From 5cd773f357a6b596a8596c672f1270b2961b63d5 Mon Sep 17 00:00:00 2001 From: Nicholas Blott Date: Fri, 2 Dec 2022 16:20:55 +0000 Subject: [PATCH] feat: Add additionalAnnotations value and corresponding templating Signed-off-by: Nicholas Blott --- keda/README.md | 1 + keda/templates/01-serviceaccount.yaml | 3 +++ keda/templates/02-crd-clustertriggerauthentications.yaml | 3 +++ keda/templates/03-crd-scaledjobs.keda.sh.yaml | 3 +++ keda/templates/04-crd-scaledobjects.keda.sh.yaml | 3 +++ keda/templates/05-crd-triggerauthentications.keda.sh.yaml | 3 +++ keda/templates/10-keda-clusterrole.yaml | 2 ++ keda/templates/11-keda-clusterrolebinding.yaml | 4 +++- keda/templates/12-keda-deployment.yaml | 7 +++++-- keda/templates/14-keda-poddisruptionbudget.yaml | 2 ++ keda/templates/15-keda-podmonitor.yaml | 2 ++ keda/templates/16-keda-prometheusrules.yaml | 2 ++ keda/templates/20-metrics-clusterrole.yaml | 4 +++- keda/templates/21-metrics-clusterrolebinding.yaml | 6 ++++++ keda/templates/22-metrics-deployment.yaml | 3 +++ keda/templates/23-metrics-service.yaml | 1 + keda/templates/24-metrics-apiservice.yaml | 2 ++ keda/templates/25-metrics-poddisruptionbudget.yaml | 2 ++ keda/templates/26-metrics-podmonitor.yaml | 2 ++ keda/values.yaml | 5 +++++ 20 files changed, 56 insertions(+), 4 deletions(-) diff --git a/keda/README.md b/keda/README.md index 41c893e6..f0db33e5 100644 --- a/keda/README.md +++ b/keda/README.md @@ -71,6 +71,7 @@ their default values. | `metricsServer.affinity` | Affinity for pod scheduling ([docs](https://kubernetes.io/docs/tasks/configure-pod-container/assign-pods-nodes-using-node-affinity/)) for Metrics API Server. Takes precedence over the `affinity` field | `{}` | | `imagePullSecrets` | Name of secret to use to pull images to use to pull Docker images | `[]` | | `additionalLabels` | Additional labels to apply to KEDA workloads | `{}` | +| `additionalAnnotations` | Additional annotations to apply to KEDA workloads | `{}` | | `podAnnotations.keda` | Pod annotations for KEDA operator | `{}` | | `podAnnotations.metricsAdapter` | Pod annotations for KEDA Metrics Adapter | `{}` | | `upgradeStrategy.operator` | Capability to configure [Deployment upgrade strategy](https://kubernetes.io/docs/concepts/workloads/controllers/deployment/#strategy) for operator | `{}` | diff --git a/keda/templates/01-serviceaccount.yaml b/keda/templates/01-serviceaccount.yaml index 7d4a6f2b..3759dccf 100644 --- a/keda/templates/01-serviceaccount.yaml +++ b/keda/templates/01-serviceaccount.yaml @@ -10,6 +10,9 @@ metadata: {{- include "keda.labels" . | indent 4 }} {{- if or .Values.podIdentity.azureWorkload.enabled .Values.podIdentity.aws.irsa.enabled .Values.serviceAccount.annotations }} annotations: + {{- if .Values.additionalAnnotations }} + {{- toYaml .Values.additionalAnnotations | indent 4 }} + {{- end }} {{- if .Values.podIdentity.azureWorkload.enabled }} {{- if .Values.podIdentity.azureWorkload.clientId }} azure.workload.identity/client-id: {{ .Values.podIdentity.azureWorkload.clientId | quote }} diff --git a/keda/templates/02-crd-clustertriggerauthentications.yaml b/keda/templates/02-crd-clustertriggerauthentications.yaml index c32cf4a1..7eb08671 100644 --- a/keda/templates/02-crd-clustertriggerauthentications.yaml +++ b/keda/templates/02-crd-clustertriggerauthentications.yaml @@ -4,6 +4,9 @@ kind: CustomResourceDefinition metadata: annotations: controller-gen.kubebuilder.io/version: v0.9.0 + {{- if .Values.additionalAnnotations }} + {{- toYaml .Values.additionalAnnotations | indent 4 }} + {{- end }} labels: app.kubernetes.io/name: {{ .Values.operator.name }} {{- include "keda.labels" . | indent 4 }} diff --git a/keda/templates/03-crd-scaledjobs.keda.sh.yaml b/keda/templates/03-crd-scaledjobs.keda.sh.yaml index 5dd195f9..0ab19579 100644 --- a/keda/templates/03-crd-scaledjobs.keda.sh.yaml +++ b/keda/templates/03-crd-scaledjobs.keda.sh.yaml @@ -4,6 +4,9 @@ kind: CustomResourceDefinition metadata: annotations: controller-gen.kubebuilder.io/version: v0.9.0 + {{- if .Values.additionalAnnotations }} + {{- toYaml .Values.additionalAnnotations | indent 4 }} + {{- end }} labels: app.kubernetes.io/name: {{ .Values.operator.name }} {{- include "keda.labels" . | indent 4 }} diff --git a/keda/templates/04-crd-scaledobjects.keda.sh.yaml b/keda/templates/04-crd-scaledobjects.keda.sh.yaml index 5e4911b4..93698a8d 100644 --- a/keda/templates/04-crd-scaledobjects.keda.sh.yaml +++ b/keda/templates/04-crd-scaledobjects.keda.sh.yaml @@ -4,6 +4,9 @@ kind: CustomResourceDefinition metadata: annotations: controller-gen.kubebuilder.io/version: v0.9.0 + {{- if .Values.additionalAnnotations }} + {{- toYaml .Values.additionalAnnotations | indent 4 }} + {{- end }} labels: app.kubernetes.io/name: {{ .Values.operator.name }} {{- include "keda.labels" . | indent 4 }} diff --git a/keda/templates/05-crd-triggerauthentications.keda.sh.yaml b/keda/templates/05-crd-triggerauthentications.keda.sh.yaml index f9b02de5..407c3049 100644 --- a/keda/templates/05-crd-triggerauthentications.keda.sh.yaml +++ b/keda/templates/05-crd-triggerauthentications.keda.sh.yaml @@ -4,6 +4,9 @@ kind: CustomResourceDefinition metadata: annotations: controller-gen.kubebuilder.io/version: v0.9.0 + {{- if .Values.additionalAnnotations }} + {{- toYaml .Values.additionalAnnotations | indent 4 }} + {{- end }} labels: app.kubernetes.io/name: {{ .Values.operator.name }} {{- include "keda.labels" . | indent 4 }} diff --git a/keda/templates/10-keda-clusterrole.yaml b/keda/templates/10-keda-clusterrole.yaml index 4777e69a..4c1e0c3c 100644 --- a/keda/templates/10-keda-clusterrole.yaml +++ b/keda/templates/10-keda-clusterrole.yaml @@ -2,6 +2,8 @@ apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRole metadata: + annotations: + {{- toYaml .Values.additionalAnnotations | nindent 4 }} labels: app.kubernetes.io/name: {{ .Values.operator.name }} {{- include "keda.labels" . | indent 4 }} diff --git a/keda/templates/11-keda-clusterrolebinding.yaml b/keda/templates/11-keda-clusterrolebinding.yaml index d019a458..39ad8ee3 100644 --- a/keda/templates/11-keda-clusterrolebinding.yaml +++ b/keda/templates/11-keda-clusterrolebinding.yaml @@ -2,6 +2,8 @@ apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRoleBinding metadata: + annotations: + {{- toYaml .Values.additionalAnnotations | nindent 4 }} labels: app.kubernetes.io/name: {{ .Values.operator.name }} {{- include "keda.labels" . | indent 4 }} @@ -14,4 +16,4 @@ subjects: - kind: ServiceAccount name: {{ .Values.serviceAccount.name }} namespace: {{ .Release.Namespace }} -{{- end -}} \ No newline at end of file +{{- end -}} diff --git a/keda/templates/12-keda-deployment.yaml b/keda/templates/12-keda-deployment.yaml index 369c2626..784c6f82 100644 --- a/keda/templates/12-keda-deployment.yaml +++ b/keda/templates/12-keda-deployment.yaml @@ -3,6 +3,8 @@ kind: Deployment metadata: name: {{ .Values.operator.name }} namespace: {{ .Release.Namespace }} + annotations: + {{- toYaml .Values.additionalAnnotations | nindent 4 }} labels: app: {{ .Values.operator.name }} name: {{ .Values.operator.name }} @@ -28,14 +30,15 @@ spec: aadpodidbinding: {{ .Values.podIdentity.activeDirectory.identity }} {{- end }} {{- if .Values.podLabels.keda }} - {{- toYaml .Values.podLabels.keda | nindent 8}} + {{- toYaml .Values.podLabels.keda | nindent 8 }} {{- end }} {{- if .Values.podIdentity.azureWorkload.enabled }} azure.workload.identity/use: "true" {{- end }} {{- if .Values.podAnnotations.keda }} annotations: - {{- toYaml .Values.podAnnotations.keda | nindent 8}} + {{- toYaml .Values.podAnnotations.keda | nindent 8 }} + {{- toYaml .Values.additionalAnnotations | nindent 8 }} {{- end }} spec: {{- if .Values.priorityClassName }} diff --git a/keda/templates/14-keda-poddisruptionbudget.yaml b/keda/templates/14-keda-poddisruptionbudget.yaml index a3329fe3..ccbe1777 100644 --- a/keda/templates/14-keda-poddisruptionbudget.yaml +++ b/keda/templates/14-keda-poddisruptionbudget.yaml @@ -4,6 +4,8 @@ kind: PodDisruptionBudget metadata: namespace: {{ .Release.Namespace }} name: {{ .Values.operator.name }} + annotations: + {{- toYaml .Values.additionalAnnotations | nindent 4 }} labels: app.kubernetes.io/name: {{ .Values.serviceAccount.name }} {{- include "keda.labels" . | indent 4 }} diff --git a/keda/templates/15-keda-podmonitor.yaml b/keda/templates/15-keda-podmonitor.yaml index d2c4c1a1..30986ae6 100644 --- a/keda/templates/15-keda-podmonitor.yaml +++ b/keda/templates/15-keda-podmonitor.yaml @@ -3,6 +3,8 @@ apiVersion: monitoring.coreos.com/v1 kind: PodMonitor metadata: name: {{ .Values.operator.name }} + annotations: + {{- toYaml .Values.additionalAnnotations | nindent 4 }} labels: app.kubernetes.io/name: {{ .Values.operator.name }} {{- include "keda.labels" . | indent 4 }} diff --git a/keda/templates/16-keda-prometheusrules.yaml b/keda/templates/16-keda-prometheusrules.yaml index 4e65c121..880b91dd 100644 --- a/keda/templates/16-keda-prometheusrules.yaml +++ b/keda/templates/16-keda-prometheusrules.yaml @@ -3,6 +3,8 @@ apiVersion: monitoring.coreos.com/v1 kind: PrometheusRule metadata: name: {{ .Values.operator.name }} + annotations: + {{- toYaml .Values.additionalAnnotations | nindent 4 }} labels: app.kubernetes.io/name: {{ .Values.operator.name }} {{- include "keda.labels" . | indent 4 }} diff --git a/keda/templates/20-metrics-clusterrole.yaml b/keda/templates/20-metrics-clusterrole.yaml index 6dc8b705..3063fe18 100644 --- a/keda/templates/20-metrics-clusterrole.yaml +++ b/keda/templates/20-metrics-clusterrole.yaml @@ -2,6 +2,8 @@ apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRole metadata: + annotations: + {{- toYaml .Values.additionalAnnotations | nindent 4 }} labels: app.kubernetes.io/name: {{ .Values.operator.name }}-external-metrics-reader {{- include "keda.labels" . | indent 4 }} @@ -14,4 +16,4 @@ rules: - '*' verbs: - '*' -{{- end -}} \ No newline at end of file +{{- end -}} diff --git a/keda/templates/21-metrics-clusterrolebinding.yaml b/keda/templates/21-metrics-clusterrolebinding.yaml index f670c247..d7292e3a 100644 --- a/keda/templates/21-metrics-clusterrolebinding.yaml +++ b/keda/templates/21-metrics-clusterrolebinding.yaml @@ -2,6 +2,8 @@ apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRoleBinding metadata: + annotations: + {{- toYaml .Values.additionalAnnotations | nindent 4 }} labels: app.kubernetes.io/name: {{ .Values.operator.name }}-system-auth-delegator {{- include "keda.labels" . | indent 4 }} @@ -18,6 +20,8 @@ subjects: apiVersion: rbac.authorization.k8s.io/v1 kind: RoleBinding metadata: + annotations: + {{- toYaml .Values.additionalAnnotations | nindent 4 }} labels: app.kubernetes.io/name: {{ .Values.operator.name }}-auth-reader {{- include "keda.labels" . | indent 4 }} @@ -35,6 +39,8 @@ subjects: apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRoleBinding metadata: + annotations: + {{- toYaml .Values.additionalAnnotations | nindent 4 }} labels: app.kubernetes.io/name: {{ .Values.operator.name }}-hpa-controller-external-metrics {{- include "keda.labels" . | indent 4 }} diff --git a/keda/templates/22-metrics-deployment.yaml b/keda/templates/22-metrics-deployment.yaml index 91efca5d..a26c99f6 100644 --- a/keda/templates/22-metrics-deployment.yaml +++ b/keda/templates/22-metrics-deployment.yaml @@ -3,6 +3,8 @@ kind: Deployment metadata: name: {{ .Values.operator.name }}-metrics-apiserver namespace: {{ .Release.Namespace }} + annotations: + {{- toYaml .Values.additionalAnnotations | nindent 4 }} labels: app: {{ .Values.operator.name }}-metrics-apiserver app.kubernetes.io/name: {{ .Values.operator.name }}-metrics-apiserver @@ -32,6 +34,7 @@ spec: azure.workload.identity/use: "true" {{- end }} annotations: + {{- toYaml .Values.additionalAnnotations | nindent 8 }} {{- if and .Values.prometheus.metricServer.enabled ( not .Values.prometheus.metricServer.podMonitor.enabled ) }} prometheus.io/scrape: "true" prometheus.io/port: {{ .Values.prometheus.metricServer.port | quote }} diff --git a/keda/templates/23-metrics-service.yaml b/keda/templates/23-metrics-service.yaml index 6162a856..c2b3130b 100644 --- a/keda/templates/23-metrics-service.yaml +++ b/keda/templates/23-metrics-service.yaml @@ -7,6 +7,7 @@ metadata: name: {{ .Values.operator.name }}-metrics-apiserver namespace: {{ .Release.Namespace }} annotations: + {{- toYaml .Values.additionalAnnotations | nindent 4 }} {{- range $key, $value := .Values.service.annotations }} {{ $key }}: {{ $value | quote }} {{- end }} diff --git a/keda/templates/24-metrics-apiservice.yaml b/keda/templates/24-metrics-apiservice.yaml index c1af96a5..362f4ffd 100644 --- a/keda/templates/24-metrics-apiservice.yaml +++ b/keda/templates/24-metrics-apiservice.yaml @@ -1,6 +1,8 @@ apiVersion: apiregistration.k8s.io/v1 kind: APIService metadata: + annotations: + {{- toYaml .Values.additionalAnnotations | nindent 4 }} labels: app.kubernetes.io/name: v1beta1.external.metrics.k8s.io {{- include "keda.labels" . | indent 4 }} diff --git a/keda/templates/25-metrics-poddisruptionbudget.yaml b/keda/templates/25-metrics-poddisruptionbudget.yaml index fc078d22..97f12ba4 100644 --- a/keda/templates/25-metrics-poddisruptionbudget.yaml +++ b/keda/templates/25-metrics-poddisruptionbudget.yaml @@ -4,6 +4,8 @@ kind: PodDisruptionBudget metadata: namespace: {{ .Release.Namespace }} name: {{ .Values.operator.name }}-metrics-apiserver + annotations: + {{- toYaml .Values.additionalAnnotations | nindent 4 }} labels: app.kubernetes.io/name: {{ .Values.operator.name }}-metrics-apiserver {{- include "keda.labels" . | indent 4 }} diff --git a/keda/templates/26-metrics-podmonitor.yaml b/keda/templates/26-metrics-podmonitor.yaml index fc158c91..bfcbfb06 100644 --- a/keda/templates/26-metrics-podmonitor.yaml +++ b/keda/templates/26-metrics-podmonitor.yaml @@ -3,6 +3,8 @@ apiVersion: monitoring.coreos.com/v1 kind: PodMonitor metadata: name: {{ .Values.operator.name }}-metrics-apiserver + annotations: + {{- toYaml .Values.additionalAnnotations | nindent 4 }} labels: app.kubernetes.io/name: {{ .Values.operator.name }} {{- include "keda.labels" . | indent 4 }} diff --git a/keda/values.yaml b/keda/values.yaml index 5bc9ea2d..aadb0749 100644 --- a/keda/values.yaml +++ b/keda/values.yaml @@ -77,6 +77,11 @@ additionalLabels: {} # foo: bar +# -- Custom annotations to add into metadata +additionalAnnotations: + {} + # foo: bar + podAnnotations: keda: {} metricsAdapter: {}