Skip to content

Conversation

@vrutkovs
Copy link
Contributor

@vrutkovs vrutkovs commented Aug 24, 2018

This PR adds several simple playbooks to create AWS VMs, create inventory file from a template and deprovision VMs. See test/ci/README.md update for a suggested workflow.

These playbooks would later on be used on Prow CI similar to GCP. We can't use playbooks/aws/ for this as an average dev account can't create ELBs, launch configs etc.

vars.yml is able to define custom AMIs, so Atomic would be supported - its also able to deploy more complex sets of VMs, e.g. LB - 3 masters - 2 infra nodes - 2 compute nodes.

Cluster config in test/ci/inventory/group_vars/OSEv3 is pretty minimal and requires two env vars to be set:

  • RPM_REPO to be set in openshift_additional_repos
  • IMAGE_FORMAT for oreg_url

TODO:

  • Rework launch.yml to run prerequisites and deprovision automatically
    Currently settings from a temporary inventory are not including test/ci/inventory/group_vars, so a simple include_playbook is insufficient.
  • Ensure all deps are present in openshift/origin-ansible docker image to make this work
  • Move extravars file to host_vars/localhost
    Reworked this to use test/ci/vars.yml instead
  • Rework provision and deprovision to avoid templating the inventory file - remove machines based on clusterid tag
    We still need it to run upgrades until we switch to dynamic enventory
  • Set volumes list for each host in the group
  • Refactor AMI search

TBD:

  • Require unique cluster ID and use it to deprovision instances instead of inventory?
  • Add a directory for custom cluster vars?
    This would allow us to run tests with per-PR settings (for instance, enable ASB temporary)

@openshift-ci-robot openshift-ci-robot added approved Indicates a PR has been approved by an approver from all required OWNERS files. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Aug 24, 2018
@vrutkovs vrutkovs requested a review from michaelgugino August 24, 2018 09:33
assign_public_ip: yes
instance_tags:
Name: "{{ outer_item.name_template }}-{{ item }}"
"kubernetes.io/cluster/{{ aws_cluster_id }}": "true"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODO: This needs fixing, as this var doesn't get templated for some reason

Copy link
Contributor

@DanyC97 DanyC97 Aug 24, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vrutkovs i suspect the reason for that is because is not a json. What i ended up doing internally for same thing was:

- name: Set ec2_tags fact for EC2 instances
   set_fact:
     ec2_tags: |
       {
          "kubernetes.io/cluster/{{ openshift_clusterid }}": "true",
          "Name": "{{ name }}"
       }

followed by

- name: Add tags to {{ name }} instance
   ec2_tag:
     region:  "{{ aws_region }}"
     resource: "{{ instance_id }}"
     state: present
     tags: "{{ ec2_tags }}"

hth

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, that did the trick, thanks!

Not sure if we care about owned vs. shared, might add this later

@vrutkovs vrutkovs force-pushed the prow-aws-playbooks branch from 4852912 to ae4ed43 Compare August 24, 2018 09:45
@vrutkovs vrutkovs changed the title Add playbooks to provision AWS VMs for CI WIP Add playbooks to provision AWS VMs for CI Aug 24, 2018
@openshift-ci-robot openshift-ci-robot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Aug 24, 2018
@vrutkovs vrutkovs force-pushed the prow-aws-playbooks branch 10 times, most recently from 103727f to a3ddb54 Compare August 24, 2018 16:22
region: "{{ aws_region }}"
when: is_atomic
with_items: "{{ ec2.results }}"

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i suspect you do need to tag your volumes with same kubernetes.io/cluster/ key and value above

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you want this especially if you planning to use PVs ... just saying

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a volume for Atomic's docker storage, it doesn't know about clusters and such. In any case it seems the bot on our instance is deleting those correctly without any tags

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

okay, fair point

