From 0bd79dcb150d5c39212655859103e4360ea43230 Mon Sep 17 00:00:00 2001 From: pasteley Date: Wed, 21 Jan 2026 21:44:02 +0100 Subject: [PATCH] feat: allow to redifine dnsPolicy and dnsConfig Signed-off-by: pasteley --- charts/coredns/Chart.yaml | 8 ++------ charts/coredns/README.md | 2 ++ charts/coredns/templates/deployment.yaml | 14 ++++++++------ charts/coredns/values.yaml | 17 +++++++++++++++++ 4 files changed, 29 insertions(+), 12 deletions(-) diff --git a/charts/coredns/Chart.yaml b/charts/coredns/Chart.yaml index 65b678750..8396a7893 100644 --- a/charts/coredns/Chart.yaml +++ b/charts/coredns/Chart.yaml @@ -1,6 +1,6 @@ apiVersion: v2 name: coredns -version: 1.45.1 +version: 1.45.2 appVersion: 1.13.1 home: https://coredns.io icon: https://coredns.io/images/CoreDNS_Colour_Horizontal.png @@ -20,8 +20,4 @@ type: application annotations: artifacthub.io/changes: | - kind: added - description: Support for customAnnotations on ClusterRole and ClusterRoleBinding - - kind: added - description: Support for dnsConfig in deployment - - kind: added - description: Support for podLabels + description: Add configurable dnsPolicy for deployment diff --git a/charts/coredns/README.md b/charts/coredns/README.md index a73407187..c7443747e 100644 --- a/charts/coredns/README.md +++ b/charts/coredns/README.md @@ -211,6 +211,8 @@ The command removes all the Kubernetes components associated with the chart and | `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 | `{}` | +| `deployment.dnsPolicy` | DNS policy for the pod (Default, ClusterFirst, ClusterFirstWithHostNet, None) | `"Default"` | +| `deployment.dnsConfig` | Custom DNS configuration (nameservers, searches, options). Required when dnsPolicy is "None" | `{}` | | `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/deployment.yaml b/charts/coredns/templates/deployment.yaml index 66d25213c..62d9c7681 100644 --- a/charts/coredns/templates/deployment.yaml +++ b/charts/coredns/templates/deployment.yaml @@ -75,13 +75,15 @@ spec: {{- if .Values.priorityClassName }} priorityClassName: {{ .Values.priorityClassName | quote }} {{- end }} - {{- if .Values.dnsConfig }} - dnsPolicy: None - {{- else if .Values.isClusterService }} - dnsPolicy: Default + {{- if .Values.isClusterService }} + dnsPolicy: {{ .Values.deployment.dnsPolicy }} + {{- end }} + {{- if and (eq .Values.deployment.dnsPolicy "None") (not .Values.deployment.dnsConfig) }} + {{- fail "dnsConfig is required when dnsPolicy is set to None" }} {{- end }} - {{- if .Values.dnsConfig }} - dnsConfig: {{ toYaml .Values.dnsConfig | nindent 8 }} + {{- with .Values.deployment.dnsConfig }} + dnsConfig: + {{- toYaml . | nindent 8 }} {{- end }} {{- if .Values.affinity }} affinity: diff --git a/charts/coredns/values.yaml b/charts/coredns/values.yaml index c729f0fb8..5f49cb330 100644 --- a/charts/coredns/values.yaml +++ b/charts/coredns/values.yaml @@ -405,6 +405,23 @@ deployment: annotations: {} ## Pod selector selector: {} + # dnsPolicy determines how DNS resolution is handled for the pod. + # When isClusterService is true, this defaults to "Default" to avoid circular DNS resolution. + # Options: Default, ClusterFirst, ClusterFirstWithHostNet, None + # If set to "None", you must provide dnsConfig. + dnsPolicy: "Default" + # dnsConfig allows fine-grained DNS configuration for the pod. + # Only used when dnsPolicy is set to "None" or when custom DNS settings are needed. + # Example: + # dnsConfig: + # nameservers: + # - 8.8.8.8 + # searches: + # - my.dns.search.suffix + # options: + # - name: ndots + # value: "2" + dnsConfig: {} # Configures initcontainers for the coredns deployment. initContainers: []