[release-2.28] Fix: the cluster is upgraded from 2.27 to 2.28 cilium will break (#12324)

* Fix: add cilium remove old resources option

Give users two options: besides skip Cilium, add
`cilium_remove_old_resources`, default is `false`, when set to `true`,
it will remove the content of the old version, but it will cause the
downtime, need to be careful to use.

Signed-off-by: ChengHao Yang <17496418+tico88612@users.noreply.github.com>

* Fix: if cilium release exist, the action will set upgrade

`cilium install` is equivalent to `helm install`, it will failed if
cilium relase exist. `cilium version` can know the release exist without
helm binary

Signed-off-by: ChengHao Yang <17496418+tico88612@users.noreply.github.com>

---------

Signed-off-by: ChengHao Yang <17496418+tico88612@users.noreply.github.com>
Co-authored-by: ChengHao Yang <17496418+tico88612@users.noreply.github.com>
This commit is contained in:
k8s-infra-cherrypick-robot
2025-06-19 20:16:51 -07:00
committed by GitHub
parent cf6e96deb0
commit d7c00ce698
4 changed files with 65 additions and 1 deletions

View File

@@ -1,6 +1,17 @@
---
- name: Check if Cilium Helm release exists (via cilium version)
command: "{{ bin_dir }}/cilium version"
register: cilium_release_info
when: inventory_hostname == groups['kube_control_plane'][0]
failed_when: false
changed_when: false
- name: Set action to install or upgrade
set_fact:
cilium_action: "{{ 'install' if ('release: not found' in cilium_release_info.stderr | default('') or 'release: not found' in cilium_release_info.stdout | default('')) else 'upgrade' }}"
- name: Cilium | Install
command: "{{ bin_dir }}/cilium install --version {{ cilium_version }} -f {{ kube_config_dir }}/cilium-values.yaml"
command: "{{ bin_dir }}/cilium {{ cilium_action }} --version {{ cilium_version }} -f {{ kube_config_dir }}/cilium-values.yaml"
when: inventory_hostname == groups['kube_control_plane'][0]
- name: Cilium | Wait for pods to run