diff --git a/charts/coredns/Chart.yaml b/charts/coredns/Chart.yaml index be84a05..20d34aa 100644 --- a/charts/coredns/Chart.yaml +++ b/charts/coredns/Chart.yaml @@ -1,6 +1,6 @@ apiVersion: v2 name: coredns -version: 1.30.0 +version: 1.31.0 appVersion: 1.11.1 home: https://coredns.io icon: https://coredns.io/images/CoreDNS_Colour_Horizontal.png @@ -20,4 +20,6 @@ type: application annotations: artifacthub.io/changes: | - kind: added - description: Ability to skip configmap management + description: Allow overriding the selectors for Deployment, Services, PodDisruptionBudget and ServiceMonitor + - kind: added + description: Setting `clusterRole.nameOverride` to allow overriding the ClusterRole name. diff --git a/charts/coredns/README.md b/charts/coredns/README.md index b98c4a2..43e15fe 100644 --- a/charts/coredns/README.md +++ b/charts/coredns/README.md @@ -60,10 +60,12 @@ The command removes all the Kubernetes components associated with the chart and | `serviceType` | Kubernetes Service type | `ClusterIP` | | `prometheus.service.enabled` | Set this to `true` to create Service for Prometheus metrics | `false` | | `prometheus.service.annotations` | Annotations to add to the metrics Service | `{prometheus.io/scrape: "true", prometheus.io/port: "9153"}` | +| `prometheus.service.selector` | Pod selector | `{}` | | `prometheus.monitor.enabled` | Set this to `true` to create ServiceMonitor for Prometheus operator | `false` | | `prometheus.monitor.additionalLabels` | Additional labels that can be used so ServiceMonitor will be discovered by Prometheus | {} | | `prometheus.monitor.namespace` | Selector to select which namespaces the Endpoints objects are discovered from. | `""` | | `prometheus.monitor.interval` | Scrape interval for polling the metrics endpoint. (E.g. "30s") | `""` | +| `prometheus.monitor.selector` | Service selector | `{}` | | `service.clusterIP` | IP address to assign to service | `""` | | `service.clusterIPs` | IP addresses to assign to service | `[]` | | `service.loadBalancerIP` | IP address to assign to load balancer (if supported) | `""` | @@ -71,6 +73,7 @@ The command removes all the Kubernetes components associated with the chart and | `service.externalTrafficPolicy` | Enable client source IP preservation | [] | | `service.ipFamilyPolicy` | Service dual-stack policy | `""` | | `service.annotations` | Annotations to add to service | {} | +| `service.selector` | Pod selector | `{}` | | `serviceAccount.create` | If true, create & use serviceAccount | false | | `serviceAccount.name` | If not set & create is true, use template fullname | | | `rbac.create` | If true, create & use RBAC resources | true | @@ -141,6 +144,8 @@ The command removes all the Kubernetes components associated with the chart and | `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 | `{}` | +| `deployment.selector` | Pod selector | `{}` | +| `clusterRole.nameOverride` | ClusterRole name override | | 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/_helpers.tpl b/charts/coredns/templates/_helpers.tpl index 6dc6833..e6f7491 100644 --- a/charts/coredns/templates/_helpers.tpl +++ b/charts/coredns/templates/_helpers.tpl @@ -224,3 +224,14 @@ Create the name of the service account to use {{ default "default" .Values.serviceAccount.name }} {{- end -}} {{- end -}} + +{{/* +Create the name of the service account to use +*/}} +{{- define "coredns.clusterRoleName" -}} +{{- if and .Values.clusterRole .Values.clusterRole.nameOverride -}} + {{ .Values.clusterRole.nameOverride }} +{{- else -}} + {{ template "coredns.fullname" . }} +{{- end -}} +{{- end -}} \ No newline at end of file diff --git a/charts/coredns/templates/clusterrole.yaml b/charts/coredns/templates/clusterrole.yaml index c33762c..ecdeafa 100644 --- a/charts/coredns/templates/clusterrole.yaml +++ b/charts/coredns/templates/clusterrole.yaml @@ -2,7 +2,7 @@ apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRole metadata: - name: {{ template "coredns.fullname" . }} + name: {{ template "coredns.clusterRoleName" . }} labels: {{- include "coredns.labels" . | nindent 4 }} rules: - apiGroups: diff --git a/charts/coredns/templates/clusterrolebinding.yaml b/charts/coredns/templates/clusterrolebinding.yaml index 36fa21c..ebeaf14 100644 --- a/charts/coredns/templates/clusterrolebinding.yaml +++ b/charts/coredns/templates/clusterrolebinding.yaml @@ -2,12 +2,12 @@ apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRoleBinding metadata: - name: {{ template "coredns.fullname" . }} + name: {{ template "coredns.clusterRoleName" . }} labels: {{- include "coredns.labels" . | nindent 4 }} roleRef: apiGroup: rbac.authorization.k8s.io kind: ClusterRole - name: {{ template "coredns.fullname" . }} + name: {{ template "coredns.clusterRoleName" . }} subjects: - kind: ServiceAccount name: {{ template "coredns.serviceAccountName" . }} diff --git a/charts/coredns/templates/deployment.yaml b/charts/coredns/templates/deployment.yaml index 1b3f86f..86db59f 100644 --- a/charts/coredns/templates/deployment.yaml +++ b/charts/coredns/templates/deployment.yaml @@ -29,12 +29,16 @@ spec: maxUnavailable: {{ .Values.rollingUpdate.maxUnavailable }} maxSurge: {{ .Values.rollingUpdate.maxSurge }} selector: + {{- if .Values.deployment.selector }} + {{- toYaml .Values.deployment.selector | nindent 4 }} + {{- else }} matchLabels: app.kubernetes.io/instance: {{ .Release.Name | quote }} {{- if .Values.isClusterService }} k8s-app: {{ template "coredns.k8sapplabel" . }} {{- end }} app.kubernetes.io/name: {{ template "coredns.name" . }} + {{- end }} template: metadata: labels: diff --git a/charts/coredns/templates/poddisruptionbudget.yaml b/charts/coredns/templates/poddisruptionbudget.yaml index 9cc62c1..136d804 100644 --- a/charts/coredns/templates/poddisruptionbudget.yaml +++ b/charts/coredns/templates/poddisruptionbudget.yaml @@ -13,6 +13,7 @@ metadata: {{- toYaml . | nindent 4 }} {{- end }} spec: + {{- if not .Values.podDisruptionBudget.selector }} selector: matchLabels: app.kubernetes.io/instance: {{ .Release.Name | quote }} @@ -20,5 +21,6 @@ spec: k8s-app: {{ template "coredns.k8sapplabel" . }} {{- end }} app.kubernetes.io/name: {{ template "coredns.name" . }} + {{- end }} {{ toYaml .Values.podDisruptionBudget | indent 2 }} {{- end }} diff --git a/charts/coredns/templates/service-metrics.yaml b/charts/coredns/templates/service-metrics.yaml index 1fc7b2d..0ae9a15 100644 --- a/charts/coredns/templates/service-metrics.yaml +++ b/charts/coredns/templates/service-metrics.yaml @@ -23,11 +23,15 @@ metadata: {{- end }} spec: selector: + {{- if .Values.prometheus.service.selector }} + {{- toYaml .Values.prometheus.service.selector | nindent 4 }} + {{- else }} app.kubernetes.io/instance: {{ .Release.Name | quote }} {{- if .Values.isClusterService }} k8s-app: {{ template "coredns.k8sapplabel" . }} {{- end }} app.kubernetes.io/name: {{ template "coredns.name" . }} + {{- end }} ports: - name: metrics port: 9153 diff --git a/charts/coredns/templates/service.yaml b/charts/coredns/templates/service.yaml index e9c5b96..95babce 100644 --- a/charts/coredns/templates/service.yaml +++ b/charts/coredns/templates/service.yaml @@ -20,11 +20,15 @@ metadata: {{- end }} spec: selector: + {{- if .Values.service.selector }} + {{- toYaml .Values.service.selector | nindent 4 }} + {{- else }} app.kubernetes.io/instance: {{ .Release.Name | quote }} {{- if .Values.isClusterService }} k8s-app: {{ template "coredns.k8sapplabel" . }} {{- end }} app.kubernetes.io/name: {{ template "coredns.name" . }} + {{- end }} {{- if .Values.service.clusterIP }} clusterIP: {{ .Values.service.clusterIP }} {{- end }} diff --git a/charts/coredns/templates/servicemonitor.yaml b/charts/coredns/templates/servicemonitor.yaml index b5fc642..53f8bdb 100644 --- a/charts/coredns/templates/servicemonitor.yaml +++ b/charts/coredns/templates/servicemonitor.yaml @@ -21,6 +21,9 @@ spec: - {{ .Release.Namespace }} {{- end }} selector: + {{- if .Values.prometheus.monitor.selector }} + {{- toYaml .Values.prometheus.monitor.selector | nindent 4 }} + {{- else }} matchLabels: app.kubernetes.io/instance: {{ .Release.Name | quote }} {{- if .Values.isClusterService }} @@ -28,6 +31,7 @@ spec: {{- end }} app.kubernetes.io/name: {{ template "coredns.name" . }} app.kubernetes.io/component: metrics + {{- end }} endpoints: - port: metrics {{- if .Values.prometheus.monitor.interval }} diff --git a/charts/coredns/values.yaml b/charts/coredns/values.yaml index aa9ec71..2c472c6 100644 --- a/charts/coredns/values.yaml +++ b/charts/coredns/values.yaml @@ -42,11 +42,13 @@ prometheus: annotations: prometheus.io/scrape: "true" prometheus.io/port: "9153" + selector: {} monitor: enabled: false additionalLabels: {} namespace: "" interval: "" + selector: {} service: # clusterIP: "" @@ -59,6 +61,8 @@ service: # If not set, a name is generated using the fullname template name: "" annotations: {} + # Pod selector + selector: {} serviceAccount: create: false @@ -377,3 +381,5 @@ deployment: name: "" ## Annotations for the coredns deployment annotations: {} + ## Pod selector + selector: {}