[multus] added support for mixed type of container engine
This commit is contained in:
parent
e6976a54e1
commit
58f62d8f47
3 changed files with 28 additions and 4 deletions
|
@ -7,5 +7,5 @@
|
|||
resource: "{{ item.item.type }}"
|
||||
filename: "{{ kube_config_dir }}/{{ item.item.file }}"
|
||||
state: "latest"
|
||||
with_items: "{{ multus_manifest_1.results }} + {{ multus_manifest_2.results }}"
|
||||
with_items: "{{ multus_manifest_1.results }} + {{ groups['k8s_cluster']|map('extract', hostvars, 'multus_manifest_2')|list|json_query('[].results') }}"
|
||||
when: inventory_hostname == groups['kube_control_plane'][0] and not item is skipped
|
||||
|
|
|
@ -10,12 +10,28 @@
|
|||
- {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 }}"
|
||||
run_once: true
|
||||
when: inventory_hostname == groups['kube_control_plane'][0]
|
||||
|
||||
- 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 a new issue