diff --git a/charts/bind9/Chart.yaml b/charts/bind9/Chart.yaml index a86938c..f41d591 100644 --- a/charts/bind9/Chart.yaml +++ b/charts/bind9/Chart.yaml @@ -3,7 +3,7 @@ name: bind9 description: A flexible and production-ready Helm chart for running ISC Bind9 DNS server on Kubernetes. type: application -version: 2026.3.1 +version: 2026.3.17 appVersion: "9.21" icon: https://www.aschnoebelen.fr/wp-content/uploads/2024/01/bind9.png diff --git a/charts/bind9/templates/configmap.yaml b/charts/bind9/templates/configmap.yaml index 2e7c368..4e7f8f3 100644 --- a/charts/bind9/templates/configmap.yaml +++ b/charts/bind9/templates/configmap.yaml @@ -7,6 +7,11 @@ metadata: data: named.conf: | + {{- if .Values.metrics.enabled }} + statistics-channels { + inet 127.0.0.1 port 8053 allow { 127.0.0.1; }; + }; + {{- end }} {{- .Values.bind.namedConf | nindent 4 }} {{- range $name, $zone := .Values.bind.zones }} diff --git a/charts/bind9/templates/deployment.yaml b/charts/bind9/templates/deployment.yaml index c764076..0024a1a 100644 --- a/charts/bind9/templates/deployment.yaml +++ b/charts/bind9/templates/deployment.yaml @@ -45,10 +45,10 @@ spec: command: ["/usr/sbin/named"] args: - - "-f" - - "-g" + - "-f" + - "-g" {{- with .Values.bind.args }} - {{- toYaml . | nindent 10 }} + {{- toYaml . | nindent 12 }} {{- end }} ports: @@ -96,7 +96,35 @@ spec: - name: bind-data mountPath: /var/lib/bind {{- end }} - + {{- if .Values.metrics.enabled }} + - name: {{ .Chart.Name }}-exporter + {{- with .Values.metrics.securityContext }} + securityContext: + {{- toYaml . | nindent 12 }} + {{- end }} + image: "{{ .Values.metrics.image.repository }}:{{ .Values.metrics.image.tag }}" + imagePullPolicy: {{ .Values.metrics.image.pullPolicy }} + args: + - --bind.stats-url=http://127.0.0.1:8053/ + - --bind.stats-groups={{ .Values.metrics.statsGroups | join "," }} + - --web.listen-address=:{{ .Values.service.ports.metrics }} + ports: + - name: metrics + containerPort: {{ .Values.service.ports.metrics }} + protocol: TCP + {{- with .Values.metrics.livenessProbe }} + livenessProbe: + {{- toYaml . | nindent 12 }} + {{- end }} + {{- with .Values.metrics.readinessProbe }} + readinessProbe: + {{- toYaml . | nindent 12 }} + {{- end }} + {{- with .Values.metrics.resources }} + resources: + {{- toYaml . | nindent 12 }} + {{- end }} + {{- end }} volumes: - name: bind-config configMap: diff --git a/charts/bind9/templates/service.yaml b/charts/bind9/templates/service.yaml index 741cca7..c94bf34 100644 --- a/charts/bind9/templates/service.yaml +++ b/charts/bind9/templates/service.yaml @@ -32,6 +32,16 @@ spec: nodePort: {{ .Values.service.ports.rndcNodePort }} {{- end }} + {{- if .Values.metrics.enabled }} + - name: metrics + port: {{ .Values.service.ports.metrics }} + targetPort: metrics + protocol: TCP + {{- if and .Values.service.ports.rndcNodePort (ne .Values.service.type "ClusterIP") }} + nodePort: {{ .Values.service.ports.rndcNodePort }} + {{- end }} + {{- end }} + selector: {{- include "bind9.selectorLabels" . | nindent 4 }} {{- end }} \ No newline at end of file diff --git a/charts/bind9/templates/servicemonitor.yaml b/charts/bind9/templates/servicemonitor.yaml new file mode 100644 index 0000000..23db1cc --- /dev/null +++ b/charts/bind9/templates/servicemonitor.yaml @@ -0,0 +1,17 @@ +{{- if .Values.metrics.serviceMonitor.enabled }} +apiVersion: monitoring.coreos.com/v1 +kind: ServiceMonitor +metadata: + name: {{ include "bind9.fullname" . }} + labels: + {{- include "bind9.labels" . | nindent 4 }} +spec: + endpoints: + {{ .Values.metrics.serviceMonitor.endpoints | toYaml | nindent 4 }} + namespaceSelector: + matchNames: + - {{ .Release.Namespace }} + selector: + matchLabels: + {{- include "bind9.selectorLabels" . | nindent 6 }} +{{- end }} diff --git a/charts/bind9/values.yaml b/charts/bind9/values.yaml index 36667c3..b5bc9b7 100644 --- a/charts/bind9/values.yaml +++ b/charts/bind9/values.yaml @@ -60,6 +60,7 @@ service: dnsTcpNodePort: 30053 dnsUdpNodePort: 30053 rndcNodePort: 30054 + metrics: 9119 resources: {} # limits: @@ -95,6 +96,53 @@ autoscaling: maxReplicas: 100 targetCPUUtilizationPercentage: 80 +metrics: + enabled: false + + # list of statistics to collect + statsGroups: + - server + - tasks + - view + + image: + repository: prometheuscommunity/bind-exporter + pullPolicy: IfNotPresent + tag: v0.8.0 + + securityContext: + allowPrivilegeEscalation: false + capabilities: + drop: + - ALL + livenessProbe: + failureThreshold: 3 + httpGet: + path: / + port: metrics + scheme: HTTP + periodSeconds: 10 + successThreshold: 1 + timeoutSeconds: 1 + readinessProbe: + failureThreshold: 3 + httpGet: + path: / + port: metrics + scheme: HTTP + periodSeconds: 10 + successThreshold: 1 + timeoutSeconds: 1 + + resources: {} + + serviceMonitor: + # Toggle the ServiceMonitor true if you have Prometheus Operator installed and configured + enabled: true + endpoints: + - port: metrics + scheme: http + # General Bind9 configuration bind: # Extra args to pass to named