From 1f9020f0b496871dbfa01b7c2388b13ebdad6654 Mon Sep 17 00:00:00 2001 From: ChengHao Yang <17496418+tico88612@users.noreply.github.com> Date: Sat, 24 May 2025 20:00:16 +0800 Subject: [PATCH] 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> --- roles/network_plugin/cilium/tasks/apply.yml | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/roles/network_plugin/cilium/tasks/apply.yml b/roles/network_plugin/cilium/tasks/apply.yml index 04a761c47..b150b3384 100644 --- a/roles/network_plugin/cilium/tasks/apply.yml +++ b/roles/network_plugin/cilium/tasks/apply.yml @@ -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