Skip to content

Commit d0fcb14

Browse files
authored
Merge pull request #34 from eminaktas/helm-chart-imp
feat: helm chart improvements
2 parents 3ae2e39 + 93d44ee commit d0fcb14

12 files changed

+123
-45
lines changed

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,8 @@ spec:
6161
nameservers:
6262
- 10.96.0.10
6363
searches:
64-
- "svc.{{ .clusterDomain }}"
65-
- "{{ .podNamespace }}.svc.{{ .clusterDomain }}"
64+
- "svc.cluster.local"
65+
- "{{ .podNamespace }}.svc.cluster.local"
6666
options:
6767
- name: ndots
6868
value: "2"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
{{- if .Values.dnsclass.enabled }}
2+
apiVersion: batch/v1
3+
kind: Job
4+
metadata:
5+
name: {{ include "chart.fullname" . }}-api-check
6+
namespace: {{ .Release.Namespace }}
7+
annotations:
8+
helm.sh/hook: post-install,post-upgrade
9+
helm.sh/hook-weight: "3"
10+
helm.sh/hook-delete-policy: hook-succeeded
11+
labels:
12+
app.kubernetes.io/component: api-check
13+
app.kubernetes.io/part-of: kubedns-shepherd
14+
{{- include "chart.labels" . | nindent 4 }}
15+
spec:
16+
template:
17+
spec:
18+
containers:
19+
- name: api-check
20+
image: quay.io/curl/curl:latest
21+
command:
22+
- /bin/sh
23+
- -c
24+
- |
25+
# Max retries and sleep interval
26+
MAX_RETRIES={{ .Values.readyCheck.maxRetries }}
27+
SLEEP_INTERVAL={{ .Values.readyCheck.sleepInterval }}
28+
29+
# Check API readiness with a limit on retries
30+
retries=0
31+
until [ "$retries" -ge "$MAX_RETRIES" ] || curl -sf http://{{ include "chart.fullname" . }}-probe-service.{{ .Release.Namespace }}:8081/readyz; do
32+
echo "Waiting for API to be ready... Attempt $((retries+1))/$MAX_RETRIES"
33+
retries=$((retries+1))
34+
sleep $SLEEP_INTERVAL
35+
done
36+
37+
# If API is not ready after max retries, exit with failure
38+
if [ "$retries" -ge "$MAX_RETRIES" ]; then
39+
echo "API did not become ready within the time limit, exiting."
40+
exit 1
41+
fi
42+
43+
echo "API is ready to respond!"
44+
resources:
45+
limits:
46+
cpu: "100m"
47+
memory: "128Mi"
48+
requests:
49+
cpu: "50m"
50+
memory: "64Mi"
51+
restartPolicy: Never
52+
backoffLimit: 4
53+
{{- end }}

chart/kubedns-shepherd/templates/dnsclass-crd.yaml chart/kubedns-shepherd/templates/crds/crd-dnsclass.yaml

+9-9
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,26 @@
1-
{{- if .Values.crds.enabled }}
1+
# START crd {{- if .Values.crds.enabled }}
22
apiVersion: apiextensions.k8s.io/v1
33
kind: CustomResourceDefinition
44
metadata:
55
name: dnsclasses.config.kubedns-shepherd.io
66
annotations:
7-
helm.sh/hook: post-install,post-upgrade
8-
helm.sh/hook-weight: "3"
97
cert-manager.io/inject-ca-from: '{{ .Release.Namespace }}/{{ include "chart.fullname" . }}-serving-cert'
108
controller-gen.kubebuilder.io/version: v0.16.3
11-
{{- if .Values.crds.keep }}
9+
# START keep {{- if .Values.crds.keep }}
1210
helm.sh/resource-policy: keep
13-
{{- end }}
11+
# END keep {{- end }}
1412
labels:
15-
{{- include "chart.labels" . | nindent 4 }}
13+
app.kubernetes.io/component: crd
14+
app.kubernetes.io/part-of: kubedns-shepherd
15+
# Generated labels {{- include "chart.labels" . | nindent 4 }}
1616
spec:
1717
conversion:
1818
strategy: Webhook
1919
webhook:
2020
clientConfig:
2121
service:
22-
name: {{ include "chart.fullname" . }}-webhook-service
23-
namespace: {{ .Release.Namespace }}
22+
name: '{{ include "chart.fullname" . }}-webhook-service'
23+
namespace: '{{ .Release.Namespace }}'
2424
path: /convert
2525
conversionReviewVersions:
2626
- v1
@@ -211,4 +211,4 @@ spec:
211211
storage: true
212212
subresources:
213213
status: {}
214-
{{- end }}
214+
# END crd {{- end }}

