From 1be064692d9d30cf867c469e7e22da581a97dcc2 Mon Sep 17 00:00:00 2001 From: Devin Buhl Date: Sat, 1 Jul 2023 17:56:29 -0400 Subject: [PATCH] feat: Keep kube-vip-rbac and delete stale addon resources Signed-off-by: Devin Buhl --- ansible/inventory/group_vars/kubernetes/k3s.yml | 2 +- ansible/playbooks/cluster-installation.yml | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/ansible/inventory/group_vars/kubernetes/k3s.yml b/ansible/inventory/group_vars/kubernetes/k3s.yml index eb90a831..ce0d05f7 100644 --- a/ansible/inventory/group_vars/kubernetes/k3s.yml +++ b/ansible/inventory/group_vars/kubernetes/k3s.yml @@ -15,7 +15,7 @@ k3s_registration_address: "{{ kubevip_address }}" k3s_server_manifests_urls: # Kube-vip RBAC - url: https://raw.githubusercontent.com/kube-vip/kube-vip/main/docs/manifests/rbac.yaml - filename: custom-kube-vip-rbac.yaml + filename: kube-vip-rbac.yaml # Essential Prometheus Operator CRDs (the rest are installed with the kube-prometheus-stack helm release) - url: https://raw.githubusercontent.com/prometheus-operator/prometheus-operator/v0.66.0/example/prometheus-operator-crd/monitoring.coreos.com_podmonitors.yaml filename: custom-prometheus-podmonitors.yaml diff --git a/ansible/playbooks/cluster-installation.yml b/ansible/playbooks/cluster-installation.yml index fd83790f..6beb7c07 100644 --- a/ansible/playbooks/cluster-installation.yml +++ b/ansible/playbooks/cluster-installation.yml @@ -145,6 +145,19 @@ path: "{{ item.path }}" state: absent loop: "{{ custom_manifest.files }}" + - name: Custom manifests (2) | Get list of custom addons + kubernetes.core.k8s_info: + kubeconfig: /etc/rancher/k3s/k3s.yaml + kind: Addon + register: addons_list + - name: Custom manifests (2) | Delete addons + kubernetes.core.k8s: + kubeconfig: /etc/rancher/k3s/k3s.yaml + name: "{{ item.metadata.name }}" + kind: Addon + namespace: kube-system + state: absent + loop: "{{ addons_list.resources | selectattr('metadata.name', 'match', '^custom-.*') | list }}" # https://github.com/k3s-io/k3s/issues/1900 - name: Stale containers