dsk-dev kubespray 이동
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
---
|
||||
- name: Cilium | Start Resources
|
||||
kube:
|
||||
name: "{{ item.item.name }}"
|
||||
namespace: "kube-system"
|
||||
kubectl: "{{ bin_dir }}/kubectl"
|
||||
resource: "{{ item.item.type }}"
|
||||
filename: "{{ kube_config_dir }}/{{ item.item.name }}-{{ item.item.file }}"
|
||||
state: "latest"
|
||||
loop: "{{ cilium_node_manifests.results }}"
|
||||
when: inventory_hostname == groups['kube_control_plane'][0] and not item is skipped
|
||||
|
||||
- name: Cilium | Wait for pods to run
|
||||
command: "{{ kubectl }} -n kube-system get pods -l k8s-app=cilium -o jsonpath='{.items[?(@.status.containerStatuses[0].ready==false)].metadata.name}'" # noqa 601
|
||||
register: pods_not_ready
|
||||
until: pods_not_ready.stdout.find("cilium")==-1
|
||||
retries: "{{ cilium_rolling_restart_wait_retries_count | int }}"
|
||||
delay: "{{ cilium_rolling_restart_wait_retries_delay_seconds | int }}"
|
||||
failed_when: false
|
||||
when: inventory_hostname == groups['kube_control_plane'][0]
|
||||
|
||||
- name: Cilium | Hubble install
|
||||
kube:
|
||||
name: "{{ item.item.name }}"
|
||||
namespace: "kube-system"
|
||||
kubectl: "{{ bin_dir }}/kubectl"
|
||||
resource: "{{ item.item.type }}"
|
||||
filename: "{{ kube_config_dir }}/addons/hubble/{{ item.item.name }}-{{ item.item.file }}"
|
||||
state: "latest"
|
||||
loop: "{{ cilium_hubble_manifests.results }}"
|
||||
when:
|
||||
- inventory_hostname == groups['kube_control_plane'][0] and not item is skipped
|
||||
- cilium_enable_hubble and cilium_hubble_install
|
||||
@@ -0,0 +1,63 @@
|
||||
---
|
||||
- name: Cilium | Check Cilium encryption `cilium_ipsec_key` for ipsec
|
||||
assert:
|
||||
that:
|
||||
- "cilium_ipsec_key is defined"
|
||||
msg: "cilium_ipsec_key should be defined to enable encryption using ipsec"
|
||||
when:
|
||||
- cilium_encryption_enabled
|
||||
- cilium_encryption_type == "ipsec"
|
||||
- cilium_tunnel_mode in ['vxlan']
|
||||
|
||||
# TODO: Clean this task up when we drop backward compatibility support for `cilium_ipsec_enabled`
|
||||
- name: Stop if `cilium_ipsec_enabled` is defined and `cilium_encryption_type` is not `ipsec`
|
||||
assert:
|
||||
that: cilium_encryption_type == 'ipsec'
|
||||
msg: >
|
||||
It is not possible to use `cilium_ipsec_enabled` when `cilium_encryption_type` is set to {{ cilium_encryption_type }}.
|
||||
when:
|
||||
- cilium_ipsec_enabled is defined
|
||||
- cilium_ipsec_enabled
|
||||
- kube_network_plugin == 'cilium' or cilium_deploy_additionally | default(false) | bool
|
||||
|
||||
- name: Stop if kernel version is too low for Cilium Wireguard encryption
|
||||
assert:
|
||||
that: ansible_kernel.split('-')[0] is version('5.6.0', '>=')
|
||||
when:
|
||||
- kube_network_plugin == 'cilium' or cilium_deploy_additionally | default(false) | bool
|
||||
- cilium_encryption_enabled
|
||||
- cilium_encryption_type == "wireguard"
|
||||
- not ignore_assert_errors
|
||||
|
||||
- name: Stop if bad Cilium identity allocation mode
|
||||
assert:
|
||||
that: cilium_identity_allocation_mode in ['crd', 'kvstore']
|
||||
msg: "cilium_identity_allocation_mode must be either 'crd' or 'kvstore'"
|
||||
|
||||
- name: Stop if bad Cilium Cluster ID
|
||||
assert:
|
||||
that:
|
||||
- cilium_cluster_id <= 255
|
||||
- cilium_cluster_id >= 0
|
||||
msg: "'cilium_cluster_id' must be between 1 and 255"
|
||||
when: cilium_cluster_id is defined
|
||||
|
||||
- name: Stop if bad encryption type
|
||||
assert:
|
||||
that: cilium_encryption_type in ['ipsec', 'wireguard']
|
||||
msg: "cilium_encryption_type must be either 'ipsec' or 'wireguard'"
|
||||
when: cilium_encryption_enabled
|
||||
|
||||
- name: Stop if cilium_version is < v1.10.0
|
||||
assert:
|
||||
that: cilium_version | regex_replace('v') is version(cilium_min_version_required, '>=')
|
||||
msg: "cilium_version is too low. Minimum version {{ cilium_min_version_required }}"
|
||||
|
||||
# TODO: Clean this task up when we drop backward compatibility support for `cilium_ipsec_enabled`
|
||||
- name: Set `cilium_encryption_type` to "ipsec" and if `cilium_ipsec_enabled` is true
|
||||
set_fact:
|
||||
cilium_encryption_type: ipsec
|
||||
cilium_encryption_enabled: true
|
||||
when:
|
||||
- cilium_ipsec_enabled is defined
|
||||
- cilium_ipsec_enabled
|
||||
@@ -0,0 +1,97 @@
|
||||
---
|
||||
- name: Cilium | Ensure BPFFS mounted
|
||||
mount:
|
||||
fstype: bpf
|
||||
path: /sys/fs/bpf
|
||||
src: bpffs
|
||||
state: mounted
|
||||
|
||||
- name: Cilium | Create Cilium certs directory
|
||||
file:
|
||||
dest: "{{ cilium_cert_dir }}"
|
||||
state: directory
|
||||
mode: 0750
|
||||
owner: root
|
||||
group: root
|
||||
when:
|
||||
- cilium_identity_allocation_mode == "kvstore"
|
||||
|
||||
- name: Cilium | Link etcd certificates for cilium
|
||||
file:
|
||||
src: "{{ etcd_cert_dir }}/{{ item.s }}"
|
||||
dest: "{{ cilium_cert_dir }}/{{ item.d }}"
|
||||
mode: 0644
|
||||
state: hard
|
||||
force: yes
|
||||
loop:
|
||||
- {s: "{{ kube_etcd_cacert_file }}", d: "ca_cert.crt"}
|
||||
- {s: "{{ kube_etcd_cert_file }}", d: "cert.crt"}
|
||||
- {s: "{{ kube_etcd_key_file }}", d: "key.pem"}
|
||||
when:
|
||||
- cilium_identity_allocation_mode == "kvstore"
|
||||
|
||||
- name: Cilium | Create hubble dir
|
||||
file:
|
||||
path: "{{ kube_config_dir }}/addons/hubble"
|
||||
state: directory
|
||||
owner: root
|
||||
group: root
|
||||
mode: 0755
|
||||
when:
|
||||
- inventory_hostname == groups['kube_control_plane'][0]
|
||||
- cilium_hubble_install
|
||||
|
||||
- name: Cilium | Create Cilium node manifests
|
||||
template:
|
||||
src: "{{ item.name }}/{{ item.file }}.j2"
|
||||
dest: "{{ kube_config_dir }}/{{ item.name }}-{{ item.file }}"
|
||||
mode: 0644
|
||||
loop:
|
||||
- {name: cilium, file: config.yml, type: cm}
|
||||
- {name: cilium-operator, file: crb.yml, type: clusterrolebinding}
|
||||
- {name: cilium-operator, file: cr.yml, type: clusterrole}
|
||||
- {name: cilium, file: crb.yml, type: clusterrolebinding}
|
||||
- {name: cilium, file: cr.yml, type: clusterrole}
|
||||
- {name: cilium, file: secret.yml, type: secret, when: "{{ cilium_encryption_enabled and cilium_encryption_type == 'ipsec' }}"}
|
||||
- {name: cilium, file: ds.yml, type: ds}
|
||||
- {name: cilium-operator, file: deploy.yml, type: deploy}
|
||||
- {name: cilium-operator, file: sa.yml, type: sa}
|
||||
- {name: cilium, file: sa.yml, type: sa}
|
||||
register: cilium_node_manifests
|
||||
when:
|
||||
- inventory_hostname in groups['kube_control_plane']
|
||||
- item.when | default(True) | bool
|
||||
|
||||
- name: Cilium | Create Cilium Hubble manifests
|
||||
template:
|
||||
src: "{{ item.name }}/{{ item.file }}.j2"
|
||||
dest: "{{ kube_config_dir }}/addons/hubble/{{ item.name }}-{{ item.file }}"
|
||||
mode: 0644
|
||||
loop:
|
||||
- {name: hubble, file: config.yml, type: cm}
|
||||
- {name: hubble, file: crb.yml, type: clusterrolebinding}
|
||||
- {name: hubble, file: cr.yml, type: clusterrole}
|
||||
- {name: hubble, file: cronjob.yml, type: cronjob, when: "{{ cilium_hubble_tls_generate }}"}
|
||||
- {name: hubble, file: deploy.yml, type: deploy}
|
||||
- {name: hubble, file: job.yml, type: job, when: "{{ cilium_hubble_tls_generate }}"}
|
||||
- {name: hubble, file: sa.yml, type: sa}
|
||||
- {name: hubble, file: service.yml, type: service}
|
||||
register: cilium_hubble_manifests
|
||||
when:
|
||||
- inventory_hostname == groups['kube_control_plane'][0]
|
||||
- cilium_enable_hubble and cilium_hubble_install
|
||||
- item.when | default(True) | bool
|
||||
|
||||
- name: Cilium | Enable portmap addon
|
||||
template:
|
||||
src: 000-cilium-portmap.conflist.j2
|
||||
dest: /etc/cni/net.d/000-cilium-portmap.conflist
|
||||
mode: 0644
|
||||
when: cilium_enable_portmap
|
||||
|
||||
- name: Cilium | Copy Ciliumcli binary from download dir
|
||||
copy:
|
||||
src: "{{ local_release_dir }}/cilium"
|
||||
dest: "{{ bin_dir }}/cilium"
|
||||
mode: 0755
|
||||
remote_src: yes
|
||||
@@ -0,0 +1,6 @@
|
||||
---
|
||||
- import_tasks: check.yml
|
||||
|
||||
- include_tasks: install.yml
|
||||
|
||||
- include_tasks: apply.yml
|
||||
@@ -0,0 +1,9 @@
|
||||
---
|
||||
- name: reset | check and remove devices if still present
|
||||
include_tasks: reset_iface.yml
|
||||
vars:
|
||||
iface: "{{ item }}"
|
||||
loop:
|
||||
- cilium_host
|
||||
- cilium_net
|
||||
- cilium_vxlan
|
||||
@@ -0,0 +1,12 @@
|
||||
---
|
||||
- name: "reset | check if network device {{ iface }} is present"
|
||||
stat:
|
||||
path: "/sys/class/net/{{ iface }}"
|
||||
get_attributes: no
|
||||
get_checksum: no
|
||||
get_mime: no
|
||||
register: device_remains
|
||||
|
||||
- name: "reset | remove network device {{ iface }}"
|
||||
command: "ip link del {{ iface }}"
|
||||
when: device_remains.stat.exists
|
||||
Reference in New Issue
Block a user