Skip to content
Snippets Groups Projects
Commit f12ecdc4 authored by Mauricio Lima's avatar Mauricio Lima Committed by caoyuan
Browse files

Optimize reconfiguration for kuryr


Co-Authored-By: default avatarcaoyuan <cao.yuan@99cloud.net>
Change-Id: I6f14860090765d3fb515238dc1525c5fc718f803
Partially-implements: blueprint better-reconfigure
parent 5e121790
No related branches found
No related tags found
No related merge requests found
--- ---
project_name: "kuryr" project_name: "kuryr"
# NOTE(huikang, apuimedo): when you request a driver in a docker operation, such
# as docker network create, docker searches /usr/lib/docker or /etc/docker
# subdirs for network/storage plugin specs or json definitions. so it's either
# have ansible place the file there, or volume mount it and let the container
# place the file there
kuryr_services:
kuryr:
container_name: kuryr
group: compute
enabled: True
image: "{{ kuryr_image_full }}"
privileged: True
volumes:
- "{{ node_config_directory }}/kuryr/:{{ container_config_directory }}/:ro"
- "/etc/localtime:/etc/localtime:ro"
- "/run:/run:shared"
- "/usr/lib/docker:/usr/lib/docker"
#################### ####################
# Docker # Docker
......
---
- name: Restart kuryr container
vars:
service_name: "kuryr"
service: "{{ kuryr_services[service_name] }}"
config_json: "{{ kuryr_config_jsons.results|selectattr('item.key', 'equalto', service_name)|first }}"
kuryr_conf: "{{ kuryr_confs.results|selectattr('item.key', 'equalto', service_name)|first }}"
policy_json: "{{ kuryr_policy_jsons.results|selectattr('item.key', 'equalto', service_name)|first }}"
kuryr_container: "{{ check_kuryr_containers.results|selectattr('item.key', 'equalto', service_name)|first }}"
kolla_docker:
action: "recreate_or_restart_container"
common_options: "{{ docker_common_options }}"
name: "{{ service.container_name }}"
image: "{{ service.image }}"
privileged: "{{ service.privileged | default(False) }}"
volumes: "{{ service.volumes }}"
when:
- action != "config"
- inventory_hostname in groups[service.group]
- service.enabled | bool
- config_json.changed | bool
or kuryr_conf.changed | bool
or kuryr_spec.changed | bool
or policy_json.changed | bool
or kuryr_container.changed | bool
--- ---
- name: Running Kuryr bootstrap container - name: Running Kuryr bootstrap container
vars:
kuryr: "{{ kuryr_services['kuryr'] }}"
kolla_docker: kolla_docker:
action: "start_container" action: "start_container"
common_options: "{{ docker_common_options }}" common_options: "{{ docker_common_options }}"
...@@ -7,13 +9,11 @@ ...@@ -7,13 +9,11 @@
environment: environment:
KOLLA_BOOTSTRAP: KOLLA_BOOTSTRAP:
KOLLA_CONFIG_STRATEGY: "{{ config_strategy }}" KOLLA_CONFIG_STRATEGY: "{{ config_strategy }}"
image: "{{ kuryr_image_full }}" image: "{{ kuryr.image }}"
labels: labels:
BOOTSTRAP: BOOTSTRAP:
name: "bootstrap_kuryr" name: "bootstrap_kuryr"
restart_policy: "never" restart_policy: "never"
volumes: volumes: "{{ kuryr.volumes }}"
- "{{ node_config_directory }}/kuryr/:{{ container_config_directory }}/:ro" run_once: True
- "/etc/localtime:/etc/localtime:ro" delegate_to: "{{ groups[kuryr.group][0] }}"
- "/run:/run:shared"
- "/usr/lib/docker:/usr/lib/docker"
--- ---
- name: Ensuring config directories exist - name: Ensuring config directories exist
file: file:
path: "{{ node_config_directory }}/{{ item }}" path: "{{ node_config_directory }}/{{ item.key }}"
state: "directory" state: "directory"
recurse: yes recurse: yes
with_items: when:
- "kuryr" - inventory_hostname in groups[item.value.group]
- item.value.enabled | bool
with_dict: "{{ kuryr_services }}"
- name: Copying over config.json files for services - name: Copying over config.json files for services
template: template:
src: "{{ item }}.json.j2" src: "{{ item.key }}.json.j2"
dest: "{{ node_config_directory }}/{{ item }}/config.json" dest: "{{ node_config_directory }}/{{ item.key }}/config.json"
with_items: register: kuryr_config_jsons
- "kuryr" when:
- inventory_hostname in groups[item.value.group]
- item.value.enabled | bool
with_dict: "{{ kuryr_services }}"
notify:
- Restart kuryr container
- name: Copying over kuryr.conf - name: Copying over kuryr.conf
template: merge_configs:
src: "kuryr.conf.j2" vars:
dest: "{{ node_config_directory }}/kuryr/kuryr.conf" service_name: "{{ item.key }}"
sources:
- "{{ role_path }}/templates/kuryr.conf.j2"
- "{{ node_custom_config }}/global.conf"
- "{{ node_custom_config }}/database.conf"
- "{{ node_custom_config }}/messaging.conf"
- "{{ node_custom_config }}/kuryr.conf"
- "{{ node_custom_config }}/kuryr/{{ item.key }}.conf"
- "{{ node_custom_config }}/kuryr/{{ inventory_hostname }}/{{ item.key }}.conf"
dest: "{{ node_config_directory }}/{{ item.key }}/kuryr.conf"
register: kuryr_confs
when:
- inventory_hostname in groups[item.value.group]
- item.value.enabled | bool
with_dict: "{{ kuryr_services }}"
notify:
- Restart kuryr container
- name: Copying over kuryr.spec - name: Copying over kuryr.spec
vars:
service: "{{ kuryr_services['kuryr']}}"
template: template:
src: "kuryr.spec.j2" src: "kuryr.spec.j2"
dest: "{{ node_config_directory }}/kuryr/kuryr.spec" dest: "{{ node_config_directory }}/{{ item }}/kuryr.spec"
register: kuryr_spec
when:
- inventory_hostname in groups[service.group]
- service.enabled | bool
with_items:
- "kuryr"
notify:
- Restart kuryr container
- name: Check if policies shall be overwritten - name: Check if policies shall be overwritten
local_action: stat path="{{ node_custom_config }}/kuryr/policy.json" local_action: stat path="{{ node_custom_config }}/kuryr/policy.json"
...@@ -31,6 +64,29 @@ ...@@ -31,6 +64,29 @@
- name: Copying over existing policy.json - name: Copying over existing policy.json
template: template:
src: "{{ node_custom_config }}/kuryr/policy.json" src: "{{ node_custom_config }}/kuryr/policy.json"
dest: "{{ node_config_directory }}/kuryr/policy.json" dest: "{{ node_config_directory }}/{{ item.key }}/policy.json"
register: kuryr_policy_jsons
when:
- kuryr_policy.stat.exists
- inventory_hostname in groups[item.value.group]
- item.value.enabled | bool
with_dict: "{{ kuryr_services }}"
notify:
- Restart kuryr container
- name: Check kuryr containers
kolla_docker:
action: "compare_container"
common_options: "{{ docker_common_options }}"
name: "{{ item.value.container_name }}"
image: "{{ item.value.image }}"
privileged: "{{ item.value.privileged|default(False) }}"
volumes: "{{ item.value.volumes }}"
register: check_kuryr_containers
when: when:
kuryr_policy.stat.exists - action != "config"
- inventory_hostname in groups[item.value.group]
- item.value.enabled | bool
with_dict: "{{ kuryr_services }}"
notify:
- Restart kuryr container
...@@ -5,4 +5,5 @@ ...@@ -5,4 +5,5 @@
- include: bootstrap.yml - include: bootstrap.yml
- include: start.yml - name: Flush handlers
meta: flush_handlers
---
- include: deploy.yml
---
# NOTE(huikang, apuimedo): when you request a driver in a docker operation, such
# as docker network create, docker searches /usr/lib/docker or /etc/docker
# subdirs for network/storage plugin specs or json definitions. so it's either
# have ansible place the file there, or volume mount it and let the container
# place the file there
- name: Starting kuryr container
kolla_docker:
action: "start_container"
common_options: "{{ docker_common_options }}"
image: "{{ kuryr_image_full }}"
name: "kuryr"
privileged: True
volumes:
- "{{ node_config_directory }}/kuryr/:{{ container_config_directory }}/:ro"
- "/etc/localtime:/etc/localtime:ro"
- "/run:/run:shared"
- "/usr/lib/docker:/usr/lib/docker"
when: inventory_hostname in groups['compute']
--- ---
- include: config.yml - include: config.yml
- include: start.yml - include: bootstrap.yml
- name: Flush handlers
meta: flush_handlers
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment