Skip to content

Commit 42bd58d

Browse files
authored
Merge pull request #168 from alex-berger/feature/eks-compatibility
Allow overriding selectors and names
2 parents 6c10624 + 0185693 commit 42bd58d

11 files changed

+47
-5
lines changed

charts/coredns/Chart.yaml

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
apiVersion: v2
22
name: coredns
3-
version: 1.30.0
3+
version: 1.31.0
44
appVersion: 1.11.1
55
home: https://coredns.io
66
icon: https://coredns.io/images/CoreDNS_Colour_Horizontal.png
@@ -20,4 +20,6 @@ type: application
2020
annotations:
2121
artifacthub.io/changes: |
2222
- kind: added
23-
description: Ability to skip configmap management
23+
description: Allow overriding the selectors for Deployment, Services, PodDisruptionBudget and ServiceMonitor
24+
- kind: added
25+
description: Setting `clusterRole.nameOverride` to allow overriding the ClusterRole name.

charts/coredns/README.md

+5
Original file line numberDiff line numberDiff line change
@@ -60,17 +60,20 @@ The command removes all the Kubernetes components associated with the chart and
6060
| `serviceType` | Kubernetes Service type | `ClusterIP` |
6161
| `prometheus.service.enabled` | Set this to `true` to create Service for Prometheus metrics | `false` |
6262
| `prometheus.service.annotations` | Annotations to add to the metrics Service | `{prometheus.io/scrape: "true", prometheus.io/port: "9153"}` |
63+
| `prometheus.service.selector` | Pod selector | `{}` |
6364
| `prometheus.monitor.enabled` | Set this to `true` to create ServiceMonitor for Prometheus operator | `false` |
6465
| `prometheus.monitor.additionalLabels` | Additional labels that can be used so ServiceMonitor will be discovered by Prometheus | {} |
6566
| `prometheus.monitor.namespace` | Selector to select which namespaces the Endpoints objects are discovered from. | `""` |
6667
| `prometheus.monitor.interval` | Scrape interval for polling the metrics endpoint. (E.g. "30s") | `""` |
68+
| `prometheus.monitor.selector` | Service selector | `{}` |
6769
| `service.clusterIP` | IP address to assign to service | `""` |
6870
| `service.clusterIPs` | IP addresses to assign to service | `[]` |
6971
| `service.loadBalancerIP` | IP address to assign to load balancer (if supported) | `""` |
7072
| `service.externalIPs` | External IP addresses | [] |
7173
| `service.externalTrafficPolicy` | Enable client source IP preservation | [] |
7274
| `service.ipFamilyPolicy` | Service dual-stack policy | `""` |
7375
| `service.annotations` | Annotations to add to service | {} |
76+
| `service.selector` | Pod selector | `{}` |
7477
| `serviceAccount.create` | If true, create & use serviceAccount | false |
7578
| `serviceAccount.name` | If not set & create is true, use template fullname | |
7679
| `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
141144
| `deployment.enabled` | Optionally disable the main deployment and its respective resources. | `true` |
142145
| `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. | `""` |
143146
| `deployment.annotations` | Annotations to add to the main deployment | `{}` |
147+
| `deployment.selector` | Pod selector | `{}` |
148+
| `clusterRole.nameOverride` | ClusterRole name override | |
144149

145150
See `values.yaml` for configuration notes. Specify each parameter using the `--set key=value[,key=value]` argument to `helm install`. For example,
146151

charts/coredns/templates/_helpers.tpl

+11
Original file line numberDiff line numberDiff line change
@@ -224,3 +224,14 @@ Create the name of the service account to use
224224
{{ default "default" .Values.serviceAccount.name }}
225225
{{- end -}}
226226
{{- end -}}
227+
228+
{{/*
229+
Create the name of the service account to use
230+
*/}}
231+
{{- define "coredns.clusterRoleName" -}}
232+
{{- if and .Values.clusterRole .Values.clusterRole.nameOverride -}}
233+
{{ .Values.clusterRole.nameOverride }}
234+
{{- else -}}
235+
{{ template "coredns.fullname" . }}
236+
{{- end -}}
237+
{{- end -}}

charts/coredns/templates/clusterrole.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
apiVersion: rbac.authorization.k8s.io/v1
33
kind: ClusterRole
44
metadata:
5-
name: {{ template "coredns.fullname" . }}
5+
name: {{ template "coredns.clusterRoleName" . }}
66
labels: {{- include "coredns.labels" . | nindent 4 }}
77
rules:
88
- apiGroups:

charts/coredns/templates/clusterrolebinding.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22
apiVersion: rbac.authorization.k8s.io/v1
33
kind: ClusterRoleBinding
44
metadata:
5-
name: {{ template "coredns.fullname" . }}
5+
name: {{ template "coredns.clusterRoleName" . }}
66
labels: {{- include "coredns.labels" . | nindent 4 }}
77
roleRef:
88
apiGroup: rbac.authorization.k8s.io
99
kind: ClusterRole
10-
name: {{ template "coredns.fullname" . }}
10+
name: {{ template "coredns.clusterRoleName" . }}
1111
subjects:
1212
- kind: ServiceAccount
1313
name: {{ template "coredns.serviceAccountName" . }}