chart/kubedns-shepherd/templates/deployment.yaml

+10-10
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,6 @@ kind: Deployment
33
metadata:
44
name: {{ include "chart.fullname" . }}
55
namespace: {{ .Release.Namespace }}
6-
annotations:
7-
helm.sh/hook: post-install,post-upgrade
8-
helm.sh/hook-weight: "4"
96
labels:
107
app.kubernetes.io/component: controller
118
app.kubernetes.io/part-of: kubedns-shepherd
@@ -42,12 +39,6 @@ spec:
4239
{{- end }}
4340
image: {{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}
4441
imagePullPolicy: {{ .Values.imagePullPolicy }}
45-
livenessProbe:
46-
httpGet:
47-
path: /healthz
48-
port: 8081
49-
initialDelaySeconds: 15
50-
periodSeconds: 20
5142
name: controller
5243
ports:
5344
- containerPort: 9443
@@ -56,10 +47,19 @@ spec:
5647
- containerPort: 8080
5748
name: metrics
5849
protocol: TCP
50+
- containerPort: 8081
51+
name: probe
52+
protocol: TCP
53+
livenessProbe:
54+
httpGet:
55+
path: /healthz
56+
port: probe
57+
initialDelaySeconds: 15
58+
periodSeconds: 20
5959
readinessProbe:
6060
httpGet:
6161
path: /readyz
62-
port: 8081
62+
port: probe
6363
initialDelaySeconds: 5
6464
periodSeconds: 10
6565
resources: {{- toYaml .Values.resources | nindent 10 }}

chart/kubedns-shepherd/templates/dnsclass-configuration.yaml

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1+
{{- if .Values.dnsclass.enabled }}
12
apiVersion: config.kubedns-shepherd.io/v1alpha1
23
kind: DNSClass
34
metadata:
45
name: {{ include "chart.fullname" . }}-dnsclass-config
56
annotations:
67
helm.sh/hook: post-install,post-upgrade
7-
helm.sh/hook-weight: "6"
8+
helm.sh/hook-weight: "4"
89
labels:
910
{{- include "chart.labels" . | nindent 4 }}
1011
spec:
@@ -21,4 +22,5 @@ spec:
2122
searches:
2223
{{- toYaml .Values.dnsclass.dnsConfig.searches | nindent 6 }}
2324
options:
24-
{{- toYaml .Values.dnsclass.dnsConfig.options | nindent 6 }}
25+
{{- toYaml .Values.dnsclass.dnsConfig.options | nindent 6 }}
26+
{{- end }}

chart/kubedns-shepherd/templates/metric-service.yaml chart/kubedns-shepherd/templates/metrics-service.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
apiVersion: v1
22
kind: Service
33
metadata:
4-
name: {{ include "chart.fullname" . }}-metric-service
4+
name: {{ include "chart.fullname" . }}-metrics-service
55
namespace: {{ .Release.Namespace }}
66
labels:
77
app.kubernetes.io/component: metrics

chart/kubedns-shepherd/templates/mutating-webhook-configuration.yaml

+5-7
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,16 @@ kind: MutatingWebhookConfiguration
33
metadata:
44
name: {{ include "chart.fullname" . }}-mutating-webhook-configuration
55
annotations:
6-
helm.sh/hook: post-install,post-upgrade
7-
helm.sh/hook-weight: "5"
8-
cert-manager.io/inject-ca-from: {{ .Release.Namespace }}/{{ include "chart.fullname" . }}-serving-cert
6+
cert-manager.io/inject-ca-from: '{{ .Release.Namespace }}/{{ include "chart.fullname" . }}-serving-cert'
97
labels:
108
{{- include "chart.labels" . | nindent 4 }}
119
webhooks:
1210
- admissionReviewVersions:
1311
- v1
1412
clientConfig:
1513
service:
16-
name: {{ include "chart.fullname" . }}-webhook-service
17-
namespace: {{ .Release.Namespace }}
14+
name: '{{ include "chart.fullname" . }}-webhook-service'
15+
namespace: '{{ .Release.Namespace }}'
1816
path: /mutate-config-kubedns-shepherd-io-v1alpha1-dnsclass
1917
failurePolicy: Fail
2018
name: mdnsclass.kubedns-shepherd.io
@@ -33,8 +31,8 @@ webhooks:
3331
- v1
3432
clientConfig:
3533
service:
36-
name: {{ include "chart.fullname" . }}-webhook-service
37-
namespace: {{ .Release.Namespace }}
34+
name: '{{ include "chart.fullname" . }}-webhook-service'
35+
namespace: '{{ .Release.Namespace }}'
3836
path: /mutate-v1-pod
3937
failurePolicy: Ignore
4038
name: mpod.kubedns-shepherd.io
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{{- if .Values.dnsclass.enabled }}
2+
apiVersion: v1
3+
kind: Service
4+
metadata:
5+
name: {{ include "chart.fullname" . }}-probe-service
6+
namespace: {{ .Release.Namespace }}
7+
labels:
8+
app.kubernetes.io/component: probe
9+
app.kubernetes.io/part-of: kubedns-shepherd
10+
{{- include "chart.labels" . | nindent 4 }}
11+
spec:
12+
type: ClusterIP
13+
selector:
14+
control-plane: controller-manager
15+
{{- include "chart.selectorLabels" . | nindent 4 }}
16+
ports:
17+
- name: probe
18+
port: 8081
19+
protocol: TCP
20+
targetPort: probe
21+
{{- end }}

chart/kubedns-shepherd/templates/selfsigned-issuer.yaml

+1-2
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,10 @@ metadata:
66
annotations:
77
{{- if .Values.certmanager.enabled }}
88
helm.sh/hook: post-install,post-upgrade
9-
helm.sh/hook-weight: "1"
109
{{- else }}
1110
helm.sh/hook: pre-install,pre-upgrade
12-
helm.sh/hook-weight: "1"
1311
{{- end }}
12+
helm.sh/hook-weight: "1"
1413
labels:
1514
{{- include "chart.labels" . | nindent 4 }}
1615
spec:

chart/kubedns-shepherd/templates/serving-cert.yaml

+1-2
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,10 @@ metadata:
66
annotations:
77
{{- if .Values.certmanager.enabled }}
88
helm.sh/hook: post-install,post-upgrade
9-
helm.sh/hook-weight: "2"
109
{{- else }}
1110
helm.sh/hook: pre-install,pre-upgrade
12-
helm.sh/hook-weight: "2"
1311
{{- end }}
12+
helm.sh/hook-weight: "2"
1413
labels:
1514
{{- include "chart.labels" . | nindent 4 }}
1615
spec:

chart/kubedns-shepherd/templates/validating-webhook-configuration.yaml

+3-5
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,16 @@ kind: ValidatingWebhookConfiguration
33
metadata:
44
name: {{ include "chart.fullname" . }}-validating-webhook-configuration
55
annotations:
6-
helm.sh/hook: post-install,post-upgrade
7-
helm.sh/hook-weight: "5"
8-
cert-manager.io/inject-ca-from: {{ .Release.Namespace }}/{{ include "chart.fullname" . }}-serving-cert
6+
cert-manager.io/inject-ca-from: '{{ .Release.Namespace }}/{{ include "chart.fullname" . }}-serving-cert'
97
labels:
108
{{- include "chart.labels" . | nindent 4 }}
119
webhooks:
1210
- admissionReviewVersions:
1311
- v1
1412
clientConfig:
1513
service:
16-
name: {{ include "chart.fullname" . }}-webhook-service
17-
namespace: {{ .Release.Namespace }}
14+
name: '{{ include "chart.fullname" . }}-webhook-service'
15+
namespace: '{{ .Release.Namespace }}'
1816
path: /validate-config-kubedns-shepherd-io-v1alpha1-dnsclass
1917
failurePolicy: Fail
2018
name: vdnsclass.kubedns-shepherd.io

chart/kubedns-shepherd/values.yaml

+13-5
Original file line numberDiff line numberDiff line change
@@ -55,22 +55,30 @@ certmanager:
5555
keep: true
5656

5757
dnsclass:
58+
enabled: false
5859
disabledNamespaces:
5960
- kube-system
60-
allowedNamespaces:
61-
- default
61+
allowedNamespaces: []
6262
allowedDNSPolicies:
6363
- None
6464
- ClusterFirst
6565
- ClusterFirstWithHostNet
6666
dnsPolicy: None
67+
# dnsConfig supports templating for dynamic configuration.
68+
# For more details on how to use templating with dnsConfig,
69+
# please refer to the documentation:
70+
# https://github.com/eminaktas/kubedns-shepherd?tab=readme-ov-file#dynamic-configuration-in-dnsclass
6771
dnsConfig:
6872
nameservers:
6973
- 10.96.0.10
7074
searches:
71-
- "svc.{{ .clusterDomain }}"
72-
- "{{ .podNamespace }}.svc.{{ .clusterDomain }}"
75+
- "svc.cluster.local"
76+
- "{{ .podNamespace }}.svc.cluster.local"
7377
options:
7478
- name: ndots
7579
value: "2"
76-
- name: edns0
80+
- name: edns0
81+
82+
readyCheck:
83+
maxRetries: 12
84+
sleepInterval: 10

0 commit comments

Comments
 (0)