Browse Source

Update flannel use install-cni-plugin to fit upstream (#8714)

* Update flannel use install-cni-plugin to fit upstream

* Replace flannel cni repo

* Remove download flannel binary
pull/8732/head
zhengtianbao 2 years ago
committed by GitHub
parent
commit
937e64d296
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 23 additions and 38 deletions
  1. 36
      roles/download/defaults/main.yml
  2. 12
      roles/network_plugin/flannel/tasks/main.yml
  3. 13
      roles/network_plugin/flannel/templates/cni-flannel.yml.j2

36
roles/download/defaults/main.yml

@ -138,7 +138,6 @@ kubelet_download_url: "https://storage.googleapis.com/kubernetes-release/release
kubectl_download_url: "https://storage.googleapis.com/kubernetes-release/release/{{ kube_version }}/bin/linux/{{ image_arch }}/kubectl" kubectl_download_url: "https://storage.googleapis.com/kubernetes-release/release/{{ kube_version }}/bin/linux/{{ image_arch }}/kubectl"
kubeadm_download_url: "https://storage.googleapis.com/kubernetes-release/release/{{ kubeadm_version }}/bin/linux/{{ image_arch }}/kubeadm" kubeadm_download_url: "https://storage.googleapis.com/kubernetes-release/release/{{ kubeadm_version }}/bin/linux/{{ image_arch }}/kubeadm"
etcd_download_url: "https://github.com/etcd-io/etcd/releases/download/{{ etcd_version }}/etcd-{{ etcd_version }}-linux-{{ image_arch }}.tar.gz" etcd_download_url: "https://github.com/etcd-io/etcd/releases/download/{{ etcd_version }}/etcd-{{ etcd_version }}-linux-{{ image_arch }}.tar.gz"
flannel_cni_download_url: "https://github.com/flannel-io/cni-plugin/releases/download/{{ flannel_cni_version }}/flannel-{{ image_arch }}"
cni_download_url: "https://github.com/containernetworking/plugins/releases/download/{{ cni_version }}/cni-plugins-linux-{{ image_arch }}-{{ cni_version }}.tgz" cni_download_url: "https://github.com/containernetworking/plugins/releases/download/{{ cni_version }}/cni-plugins-linux-{{ image_arch }}-{{ cni_version }}.tgz"
calicoctl_download_url: "https://github.com/projectcalico/calicoctl/releases/download/{{ calico_ctl_version }}/calicoctl-linux-{{ image_arch }}" calicoctl_download_url: "https://github.com/projectcalico/calicoctl/releases/download/{{ calico_ctl_version }}/calicoctl-linux-{{ image_arch }}"
calicoctl_alternate_download_url: "https://github.com/projectcalico/calico/releases/download/{{ calico_ctl_version }}/calicoctl-linux-{{ image_arch }}" calicoctl_alternate_download_url: "https://github.com/projectcalico/calico/releases/download/{{ calico_ctl_version }}/calicoctl-linux-{{ image_arch }}"
@ -531,16 +530,6 @@ etcd_binary_checksums:
v3.5.2: 3d37187b042a32b7234a1e2a4612374db50c9a50e0cdd63baaa0d52d91335186 v3.5.2: 3d37187b042a32b7234a1e2a4612374db50c9a50e0cdd63baaa0d52d91335186
v3.5.3: f14154897ca5ad4698383b4c197001340fbe467525f6fab3b89ee8116246480f v3.5.3: f14154897ca5ad4698383b4c197001340fbe467525f6fab3b89ee8116246480f
flannel_cni_binary_checksums:
arm:
v1.0.0: bd36adccabf9974c0a9f9a09bfe35558ddeb83636efefa94bc260ef267e14671
arm64:
v1.0.0: eb7183498b5d1ae4034dde6184e4396270e29ed88482b295f81b93eb3120c61c
amd64:
v1.0.0: 22dc9152571167f30d59d1e512bb7f4b4978175ddd46a30b24ad247c8c843dd7
ppc64le:
v1.0.0: 994d206a84013b050677d3e09b53485faaa9e769a43065cf4674efb52fafb18c
cni_binary_checksums: cni_binary_checksums:
arm: arm:
v1.0.1: d35e3e9fd71687fc7e165f7dc7b1e35654b8012995bbfd937946b0681926d62d v1.0.1: d35e3e9fd71687fc7e165f7dc7b1e35654b8012995bbfd937946b0681926d62d
@ -800,7 +789,6 @@ containerd_archive_checksums:
1.6.2: 0 1.6.2: 0
etcd_binary_checksum: "{{ etcd_binary_checksums[image_arch][etcd_version] }}" etcd_binary_checksum: "{{ etcd_binary_checksums[image_arch][etcd_version] }}"
flannel_cni_binary_checksum: "{{ flannel_cni_binary_checksums[image_arch][flannel_cni_version] }}"
cni_binary_checksum: "{{ cni_binary_checksums[image_arch][cni_version] }}" cni_binary_checksum: "{{ cni_binary_checksums[image_arch][cni_version] }}"
kubelet_binary_checksum: "{{ kubelet_checksums[image_arch][kube_version] }}" kubelet_binary_checksum: "{{ kubelet_checksums[image_arch][kube_version] }}"
kubectl_binary_checksum: "{{ kubectl_checksums[image_arch][kube_version] }}" kubectl_binary_checksum: "{{ kubectl_checksums[image_arch][kube_version] }}"
@ -833,6 +821,8 @@ etcd_image_repo: "{{ quay_image_repo }}/coreos/etcd"
etcd_image_tag: "{{ etcd_version }}{%- if image_arch != 'amd64' -%}-{{ image_arch }}{%- endif -%}" etcd_image_tag: "{{ etcd_version }}{%- if image_arch != 'amd64' -%}-{{ image_arch }}{%- endif -%}"
flannel_image_repo: "{{ quay_image_repo }}/coreos/flannel" flannel_image_repo: "{{ quay_image_repo }}/coreos/flannel"
flannel_image_tag: "{{ flannel_version }}-{{ image_arch }}" flannel_image_tag: "{{ flannel_version }}-{{ image_arch }}"
flannel_init_image_repo: "{{ docker_image_repo }}/flannelcni/flannel-cni-plugin"
flannel_init_image_tag: "{{ flannel_cni_version }}"
calico_node_image_repo: "{{ quay_image_repo }}/calico/node" calico_node_image_repo: "{{ quay_image_repo }}/calico/node"
calico_node_image_tag: "{{ calico_version }}{%- if image_arch != 'amd64' -%}-{{ image_arch }}{%- endif -%}" calico_node_image_tag: "{{ calico_version }}{%- if image_arch != 'amd64' -%}-{{ image_arch }}{%- endif -%}"
calico_cni_image_repo: "{{ quay_image_repo }}/calico/cni" calico_cni_image_repo: "{{ quay_image_repo }}/calico/cni"
@ -1020,19 +1010,6 @@ downloads:
groups: groups:
- etcd - etcd
flannel_cni:
enabled: "{{ kube_network_plugin == 'flannel' }}"
file: true
version: "{{ flannel_cni_version }}"
dest: "{{ local_release_dir }}/flannel-{{ flannel_cni_version }}-{{ image_arch }}"
sha256: "{{ flannel_cni_binary_checksum }}"
url: "{{ flannel_cni_download_url }}"
unarchive: false
owner: "root"
mode: "0755"
groups:
- k8s_cluster
cni: cni:
enabled: true enabled: true
file: true file: true
@ -1260,6 +1237,15 @@ downloads:
groups: groups:
- k8s_cluster - k8s_cluster
flannel_init:
enabled: "{{ kube_network_plugin == 'flannel' or kube_network_plugin == 'canal' }}"
container: true
repo: "{{ flannel_init_image_repo }}"
tag: "{{ flannel_init_image_tag }}"
sha256: "{{ flannel_init_digest_checksum|default(None) }}"
groups:
- k8s_cluster
calicoctl: calicoctl:
enabled: "{{ kube_network_plugin == 'calico' or kube_network_plugin == 'canal' }}" enabled: "{{ kube_network_plugin == 'calico' or kube_network_plugin == 'canal' }}"
file: true file: true

12
roles/network_plugin/flannel/tasks/main.yml

@ -1,16 +1,4 @@
--- ---
- name: runc | Download flannel binary
include_tasks: "../../../download/tasks/download_file.yml"
vars:
download: "{{ download_defaults | combine(downloads.flannel_cni) }}"
- name: Copy flannel binary from download dir
copy:
src: "{{ downloads.flannel_cni.dest }}"
dest: "/opt/cni/bin/flannel"
mode: 0755
remote_src: true
- name: Flannel | Create Flannel manifests - name: Flannel | Create Flannel manifests
template: template:
src: "{{ item.file }}.j2" src: "{{ item.file }}.j2"

13
roles/network_plugin/flannel/templates/cni-flannel.yml.j2

@ -108,6 +108,17 @@ spec:
values: values:
- {{ arch }} - {{ arch }}
initContainers: initContainers:
- name: install-cni-plugin
image: {{ flannel_init_image_repo }}:{{ flannel_init_image_tag }}
command:
- cp
args:
- -f
- /flannel
- /opt/cni/bin/flannel
volumeMounts:
- name: cni-plugin
mountPath: /opt/cni/bin
- name: install-cni - name: install-cni
image: {{ flannel_image_repo }}:{{ flannel_image_tag | regex_replace(image_arch,'') }}{{ arch }} image: {{ flannel_image_repo }}:{{ flannel_image_tag | regex_replace(image_arch,'') }}{{ arch }}
command: command:
@ -135,7 +146,7 @@ spec:
- name: flannel-cfg - name: flannel-cfg
configMap: configMap:
name: kube-flannel-cfg name: kube-flannel-cfg
- name: host-cni-bin
- name: cni-plugin
hostPath: hostPath:
path: /opt/cni/bin path: /opt/cni/bin
updateStrategy: updateStrategy:

Loading…
Cancel
Save