From e43da173b4b8c1c0709b106fcdb85388e22ad63a Mon Sep 17 00:00:00 2001 From: a1exdandy Date: Tue, 20 Apr 2021 20:18:35 +0300 Subject: [PATCH] add cilium --- defaults/main.yml | 3 +++ tasks/master-setup.yml | 33 +++++++++++++++++++++++++++++ templates/cilium-kustomization.yaml | 9 ++++++++ templates/cilium-patch.yaml | 3 +++ 4 files changed, 48 insertions(+) create mode 100644 templates/cilium-kustomization.yaml create mode 100644 templates/cilium-patch.yaml diff --git a/defaults/main.yml b/defaults/main.yml index 67816a9..71eae03 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -51,3 +51,6 @@ kubernetes_flannel_manifest_file: https://raw.githubusercontent.com/coreos/flann # Calico config files kubernetes_calico_manifest_file: https://docs.projectcalico.org/v3.10/manifests/calico.yaml + +# Cilium config files +kubernetes_cilium_manifest_file: https://raw.githubusercontent.com/cilium/cilium/v1.9/install/kubernetes/quick-install.yaml diff --git a/tasks/master-setup.yml b/tasks/master-setup.yml index 80aa346..7c0600f 100644 --- a/tasks/master-setup.yml +++ b/tasks/master-setup.yml @@ -60,6 +60,39 @@ changed_when: "'created' in weave_result.stdout" when: kubernetes_pod_network.cni == 'weave' +- name: Create temporary directory for Cilium kustomization. + tempfile: + state: directory + prefix: "cilium-kustomize." + register: cilium_kustomize_dir + when: kubernetes_pod_network.cni == 'cilium' + +- name: Get cilium manifest. + get_url: + url: "{{ kubernetes_cilium_manifest_file }}" + dest: "{{ cilium_kustomize_dir.path }}/cilium.yaml" + when: kubernetes_pod_network.cni == 'cilium' + +- name: Add cilium kustomization.yaml. + template: + src: "cilium-kustomization.yaml" + dest: "{{ cilium_kustomize_dir.path }}/kustomization.yaml" + when: kubernetes_pod_network.cni == 'cilium' + +- name: Add cilium patch.yaml. + template: + src: "cilium-patch.yaml" + dest: "{{ cilium_kustomize_dir.path }}/patch.yaml" + when: kubernetes_pod_network.cni == 'cilium' + +- name: Configure Cilium networking. + command: "{{ item }}" + with_items: + - kubectl apply -k {{ cilium_kustomize_dir.path }} + register: cilium_result + changed_when: "'created' in cilium_result.stdout" + when: kubernetes_pod_network.cni == 'cilium' + # TODO: Check if taint exists with something like `kubectl describe nodes` # instead of using kubernetes_init_stat.stat.exists check. - name: Allow pods on master node (if configured). diff --git a/templates/cilium-kustomization.yaml b/templates/cilium-kustomization.yaml new file mode 100644 index 0000000..c3a47d4 --- /dev/null +++ b/templates/cilium-kustomization.yaml @@ -0,0 +1,9 @@ +resources: +- cilium.yaml + +patchesJson6902: +- path: patch.yaml + target: + version: v1 + kind: ConfigMap + name: cilium-config diff --git a/templates/cilium-patch.yaml b/templates/cilium-patch.yaml new file mode 100644 index 0000000..a62d8b0 --- /dev/null +++ b/templates/cilium-patch.yaml @@ -0,0 +1,3 @@ +- op: replace + path: /data/cluster-pool-ipv4-cidr + value: "{{ kubernetes_pod_network.cidr }}"