From 3a52c489fa38aa90b3d715b468098929dd60c6aa Mon Sep 17 00:00:00 2001 From: Tamal Saha Date: Mon, 17 Feb 2025 10:42:29 -0800 Subject: [PATCH] Make crd-manager chart kustomize friendly Signed-off-by: Tamal Saha --- apis/installer/v1alpha1/kubedb_crd_manager_types.go | 9 +++++---- charts/kubedb-crd-manager/README.md | 1 + charts/kubedb-crd-manager/templates/job.yaml | 8 +++++++- charts/kubedb-crd-manager/templates/serviceaccount.yaml | 1 + charts/kubedb-crd-manager/values.openapiv3_schema.yaml | 3 +++ charts/kubedb-crd-manager/values.yaml | 2 ++ charts/kubedb/values.openapiv3_schema.yaml | 3 +++ 7 files changed, 22 insertions(+), 5 deletions(-) diff --git a/apis/installer/v1alpha1/kubedb_crd_manager_types.go b/apis/installer/v1alpha1/kubedb_crd_manager_types.go index cc6d7a423..16e4a45a7 100644 --- a/apis/installer/v1alpha1/kubedb_crd_manager_types.go +++ b/apis/installer/v1alpha1/kubedb_crd_manager_types.go @@ -71,10 +71,11 @@ type KubedbCrdManagerSpec struct { Tolerations []core.Toleration `json:"tolerations"` // If specified, the pod's scheduling constraints // +optional - Affinity *core.Affinity `json:"affinity"` - ServiceAccount ServiceAccountSpec `json:"serviceAccount"` - FeatureGates map[string]bool `json:"featureGates"` - RemoveUnusedCRDs bool `json:"removeUnusedCRDs"` + Affinity *core.Affinity `json:"affinity"` + ServiceAccount ServiceAccountSpec `json:"serviceAccount"` + FeatureGates map[string]bool `json:"featureGates"` + RemoveUnusedCRDs bool `json:"removeUnusedCRDs"` + TTLSecondsAfterFinished int `json:"ttlSecondsAfterFinished"` } // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object diff --git a/charts/kubedb-crd-manager/README.md b/charts/kubedb-crd-manager/README.md index bf18e0f10..fc0c71562 100644 --- a/charts/kubedb-crd-manager/README.md +++ b/charts/kubedb-crd-manager/README.md @@ -62,6 +62,7 @@ The following table lists the configurable parameters of the `kubedb-crd-manager | nodeSelector | | {} | | tolerations | | [] | | affinity | | {} | +| ttlSecondsAfterFinished | | 120 | | serviceAccount.create | Specifies whether a service account should be created | true | | serviceAccount.annotations | Annotations to add to the service account | {} | | serviceAccount.name | The name of the service account to use. If not set and create is true, a name is generated using the fullname template | | diff --git a/charts/kubedb-crd-manager/templates/job.yaml b/charts/kubedb-crd-manager/templates/job.yaml index caab6537b..7ad6f554e 100644 --- a/charts/kubedb-crd-manager/templates/job.yaml +++ b/charts/kubedb-crd-manager/templates/job.yaml @@ -31,7 +31,13 @@ metadata: "helm.sh/hook-delete-policy": before-hook-creation,hook-succeeded,hook-failed spec: backoffLimit: 3 - ttlSecondsAfterFinished: 300 + {{- if ge (int .Values.ttlSecondsAfterFinished) 0 }} + ttlSecondsAfterFinished: {{ .Values.ttlSecondsAfterFinished }} + {{- end }} + manualSelector: true + selector: + matchLabels: + {{- include "kubedb-crd-manager.labels" . | nindent 6 }} template: metadata: {{- with .Values.podAnnotations }} diff --git a/charts/kubedb-crd-manager/templates/serviceaccount.yaml b/charts/kubedb-crd-manager/templates/serviceaccount.yaml index 5ff1b3f5c..c50fb2c14 100644 --- a/charts/kubedb-crd-manager/templates/serviceaccount.yaml +++ b/charts/kubedb-crd-manager/templates/serviceaccount.yaml @@ -3,6 +3,7 @@ apiVersion: v1 kind: ServiceAccount metadata: name: {{ include "kubedb-crd-manager.serviceAccountName" . }} + namespace: {{ .Release.Namespace }} labels: {{- include "kubedb-crd-manager.labels" . | nindent 4 }} annotations: diff --git a/charts/kubedb-crd-manager/values.openapiv3_schema.yaml b/charts/kubedb-crd-manager/values.openapiv3_schema.yaml index 070f0a082..637a5ac2c 100644 --- a/charts/kubedb-crd-manager/values.openapiv3_schema.yaml +++ b/charts/kubedb-crd-manager/values.openapiv3_schema.yaml @@ -1390,10 +1390,13 @@ properties: type: string type: object type: array + ttlSecondsAfterFinished: + type: integer required: - featureGates - image - imagePullPolicy - removeUnusedCRDs - serviceAccount +- ttlSecondsAfterFinished type: object diff --git a/charts/kubedb-crd-manager/values.yaml b/charts/kubedb-crd-manager/values.yaml index 405d0a4bb..4d4dcb8ca 100644 --- a/charts/kubedb-crd-manager/values.yaml +++ b/charts/kubedb-crd-manager/values.yaml @@ -59,6 +59,8 @@ tolerations: [] affinity: {} +ttlSecondsAfterFinished: 120 + serviceAccount: # Specifies whether a service account should be created create: true diff --git a/charts/kubedb/values.openapiv3_schema.yaml b/charts/kubedb/values.openapiv3_schema.yaml index a20546dc0..f45664033 100644 --- a/charts/kubedb/values.openapiv3_schema.yaml +++ b/charts/kubedb/values.openapiv3_schema.yaml @@ -4275,6 +4275,8 @@ properties: type: string type: object type: array + ttlSecondsAfterFinished: + type: integer required: - enabled - featureGates @@ -4282,6 +4284,7 @@ properties: - imagePullPolicy - removeUnusedCRDs - serviceAccount + - ttlSecondsAfterFinished type: object kubedb-kubestash-catalog: properties: