From 599dcca744412e85adf1ca6b97e23a411301d683 Mon Sep 17 00:00:00 2001 From: Matthias Teich Date: Fri, 4 Feb 2022 10:10:13 +0100 Subject: [PATCH] Add optional annotations to coredns deployment Signed-off-by: Matthias Teich --- charts/coredns/README.md | 2 ++ charts/coredns/templates/clusterrole-autoscaler.yaml | 4 ++++ .../coredns/templates/clusterrolebinding-autoscaler.yaml | 4 ++++ charts/coredns/templates/configmap-autoscaler.yaml | 7 ++++--- charts/coredns/templates/configmap.yaml | 4 ++++ charts/coredns/templates/deployment-autoscaler.yaml | 4 ++++ charts/coredns/templates/deployment.yaml | 5 +++++ charts/coredns/templates/hpa.yaml | 4 ++++ charts/coredns/templates/poddisruptionbudget.yaml | 4 ++++ charts/coredns/templates/service-metrics.yaml | 4 ++++ charts/coredns/templates/service.yaml | 3 +++ charts/coredns/templates/serviceaccount-autoscaler.yaml | 4 ++++ charts/coredns/templates/serviceaccount.yaml | 7 ++++--- charts/coredns/templates/servicemonitor.yaml | 4 ++++ charts/coredns/values.yaml | 5 +++++ 15 files changed, 59 insertions(+), 6 deletions(-) diff --git a/charts/coredns/README.md b/charts/coredns/README.md index 81e1e72..7a6524a 100644 --- a/charts/coredns/README.md +++ b/charts/coredns/README.md @@ -96,6 +96,7 @@ The command removes all the Kubernetes components associated with the chart and | `extraVolumeMounts` | Optional array of volumes to mount inside the CoreDNS container | [] | | `extraSecrets` | Optional array of secrets to mount inside the CoreDNS container | [] | | `customLabels` | Optional labels for Deployment(s), Pod, Service, ServiceMonitor objects | {} | +| `customAnnotations` | Optional annotations for Deployment(s), Pod, Service, ServiceMonitor objects | `rollingUpdate.maxUnavailable` | Maximum number of unavailable replicas during rolling update | `1` | | `rollingUpdate.maxSurge` | Maximum number of pods created above desired number of pods | `25%` | | `podDisruptionBudget` | Optional PodDisruptionBudget | {} | @@ -135,6 +136,7 @@ The command removes all the Kubernetes components associated with the chart and | `autoscaler.livenessProbe.successThreshold` | Minimum consecutive successes for the probe to be considered successful after having failed. | `1` | | `deployment.enabled` | Optionally disable the main deployment and its respective resources. | `true` | | `deployment.name` | Name of the deployment if `deployment.enabled` is true. Otherwise the name of an existing deployment for the autoscaler or HPA to target. | `""` | +| `deployment.annotations` | Annotations to add to the main deployment | `{}` | See `values.yaml` for configuration notes. Specify each parameter using the `--set key=value[,key=value]` argument to `helm install`. For example, diff --git a/charts/coredns/templates/clusterrole-autoscaler.yaml b/charts/coredns/templates/clusterrole-autoscaler.yaml index 748c62b..1d738fa 100644 --- a/charts/coredns/templates/clusterrole-autoscaler.yaml +++ b/charts/coredns/templates/clusterrole-autoscaler.yaml @@ -17,6 +17,10 @@ metadata: {{- if .Values.customLabels }} {{ toYaml .Values.customLabels | indent 4 }} {{- end }} +{{- with .Values.customAnnotations }} + annotations: +{{- toYaml . | nindent 4 }} +{{- end }} rules: - apiGroups: [""] resources: ["nodes"] diff --git a/charts/coredns/templates/clusterrolebinding-autoscaler.yaml b/charts/coredns/templates/clusterrolebinding-autoscaler.yaml index eafb38f..82a91d0 100644 --- a/charts/coredns/templates/clusterrolebinding-autoscaler.yaml +++ b/charts/coredns/templates/clusterrolebinding-autoscaler.yaml @@ -17,6 +17,10 @@ metadata: {{- if .Values.customLabels }} {{ toYaml .Values.customLabels | indent 4 }} {{- end }} +{{- with .Values.customAnnotations }} + annotations: +{{- toYaml . | nindent 4 }} +{{- end }} roleRef: apiGroup: rbac.authorization.k8s.io kind: ClusterRole diff --git a/charts/coredns/templates/configmap-autoscaler.yaml b/charts/coredns/templates/configmap-autoscaler.yaml index 12210c2..ef67d7b 100644 --- a/charts/coredns/templates/configmap-autoscaler.yaml +++ b/charts/coredns/templates/configmap-autoscaler.yaml @@ -18,10 +18,11 @@ metadata: {{- if .Values.customLabels }} {{- toYaml .Values.customLabels | nindent 4 }} {{- end }} - {{- if .Values.autoscaler.configmap.annotations }} +{{ if or .Values.autoscaler.configmap.annotations .Values.customAnnotations }} annotations: - {{- toYaml .Values.autoscaler.configmap.annotations | nindent 4 }} - {{- end }} +{{ toYaml .Values.customAnnotations | indent 4 }} +{{- toYaml .Values.autoscaler.configmap.annotations | nindent 4 }} +{{- end }} data: # When cluster is using large nodes(with more cores), "coresPerReplica" should dominate. # If using small nodes, "nodesPerReplica" should dominate. diff --git a/charts/coredns/templates/configmap.yaml b/charts/coredns/templates/configmap.yaml index 64bfe4f..a1d8668 100644 --- a/charts/coredns/templates/configmap.yaml +++ b/charts/coredns/templates/configmap.yaml @@ -17,6 +17,10 @@ metadata: {{- if .Values.customLabels }} {{ toYaml .Values.customLabels | indent 4 }} {{- end }} +{{- with .Values.customAnnotations }} + annotations: +{{- toYaml . | nindent 4 }} +{{- end }} data: Corefile: |- {{- range $name, $conf := .Values.extraConfig }} diff --git a/charts/coredns/templates/deployment-autoscaler.yaml b/charts/coredns/templates/deployment-autoscaler.yaml index 79450f1..31bcc96 100644 --- a/charts/coredns/templates/deployment-autoscaler.yaml +++ b/charts/coredns/templates/deployment-autoscaler.yaml @@ -18,6 +18,10 @@ metadata: {{- if .Values.customLabels }} {{ toYaml .Values.customLabels | indent 4 }} {{- end }} +{{- with .Values.customAnnotations }} + annotations: +{{- toYaml . | nindent 4 }} +{{- end }} spec: selector: matchLabels: diff --git a/charts/coredns/templates/deployment.yaml b/charts/coredns/templates/deployment.yaml index 7ac0bbc..13b9bdc 100644 --- a/charts/coredns/templates/deployment.yaml +++ b/charts/coredns/templates/deployment.yaml @@ -18,6 +18,11 @@ metadata: {{- if .Values.customLabels }} {{ toYaml .Values.customLabels | indent 4 }} {{- end }} +{{ if or .Values.deployment.annotations .Values.customAnnotations }} + annotations: +{{ toYaml .Values.customAnnotations | indent 4 }} +{{ toYaml .Values.deployment.annotations | indent 4 }} +{{- end }} spec: {{- if not .Values.autoscaler.enabled }} replicas: {{ .Values.replicaCount }} diff --git a/charts/coredns/templates/hpa.yaml b/charts/coredns/templates/hpa.yaml index 068b9fb..79fc4cc 100644 --- a/charts/coredns/templates/hpa.yaml +++ b/charts/coredns/templates/hpa.yaml @@ -17,6 +17,10 @@ metadata: {{- if .Values.customLabels }} {{ toYaml .Values.customLabels | indent 4 }} {{- end }} +{{- with .Values.customAnnotations }} + annotations: +{{- toYaml . | nindent 4 }} +{{- end }} spec: scaleTargetRef: apiVersion: apps/v1 diff --git a/charts/coredns/templates/poddisruptionbudget.yaml b/charts/coredns/templates/poddisruptionbudget.yaml index 7754896..c2f0515 100644 --- a/charts/coredns/templates/poddisruptionbudget.yaml +++ b/charts/coredns/templates/poddisruptionbudget.yaml @@ -16,6 +16,10 @@ metadata: {{- if .Values.customLabels }} {{ toYaml .Values.customLabels | indent 4 }} {{- end }} +{{- with .Values.customAnnotations }} + annotations: +{{- toYaml . | nindent 4 }} +{{- end }} spec: selector: matchLabels: diff --git a/charts/coredns/templates/service-metrics.yaml b/charts/coredns/templates/service-metrics.yaml index b91922d..712a718 100644 --- a/charts/coredns/templates/service-metrics.yaml +++ b/charts/coredns/templates/service-metrics.yaml @@ -19,6 +19,10 @@ metadata: {{- end }} annotations: {{ toYaml .Values.prometheus.service.annotations | indent 4 }} +{{ toYaml .Values.service.annotations | indent 4 }} +{{- if .Values.customAnnotations }} +{{ toYaml .Values.customAnnotations | indent 4 }} +{{- end }} spec: selector: app.kubernetes.io/instance: {{ .Release.Name | quote }} diff --git a/charts/coredns/templates/service.yaml b/charts/coredns/templates/service.yaml index 58d2b15..5749e4b 100644 --- a/charts/coredns/templates/service.yaml +++ b/charts/coredns/templates/service.yaml @@ -19,6 +19,9 @@ metadata: {{- end }} annotations: {{ toYaml .Values.service.annotations | indent 4 }} +{{- if .Values.customAnnotations }} +{{ toYaml .Values.customAnnotations | indent 4 }} +{{- end }} spec: selector: app.kubernetes.io/instance: {{ .Release.Name | quote }} diff --git a/charts/coredns/templates/serviceaccount-autoscaler.yaml b/charts/coredns/templates/serviceaccount-autoscaler.yaml index 64f74fa..b0479e9 100644 --- a/charts/coredns/templates/serviceaccount-autoscaler.yaml +++ b/charts/coredns/templates/serviceaccount-autoscaler.yaml @@ -18,6 +18,10 @@ metadata: {{- if .Values.customLabels }} {{ toYaml .Values.customLabels | indent 4 }} {{- end }} +{{- with .Values.customAnnotations }} + annotations: +{{- toYaml . | nindent 4 }} +{{- end }} {{- if .Values.autoscaler.image.pullSecrets }} imagePullSecrets: {{- range .Values.autoscaler.image.pullSecrets }} diff --git a/charts/coredns/templates/serviceaccount.yaml b/charts/coredns/templates/serviceaccount.yaml index 0b1a1b0..c270b06 100644 --- a/charts/coredns/templates/serviceaccount.yaml +++ b/charts/coredns/templates/serviceaccount.yaml @@ -13,10 +13,11 @@ metadata: kubernetes.io/name: "CoreDNS" {{- end }} app.kubernetes.io/name: {{ template "coredns.name" . }} - {{- with .Values.serviceAccount.annotations }} +{{ if or .Values.serviceAccount.annotations .Values.customAnnotations }} annotations: - {{- toYaml . | nindent 4 }} - {{- end }} +{{ toYaml .Values.customAnnotations | indent 4 }} +{{ toYaml .Values.serviceAccount.annotations | indent 4 }} +{{- end }} {{- if .Values.image.pullSecrets }} imagePullSecrets: {{- range .Values.image.pullSecrets }} diff --git a/charts/coredns/templates/servicemonitor.yaml b/charts/coredns/templates/servicemonitor.yaml index ad1f84f..9e6f143 100644 --- a/charts/coredns/templates/servicemonitor.yaml +++ b/charts/coredns/templates/servicemonitor.yaml @@ -19,6 +19,10 @@ metadata: {{- if .Values.prometheus.monitor.additionalLabels }} {{ toYaml .Values.prometheus.monitor.additionalLabels | indent 4 }} {{- end }} +{{- with .Values.customAnnotations }} + annotations: +{{- toYaml . | nindent 4 }} +{{- end }} spec: selector: matchLabels: diff --git a/charts/coredns/values.yaml b/charts/coredns/values.yaml index 76ce4be..17bd168 100644 --- a/charts/coredns/values.yaml +++ b/charts/coredns/values.yaml @@ -231,6 +231,9 @@ extraSecrets: [] # Custom labels to apply to Deployment, Pod, Configmap, Service, ServiceMonitor. Including autoscaler if enabled. customLabels: {} +# Custom annotations to apply to Deployment, Pod, Configmap, Service, ServiceMonitor. Including autoscaler if enabled. +customAnnotations: {} + ## Alternative configuration for HPA deployment if wanted # hpa: @@ -314,3 +317,5 @@ autoscaler: deployment: enabled: true name: "" + ## Annotations for the coredns deployment + annotations: {} \ No newline at end of file