[multus] added support for mixed type of container engine (#9224)
* [multus] added support for mixed type of container engine * [multus] fixed for using with cluster/upgrade-cluster/scale playbookspull/9674/head
parent
19bc610f44
commit
d919c58e21
|
@ -7,5 +7,11 @@
|
|||
resource: "{{ item.item.type }}"
|
||||
filename: "{{ kube_config_dir }}/{{ item.item.file }}"
|
||||
state: "latest"
|
||||
with_items: "{{ multus_manifest_1.results }} + {{ multus_manifest_2.results }}"
|
||||
when: inventory_hostname == groups['kube_control_plane'][0] and not item is skipped
|
||||
delegate_to: "{{ groups['kube_control_plane'][0] }}"
|
||||
run_once: true
|
||||
with_items: "{{ multus_manifest_1.results }} + {{ multus_nodes_list|map('extract', hostvars, 'multus_manifest_2')|list|json_query('[].results') }}"
|
||||
loop_control:
|
||||
label: "{{ item.item.name }}"
|
||||
vars:
|
||||
multus_nodes_list: "{{ groups['k8s_cluster'] if ansible_play_batch|length == ansible_play_hosts_all|length else ansible_play_batch }}"
|
||||
when: not item is skipped
|
||||
|
|
|
@ -10,12 +10,26 @@
|
|||
- {name: multus-clusterrole, file: multus-clusterrole.yml, type: clusterrole}
|
||||
- {name: multus-clusterrolebinding, file: multus-clusterrolebinding.yml, type: clusterrolebinding}
|
||||
register: multus_manifest_1
|
||||
when: inventory_hostname == groups['kube_control_plane'][0]
|
||||
|
||||
- name: Multus | Check container engine type
|
||||
set_fact:
|
||||
container_manager_types: "{{ ansible_play_hosts_all|map('extract', hostvars, ['container_manager'])|list|unique }}"
|
||||
|
||||
- name: Multus | Copy manifest templates
|
||||
template:
|
||||
src: "{{ item.file }}.j2"
|
||||
src: multus-daemonset.yml.j2
|
||||
dest: "{{ kube_config_dir }}/{{ item.file }}"
|
||||
mode: 0644
|
||||
with_items:
|
||||
- {name: multus-daemonset, file: multus-daemonset.yml, type: daemonset}
|
||||
- {name: multus-daemonset-containerd, file: multus-daemonset-containerd.yml, type: daemonset, engine: containerd }
|
||||
- {name: multus-daemonset-docker, file: multus-daemonset-docker.yml, type: daemonset, engine: docker }
|
||||
- {name: multus-daemonset-crio, file: multus-daemonset-crio.yml, type: daemonset, engine: crio }
|
||||
register: multus_manifest_2
|
||||
vars:
|
||||
query: "*|[?container_manager=='{{ container_manager }}']|[0].inventory_hostname"
|
||||
vars_from_node: "{{ hostvars|json_query(query) }}"
|
||||
delegate_to: "{{ groups['kube_control_plane'][0] }}"
|
||||
when:
|
||||
- item.engine in container_manager_types
|
||||
- hostvars[inventory_hostname].container_manager == item.engine
|
||||
- inventory_hostname == vars_from_node
|
||||
|
|
|
@ -2,7 +2,11 @@
|
|||
kind: DaemonSet
|
||||
apiVersion: apps/v1
|
||||
metadata:
|
||||
{% if container_manager_types|length >= 2 %}
|
||||
name: kube-multus-{{ container_manager }}-{{ image_arch }}
|
||||
{% else %}
|
||||
name: kube-multus-ds-{{ image_arch }}
|
||||
{% endif %}
|
||||
namespace: kube-system
|
||||
labels:
|
||||
tier: node
|
||||
|
@ -22,6 +26,9 @@ spec:
|
|||
dnsPolicy: ClusterFirstWithHostNet
|
||||
nodeSelector:
|
||||
kubernetes.io/arch: {{ image_arch }}
|
||||
{% if container_manager_types|length >= 2 %}
|
||||
kubespray.io/container_manager: {{ container_manager }}
|
||||
{% endif %}
|
||||
tolerations:
|
||||
- operator: Exists
|
||||
serviceAccountName: multus
|
||||
|
@ -52,6 +59,7 @@ spec:
|
|||
{% if container_manager == 'crio' %}
|
||||
- name: run
|
||||
mountPath: {{ multus_cni_run_dir }}
|
||||
mountPropagation: HostToContainer
|
||||
{% endif %}
|
||||
- name: cni
|
||||
mountPath: {{ multus_cni_conf_dir }}
|
||||
|
|
Loading…
Reference in New Issue