From 1147384d37497d8b74a8bedeee119700446d087a Mon Sep 17 00:00:00 2001 From: Quirin Vetterl <140174674+qrnvttrl@users.noreply.github.com> Date: Wed, 18 Sep 2024 17:00:41 +0200 Subject: [PATCH] delete pvc (#26) --- charts/gardener-extension-audit/templates/rbac.yaml | 6 ++++++ example/controller-registration.yaml | 4 ++-- pkg/controller/audit/actuator.go | 7 +++++++ 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/charts/gardener-extension-audit/templates/rbac.yaml b/charts/gardener-extension-audit/templates/rbac.yaml index f3e5530..4dab9ef 100644 --- a/charts/gardener-extension-audit/templates/rbac.yaml +++ b/charts/gardener-extension-audit/templates/rbac.yaml @@ -49,6 +49,12 @@ rules: - update - patch - delete +- apiGroups: + - "" + resources: + - persistentvolumeclaims + verbs: + - deletecollection - apiGroups: - "" resources: diff --git a/example/controller-registration.yaml b/example/controller-registration.yaml index 211e993..2987e0d 100644 --- a/example/controller-registration.yaml +++ b/example/controller-registration.yaml @@ -5,10 +5,10 @@ metadata: name: audit type: helm providerConfig: - chart: H4sIAAAAAAAAA+0c/W/btrI/668g1A7bgEr+dgcBfe+lqbcFaxMjyevewzAEtETbamRRo6Q0Wdv//R0/JFOyZNlJmrxuOgSITfE+SN4d746UF5h5JCTMItcJCWOfhhZOPT/pPLk/6AK8GI3Ef4Dyf/G5Nxj2+qP+eMzbe8PhuPsEje5RhlpI4wQzhJ4wSpNt/Zqef6WwqFv/wyVmiX2DV8GdefAFHg+Htevf7/ZK6z8evBg/Qd17GF8j/M3XH0f+O8L4ujvoqmfgKMq/mj27axoeiV3mR4loOkA/k2CFXK4baE4ZSpYECX1Buf4YIV4RB9UplnGV0e/awMB47An4m0Ot/XvUtRf0Xng02f9wXLb/EUBr/w8Bnc6COguuATghKF4iy0WmbXfg74qEHmWdhZ8s05nt0lUnU5b1hyV2LzsZuuXSMGE0CECdGFn4cQKtoFE2kJVOwkbPvnMx/BcM3k1Oz45Ojr9XX8k1XkUB6dRR4XsRmmRq6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m7xFX/47K1yR2KXo+ZlRH0DenmOwQ7GeVUcffPrRz0rWOuWfnE011/q7Jlu7Vb4/vzbN/tJwI67s9o7qAz4tdiQ59pPIlQ+40aWpkoJlDwV+JbqloUDEZBRENU/f35ZQSzxY04REPiJv76XpCF1DO5qc0k3p68whS67uVOITu+S5Cf8xqp0wcfzQva+2/We/LzF4B8tNB6P+BiLByO8MszXf69zlqc29AbY3f9jsTPdYRtoq/8Nx2X/PxxNOv//KLDN/2exyJMW8Z56gv7k0Gj/4iTtQX4AqO39n8Go8v5/9/7fI4G4JMdTuuxSnIVWazvKggXYtBP+Ix/NN9cSvLIQ3yvYt1C5KXe8PKHJHAIDdotYU2vsFhpomywSffysacplKPmuj3pVzEITaFTukokAsqlXlCwITkQfeEo+HAcQF4BSn7P7ag50HLGzx8bbYxZaYi8mmla9i2WhX3/Lmn8RO75ogxS/7tCVvanEjpTFBRCLf86OX0OcxuIaGL+5oYmjZzEtZ+qKbH6EZRPPqR8XHl30fMyCn94idT2Iuhjp3htqX5Fo6UJKmp38K1TFMq8oXXnkcnPRUuAa2HemY4nG11gfsV+EEg35zzgNzMHAvPm6RzWojEr/+ys2sqF4YJqmphWiO0sTFzWy2zYsVtTs/FH9u191b37hkBsF69RjF8Ayrd68hVXbg78fBWky/yJfXgI/qmk1rwhV2uTLO0Ko5/my+bfylpaW3YLY3G8X0wM9+MUN+M/3By3/pQhLUydP77btDjrooIMOOuiggw466KCDDjrooIMOOuiggw466KCDDjrooIMOOuiggw466KCDDjr4gvA/zURGxQB4AAA= values: image: - tag: v0.1.0 + tag: v0.1.6 --- apiVersion: core.gardener.cloud/v1beta1 kind: ControllerRegistration diff --git a/pkg/controller/audit/actuator.go b/pkg/controller/audit/actuator.go index 5c5252c..279cee6 100644 --- a/pkg/controller/audit/actuator.go +++ b/pkg/controller/audit/actuator.go @@ -247,6 +247,13 @@ func (a *actuator) deleteResources(ctx context.Context, log logr.Logger, namespa return err } + // TODO: since k8s v1.27 there is a new feature to delete the pvc automatically when the statefulSet is deleted + // https://kubernetes.io/docs/concepts/workloads/controllers/statefulset/#persistentvolumeclaim-retention + err := a.client.DeleteAllOf(ctx, &corev1.PersistentVolumeClaim{}, client.MatchingLabels{"app": "audit-webhook-backend"}, client.InNamespace(namespace)) + if err != nil { + return err + } + return nil }