@vrutkovs vrutkovs force-pushed the prow-aws-playbooks branch 9 times, most recently from babbd68 to c57dad8 Compare August 27, 2018 08:17
@vrutkovs vrutkovs changed the title WIP Add playbooks to provision AWS VMs for CI Add playbooks to provision AWS VMs for CI Aug 27, 2018
@vrutkovs vrutkovs force-pushed the prow-aws-playbooks branch 2 times, most recently from 6130efd to 4475ffc Compare August 30, 2018 09:19
{{ entry }} ansible_host='{{ hostvars[entry]['ansible_host'] }}' aws_id='{{ hostvars[entry]['aws_id'] }}' {{ addon_opts }}
{% endfor %}
{% endif %}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: you may want to have a nice generated ini file and as such you could do with a bit of trimming the whitespace - http://jinja.pocoo.org/docs/dev/templates/#whitespace-control

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I had this initially and it turned into a nightmare :(

This inv is temporary anyway, all it needs is the hostnames and host-specific params (just one actually) so I wouldn't care about it much

@openshift-ci-robot openshift-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Aug 30, 2018
@vrutkovs vrutkovs changed the title WIP Add playbooks to provision AWS VMs for CI Add playbooks to provision AWS VMs for CI Aug 30, 2018
@openshift-ci-robot openshift-ci-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Aug 30, 2018
@vrutkovs vrutkovs force-pushed the prow-aws-playbooks branch from 1e51abd to 85251f9 Compare August 30, 2018 17:52
instance_tags: "{{ aws_instance_tags }}"
volumes: "{{ item.aws_volumes | default(omit) }}"
register: ec2
with_items: "{{ vms }}"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

aws_instances?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

aws_region: "{{ aws_region }}"
aws_ip: "{{ item.instances.0.public_ip }}"
aws_id: "{{ item.instances.0.id }}"
node_group: "{{ item.instances.0.tags['ansible-node-group'] }}"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think 'node_group' is the correct variable name here. openshift_node_group_name ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed. This incorrectly set for in-memory inventory, but was correctly rendered in hosts/inventory

- nodes
aws_flavor: t2.large
aws_security_group: public
node_group: "node-config-all-in-one"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could be better handled by group vars.

Possible inventory groups:

[OSEv3:children]
etcd
nodes

[nodes:children]
masters
compute

[etcd:children]
masters

[masters]
master1.example.com

[master:vars]
openshift_node_group_name: node-config-master-infra

[compute]
node1.example.com

[compute:vars]
openshift_node_group_name: node-config-compute

Obviously, we can define vars sections in appropriate group_vars files and we can adjust groups for different scenarios.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That'd complicate vars.yml - a list of groups to create and assign the instance to the group? In the end I'd still have to set per-instance aws_ip and aws_id, so why not put openshift_node_group_name there too?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That'd complicate vars.yml - a list of groups to create and assign the instance to the group? In the end I'd still have to set per-instance aws_ip and aws_id, so why not put openshift_node_group_name there too?

I'm not sure what you mean. You don't need to 'create' the groups, you just make this the base template of the inventory file (since we're not using dynamic inventory).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That'd limit us in groups choice. Instead of hardcoding the list of those in the template these groups are now being created automagically. So later on we could try scale up tests, by adding hosts in new_nodes group for instance.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not a fan of this implementation, I do think we need to update our group reference architecture to reflect what an actual user should do as far as group hierarchy. I'm against using hostvars where we could use groupvars because the syntax is different between the two in ini files and users never seem to understand what hostvars actually are (you'll see inventories with same host in two groups, eg masters and nodes, and competing values set on each instance of the host).

In any case, we can revisit this later.

@vrutkovs vrutkovs force-pushed the prow-aws-playbooks branch 7 times, most recently from fa28be3 to 772af74 Compare August 31, 2018 10:29
@vrutkovs vrutkovs force-pushed the prow-aws-playbooks branch from 772af74 to 6446f05 Compare August 31, 2018 12:33
connection: local
gather_facts: false
tasks:
- include_vars: "{{ item }}"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we saying that there should be a vars.yaml on the host that is running ansible that supplies some variables? This file is provided by CI? Let's add a comment if so.

- nodes
aws_flavor: t2.large
aws_security_group: public
node_group: "node-config-all-in-one"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That'd complicate vars.yml - a list of groups to create and assign the instance to the group? In the end I'd still have to set per-instance aws_ip and aws_id, so why not put openshift_node_group_name there too?

I'm not sure what you mean. You don't need to 'create' the groups, you just make this the base template of the inventory file (since we're not using dynamic inventory).

Copy link
Contributor

@michaelgugino michaelgugino left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm

- nodes
aws_flavor: t2.large
aws_security_group: public
node_group: "node-config-all-in-one"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not a fan of this implementation, I do think we need to update our group reference architecture to reflect what an actual user should do as far as group hierarchy. I'm against using hostvars where we could use groupvars because the syntax is different between the two in ini files and users never seem to understand what hostvars actually are (you'll see inventories with same host in two groups, eg masters and nodes, and competing values set on each instance of the host).

In any case, we can revisit this later.

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Sep 5, 2018
@openshift-ci-robot
Copy link

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: michaelgugino, vrutkovs

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:
  • OWNERS [michaelgugino,vrutkovs]

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@vrutkovs
Copy link
Contributor Author

vrutkovs commented Sep 6, 2018

/cherrypick release-3.10

@openshift-cherrypick-robot

@vrutkovs: new pull request created: #9936

Details

In response to this:

/cherrypick release-3.10

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@vrutkovs vrutkovs deleted the prow-aws-playbooks branch January 5, 2019 13:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants