Skip to content

fix(networkpolicy): allow DNS egress to link-local resolvers (GKE Cloud DNS, NodeLocal DNSCache) - #4001

Open
aqeelat wants to merge 1 commit into
tektoncd:mainfrom
aqeelat:fix/dns-egress-link-local
Open

fix(networkpolicy): allow DNS egress to link-local resolvers (GKE Cloud DNS, NodeLocal DNSCache)#4001
aqeelat wants to merge 1 commit into
tektoncd:mainfrom
aqeelat:fix/dns-egress-link-local

Conversation

@aqeelat

@aqeelat aqeelat commented Aug 30, 2026

Copy link
Copy Markdown
Contributor

Changes

DNSEgressRule allowed DNS egress only to the kube-dns/CoreDNS pod peer. On GKE clusters using Cloud DNS, kubelet points every pod's resolv.conf at the link-local metadata server 169.254.169.254, which no pod selector can match — so on Dataplane V2 clusters DNS egress is dropped and e.g. tekton-results-retention-policy-agent crashloops. NodeLocal DNSCache (169.254.20.10) has the same host-network property.

Adds ipBlock peers 169.254.169.254/32 and 169.254.20.10/32 (UDP+TCP 53) to the Kubernetes-platform DNS rule, alongside the existing pod peer. Purely additive — on clusters not using these resolvers the peers never match. OpenShift unchanged. Fixes #4000.

Submitter Checklist

These are the criteria that every PR should meet, please check them off as you
review them:

See the contribution guide for more details.

Release Notes

NetworkPolicies generated by the operator now allow DNS egress to link-local resolvers (GKE Cloud DNS 169.254.169.254 and NodeLocal DNSCache 169.254.20.10), fixing DNS failures on GKE clusters using Cloud DNS.

AI assistance: developed with opencode (GLM model) under my direction; every commit carries an Assisted-by: trailer per the AI contribution policy. I drove scoping and decisions, reviewed every change, and verified each push — unit tests and make test lint for the touched packages.

@tekton-robot tekton-robot added the release-note Denotes a PR that will be considered when it comes time to generate release notes. label Aug 30, 2026
@tekton-robot

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
To complete the pull request process, please assign pramodbindal after the PR has been reviewed.
You can assign the PR to them by writing /assign @pramodbindal in a comment when ready.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@tekton-robot tekton-robot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Aug 30, 2026
@codecov

codecov Bot commented Aug 30, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 26.98%. Comparing base (3fc9104) to head (bfe8b88).
⚠️ Report is 10 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4001      +/-   ##
==========================================
+ Coverage   26.44%   26.98%   +0.53%     
==========================================
  Files         465      467       +2     
  Lines       24992    25179     +187     
==========================================
+ Hits         6610     6794     +184     
+ Misses      17661    17648      -13     
- Partials      721      737      +16     
Flag Coverage Δ
unit-tests 26.98% <ø> (+0.53%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@aqeelat
aqeelat force-pushed the fix/dns-egress-link-local branch from 4e35fa0 to 4a145dc Compare September 4, 2026 16:12
return PlatformParams{
DNSResolverNamespace: "kube-system",
DNSResolverPodLabel: map[string]string{"k8s-app": "kube-dns"},
DNSResolverIPBlocks: []string{"169.254.169.254/32", "169.254.20.10/32"},

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add comment here
// 169.254.169.254/32: GKE Cloud DNS forwarder (link-local, host-network).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not just GKE. I think aws and azure also have it.

BTW, I saw it in some charts as 169.254.0.0/16
Do we want that?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the GCE/AWS IMDS IP is already in the list as a /32, so /16 doesnt add any functional value

@aqeelat aqeelat Sep 10, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added in bfe8b88, along with per-entry comments. On the /16 question: it turns out /16 would add one thing the two /32s lack — 169.254.169.253, the AWS VPC resolver (Route 53 Resolver is link-local too). I've added that as a /32 rather than widening to /16: with the three documented resolvers covered, the /16 would only add non-default NodeLocal localips, at the cost of exposing port 53 to the entire link-local range. On whether AWS/Azure "also have" 169.254.169.254 — as a DNS endpoint only GCP does; on AWS that address is IMDS (no DNS listener), and Azure's IMDS is 169.254.169.50 with Azure DNS at 168.63.129.16 (not link-local at all, so out of scope here). The rule stays port-scoped to 53, so IMDS on 80 remains blocked either way.

@tekton-robot tekton-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Sep 10, 2026
@jkhelil

jkhelil commented Sep 10, 2026

Copy link
Copy Markdown
Member

@aqeelat PLease squash your commit; and will be happy to approve

DNSEgressRule allowed DNS egress only to the kube-dns/CoreDNS pod
peer. On GKE clusters using Cloud DNS, kubelet points every pod's
resolv.conf at the link-local metadata server 169.254.169.254,
which no pod selector can match, so DNS egress is dropped on
Dataplane V2 clusters. NodeLocal DNSCache (169.254.20.10, GKE
Autopilot default) has the same host-network property.

Add ipBlock peers 169.254.169.254/32 and 169.254.20.10/32 (UDP+TCP
53) to the Kubernetes-platform DNS rule alongside the existing pod
peer, plus 169.254.169.253/32 — the AWS VPC resolver (Route 53
Resolver). Default ClusterFirst pods never query the AWS resolver
directly (they use the CoreDNS Service IP), but pods with custom DNS
configuration do, so it is allowed for parity with the GKE entries.
Azure is deliberately not covered: Azure DNS (168.63.129.16) is not
a link-local endpoint. Each peer is documented inline.

Purely additive: on clusters not using these resolvers the peers
never match; the rule stays port-scoped to 53, so IMDS on 80 remains
blocked. OpenShift unchanged.

Fixes tektoncd#4000

Signed-off-by: Abdullah Alaqeel <abdullah.t.aqeel@gmail.com>
Assisted-by: GLM (via opencode)
@aqeelat
aqeelat force-pushed the fix/dns-egress-link-local branch from 09cfcb1 to bfe8b88 Compare September 10, 2026 10:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release-note Denotes a PR that will be considered when it comes time to generate release notes. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Generated NetworkPolicies break DNS on GKE clusters using Cloud DNS (link-local resolver cannot be matched by pod selector)

3 participants