Skip to content

[node-local-dns] Add spec.trafficDistribution #738

@dbsmartchain

Description

@dbsmartchain

Hi!
Can you please implement/add trafficDistribution key to Upstream Service manifest?

🎯 Use Case: Multi-AZ Kubernetes Clusters

Problem:

In multi-AZ clusters, DNS queries from nodes in one availability zone (AZ) may be routed to DNS servers in different AZs, causing unnecessary cross-AZ network traffic, increased latency, and higher costs.

Solution: upstreamServiceTrafficDistribution: PreferClose

upstreamServiceTrafficDistribution: PreferClose

How It Works:

  • Node in AZ-A → Prefers DNS upstream endpoints in AZ-A
  • Node in AZ-B → Prefers DNS upstream endpoints in AZ-B
  • Node in AZ-C → Prefers DNS upstream endpoints in AZ-C

Benefits:

  • Reduced Latency: DNS queries stay within local AZ
  • 💰 Lower Costs: Eliminates cross-AZ data transfer charges
  • 🛡️ Better Reliability: AZ failures don't affect DNS resolution in other AZs
  • 🎯 Optimized Performance: Local network routing for DNS traffic

Real-World Impact:

In a 3-AZ cluster with 10 nodes per AZ, this can reduce cross-AZ DNS traffic by ~67%, significantly lowering cloud networking costs while improving DNS query performance.

Commit Message:

feat: add upstreamServiceTrafficDistribution parameter

Add optional trafficDistribution field to upstream service with support for:
- PreferClose: Route traffic to endpoints in the same zone
- PreferSameZone: Alias for PreferClose (clearer naming)
- PreferSameNode: Route traffic to endpoints on the same node

Parameter is optional and only applied when configured. Includes:
- Updated values.yaml with documentation and examples
- Modified service-upstream.yaml template with conditional field rendering
- Updated README.md with parameter documentation and link to Kubernetes docs

Files Changed:

  • stable/node-local-dns/README.md (1 addition)
  • stable/node-local-dns/templates/service-upstream.yaml (3 additions)
  • stable/node-local-dns/values.yaml (4 additions)

Git Diff:

diff --git a/stable/node-local-dns/README.md b/stable/node-local-dns/README.md
index e2816b0..3bee758 100644
--- a/stable/node-local-dns/README.md
+++ b/stable/node-local-dns/README.md
@@ -86,6 +86,7 @@ helm install my-release oci://ghcr.io/deliveryhero/helm-charts/node-local-dns -f
 | resources.requests.memory | string | `"128Mi"` |  |
 | securityContext.capabilities.add[0] | string | `"NET_ADMIN"` |  |
 | service.annotations | object | `{}` | Annotations to add to the service. |
+| upstreamServiceTrafficDistribution | string | `nil` | Traffic distribution policy for the upstream service. Options: PreferClose, PreferSameZone, PreferSameNode. @see https://kubernetes.io/docs/concepts/services-networking/service/#traffic-distribution |
 | serviceAccount.annotations | object | `{}` | Annotations to add to the service account. |
 | serviceAccount.create | bool | `true` | Specifies whether a service account should be created. |
 | serviceAccount.name | string | `""` | If not set and create is true, a name is generated using the fullname template. |
diff --git a/stable/node-local-dns/templates/service-upstream.yaml b/stable/node-local-dns/templates/service-upstream.yaml
index d11ecc0..92055be 100644
--- a/stable/node-local-dns/templates/service-upstream.yaml
+++ b/stable/node-local-dns/templates/service-upstream.yaml
@@ -7,6 +7,9 @@ metadata:
   labels:
     {{- include "node-local-dns.labels" . | nindent 4 }}
 spec:
+  {{- with .Values.upstreamServiceTrafficDistribution }}
+  trafficDistribution: {{ . }}
+  {{- end }}
   ports:
   - name: dns
     port: 53
diff --git a/stable/node-local-dns/values.yaml b/stable/node-local-dns/values.yaml
index 2bce944..1754d0d 100644
--- a/stable/node-local-dns/values.yaml
+++ b/stable/node-local-dns/values.yaml
@@ -56,6 +56,10 @@ config:
 nameOverride: ""
 fullnameOverride: ""
 
+# -- Traffic distribution policy for the upstream service. Options: PreferClose, PreferSameZone, PreferSameNode
+# @see https://kubernetes.io/docs/concepts/services-networking/service/#traffic-distribution
+# upstreamServiceTrafficDistribution: PreferClose
+
 serviceAccount:
   # -- Specifies whether a service account should be created.
   create: true

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions