Files
tripleo-heat-templates/extraconfig/services/openshift-worker.yaml
Flavio Percoco 45f5361391 Add the ability to scaleup the openshift stack
Refactored the inventory generation to allow for scaling up the
openshift stack. They deployment process now checks whether the
origin-node container is already running in the openshift nodes. All
the nodes where origin-node is not present are considered as new.

The new_masters/new_nodes sections will be populated accordingly and
the `scaleup.yml` playbook will be used instead of the `deploy_cluster`
one *only* if the stack is being updated.

Unfortunately, openshift-ansible's implementation is not as idempotent
as TripleO's, which requires differentiating between deployments,
scaleup and between new and old nodes.

Change-Id: I15c4e855a3ccfba6ce8d516b5b59e7508c4885cc
2018-07-09 14:53:35 +02:00

129 lines
5.1 KiB
YAML

heat_template_version: rocky
description: External tasks definition for OpenShift
parameters:
RoleNetIpMap:
default: {}
type: json
ServiceData:
default: {}
description: Dictionary packing service data
type: json
ServiceNetMap:
default: {}
description: Mapping of service_name -> network name. Typically set
via parameter_defaults in the resource registry. This
mapping overrides those in ServiceNetMapDefaults.
type: json
DefaultPasswords:
default: {}
type: json
RoleName:
default: ''
description: Role name on which the service is applied
type: string
RoleParameters:
default: {}
description: Parameters specific to the role
type: json
EndpointMap:
default: {}
description: Mapping of service endpoint -> protocol. Typically set
via parameter_defaults in the resource registry.
type: json
OpenShiftWorkerScaleupPlaybook:
default: '/usr/share/ansible/openshift-ansible/playbooks/openshift-node/scaleup.yml'
description: Path to OpenShift-Ansible playbook.
type: string
outputs:
role_data:
description: Role data for the Openshift Service
value:
# This service template essentially tags the nodes that we want
# as workers. The actual installation is performed in
# openshift-master service template.
service_name: openshift_worker
config_settings:
tripleo.openshift_worker.firewall_rules:
'200 openshift-worker kubelet':
dport:
- 10250
- 10255
proto: tcp
'200 openshift-worker external services':
dport: '30000-32767'
upgrade_tasks: []
step_config: ''
external_deploy_tasks:
- name: openshift_worker step 1
when: step == '1'
block:
- name: create openshift temp dirs
file:
path: "{{item}}"
state: directory
with_items:
- "{{playbook_dir}}/openshift/inventory"
- name: set global vars facts
set_fact:
tripleo_role_name: {get_param: RoleName}
openshift_worker_scaleup_playbook_path: {get_param: OpenShiftWorkerScaleupPlaybook}
- name: Check if origin-node is running
become: true
shell: >
docker inspect atomic-enterprise-node > /dev/null 2>&1
|| docker inspect origin-node > /dev/null 2>&1
|| echo "false"
register: origin_nodes
delegate_to: "{{item}}"
with_items: "{{ groups[tripleo_role_name] | default([]) }}"
- set_fact:
nodes:
- new_node: "{{origin_nodes.results | selectattr('item', 'equalto', item) | selectattr('stdout', 'equalto', 'false') | list | count > 0}}"
hostname: "{{item}}"
ansible_user: "{{ hostvars.raw_get(item)['ansible_user'] | default(hostvars.raw_get(item)['ansible_ssh_user']) | default('root') }}"
ansible_host: "{{ hostvars.raw_get(item)['ansible_host'] | default(item) }}"
ansible_become: true
etcd_ip: "{{hostvars.raw_get(item)['ctlplane_ip']}}"
openshift_ip: "{{hostvars.raw_get(item)['ctlplane_ip']}}"
openshift_public_ip: "{{hostvars.raw_get(item)['external_ip'] | default(hostvars.raw_get(item)['ctlplane_ip'])}}"
openshift_hostname: "{{hostvars.raw_get(item)['ctlplane_ip']}}"
openshift_public_hostname: "{{hostvars.raw_get(item)['external_ip'] | default(hostvars.raw_get(item)['ctlplane_ip'])}}"
openshift_schedulable: true
openshift_node_labels:
region: 'infra'
zone: 'default'
node-role.kubernetes.io/compute: true
register: all_worker_nodes
with_items: "{{groups[tripleo_role_name] | default([]) }}"
- set_fact:
worker_nodes: "{{all_worker_nodes.results | map(attribute='ansible_facts') | map(attribute='nodes') | flatten | list}}"
new_nodes: "{{all_worker_nodes.results | map(attribute='ansible_facts') | map(attribute='nodes') | flatten | selectattr('new_node', 'equalto', True) | list}}"
- copy:
dest: "{{playbook_dir}}/openshift/inventory/{{tripleo_role_name}}_openshift_worker.yml"
content: |
{% if worker_nodes | count > 0 %}
nodes:
hosts:
{% for host in worker_nodes %}
{{host.hostname}}:
{{host | to_nice_yaml() | indent(6)}}
{% endfor %}
{% endif %}
{% if new_nodes | count > 0 %}
new_nodes:
hosts:
{% for host in new_nodes %}
{{host.hostname}}:
{{host | to_nice_yaml() | indent(6)}}
{% endfor %}
{% endif %}