charts/coredns/templates/deployment.yaml

+4
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,16 @@ spec:
2929
maxUnavailable: {{ .Values.rollingUpdate.maxUnavailable }}
3030
maxSurge: {{ .Values.rollingUpdate.maxSurge }}
3131
selector:
32+
{{- if .Values.deployment.selector }}
33+
{{- toYaml .Values.deployment.selector | nindent 4 }}
34+
{{- else }}
3235
matchLabels:
3336
app.kubernetes.io/instance: {{ .Release.Name | quote }}
3437
{{- if .Values.isClusterService }}
3538
k8s-app: {{ template "coredns.k8sapplabel" . }}
3639
{{- end }}
3740
app.kubernetes.io/name: {{ template "coredns.name" . }}
41+
{{- end }}
3842
template:
3943
metadata:
4044
labels:

charts/coredns/templates/poddisruptionbudget.yaml

+2
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,14 @@ metadata:
1313
{{- toYaml . | nindent 4 }}
1414
{{- end }}
1515
spec:
16+
{{- if not .Values.podDisruptionBudget.selector }}
1617
selector:
1718
matchLabels:
1819
app.kubernetes.io/instance: {{ .Release.Name | quote }}
1920
{{- if .Values.isClusterService }}
2021
k8s-app: {{ template "coredns.k8sapplabel" . }}
2122
{{- end }}
2223
app.kubernetes.io/name: {{ template "coredns.name" . }}
24+
{{- end }}
2325
{{ toYaml .Values.podDisruptionBudget | indent 2 }}
2426
{{- end }}

charts/coredns/templates/service-metrics.yaml

+4
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,15 @@ metadata:
2323
{{- end }}
2424
spec:
2525
selector:
26+
{{- if .Values.prometheus.service.selector }}
27+
{{- toYaml .Values.prometheus.service.selector | nindent 4 }}
28+
{{- else }}
2629
app.kubernetes.io/instance: {{ .Release.Name | quote }}
2730
{{- if .Values.isClusterService }}
2831
k8s-app: {{ template "coredns.k8sapplabel" . }}
2932
{{- end }}
3033
app.kubernetes.io/name: {{ template "coredns.name" . }}
34+
{{- end }}
3135
ports:
3236
- name: metrics
3337
port: 9153

charts/coredns/templates/service.yaml

+4
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,15 @@ metadata:
2020
{{- end }}
2121
spec:
2222
selector:
23+
{{- if .Values.service.selector }}
24+
{{- toYaml .Values.service.selector | nindent 4 }}
25+
{{- else }}
2326
app.kubernetes.io/instance: {{ .Release.Name | quote }}
2427
{{- if .Values.isClusterService }}
2528
k8s-app: {{ template "coredns.k8sapplabel" . }}
2629
{{- end }}
2730
app.kubernetes.io/name: {{ template "coredns.name" . }}
31+
{{- end }}
2832
{{- if .Values.service.clusterIP }}
2933
clusterIP: {{ .Values.service.clusterIP }}
3034
{{- end }}

charts/coredns/templates/servicemonitor.yaml

+4
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,17 @@ spec:
2121
- {{ .Release.Namespace }}
2222
{{- end }}
2323
selector:
24+
{{- if .Values.prometheus.monitor.selector }}
25+
{{- toYaml .Values.prometheus.monitor.selector | nindent 4 }}
26+
{{- else }}
2427
matchLabels:
2528
app.kubernetes.io/instance: {{ .Release.Name | quote }}
2629
{{- if .Values.isClusterService }}
2730
k8s-app: {{ template "coredns.k8sapplabel" . }}
2831
{{- end }}
2932
app.kubernetes.io/name: {{ template "coredns.name" . }}
3033
app.kubernetes.io/component: metrics
34+
{{- end }}
3135
endpoints:
3236
- port: metrics
3337
{{- if .Values.prometheus.monitor.interval }}

charts/coredns/values.yaml

+6
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,13 @@ prometheus:
4242
annotations:
4343
prometheus.io/scrape: "true"
4444
prometheus.io/port: "9153"
45+
selector: {}
4546
monitor:
4647
enabled: false
4748
additionalLabels: {}
4849
namespace: ""
4950
interval: ""
51+
selector: {}
5052

5153
service:
5254
# clusterIP: ""
@@ -59,6 +61,8 @@ service:
5961
# If not set, a name is generated using the fullname template
6062
name: ""
6163
annotations: {}
64+
# Pod selector
65+
selector: {}
6266

6367
serviceAccount:
6468
create: false
@@ -377,3 +381,5 @@ deployment:
377381
name: ""
378382
## Annotations for the coredns deployment
379383
annotations: {}
384+
## Pod selector
385+
selector: {}

0 commit comments

Comments
 (0)