Skip to content

Commit

Permalink
Add optional annotations to coredns deployment
Browse files Browse the repository at this point in the history
Signed-off-by: Matthias Teich <[email protected]>
  • Loading branch information
Mattes83 authored and mrueg committed Mar 22, 2022
1 parent fe3928a commit 599dcca
Show file tree
Hide file tree
Showing 15 changed files with 59 additions and 6 deletions.
2 changes: 2 additions & 0 deletions charts/coredns/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 | {} |
Expand Down Expand Up @@ -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,

Expand Down
4 changes: 4 additions & 0 deletions charts/coredns/templates/clusterrole-autoscaler.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand Down
4 changes: 4 additions & 0 deletions charts/coredns/templates/clusterrolebinding-autoscaler.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
7 changes: 4 additions & 3 deletions charts/coredns/templates/configmap-autoscaler.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
4 changes: 4 additions & 0 deletions charts/coredns/templates/configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down
4 changes: 4 additions & 0 deletions charts/coredns/templates/deployment-autoscaler.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
5 changes: 5 additions & 0 deletions charts/coredns/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down
4 changes: 4 additions & 0 deletions charts/coredns/templates/hpa.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions charts/coredns/templates/poddisruptionbudget.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
4 changes: 4 additions & 0 deletions charts/coredns/templates/service-metrics.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down
3 changes: 3 additions & 0 deletions charts/coredns/templates/service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down
4 changes: 4 additions & 0 deletions charts/coredns/templates/serviceaccount-autoscaler.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down
7 changes: 4 additions & 3 deletions charts/coredns/templates/serviceaccount.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down
4 changes: 4 additions & 0 deletions charts/coredns/templates/servicemonitor.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
5 changes: 5 additions & 0 deletions charts/coredns/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -314,3 +317,5 @@ autoscaler:
deployment:
enabled: true
name: ""
## Annotations for the coredns deployment
annotations: {}

0 comments on commit 599dcca

Please sign in to comment.