Skip to content

Use ClusterFirst DNS instead of hardcoded public resolvers for secure-by-default#449

Open
noeljackson wants to merge 1 commit intokubernetes-sigs:mainfrom
noeljackson:fix/dns-cluster-first
Open

Use ClusterFirst DNS instead of hardcoded public resolvers for secure-by-default#449
noeljackson wants to merge 1 commit intokubernetes-sigs:mainfrom
noeljackson:fix/dns-cluster-first

Conversation

@noeljackson
Copy link
Contributor

Summary

The secure-by-default DNS policy currently sets DNSNone with hardcoded 8.8.8.8 and 1.1.1.1 nameservers when a sandbox template doesn't specify an explicit dnsPolicy. This completely breaks cluster-internal DNS resolution, which means any sidecar container that needs to discover cluster services (health checks, coordinators, etc.) can't resolve *.svc.cluster.local names at all.

This switches the default to ClusterFirst, which is what Kubernetes uses by default for pods anyway. It still prevents DNS enumeration of external services through the cluster's CoreDNS policy and network policy egress rules, but lets pods resolve the cluster services they actually need. The DNSNone + public resolver approach was too aggressive for any multi-container pod pattern where a sidecar needs to talk to other cluster services.

What changed:

  • sandboxclaim_controller.go: default DNS policy is now ClusterFirst instead of DNSNone with hardcoded nameservers
  • sandboxwarmpool_controller.go: same change for warm pool sandboxes
  • sandboxclaim_controller_test.go: updated test expectations to match

The behavior when users explicitly set a dnsPolicy in their template is unchanged. This only affects the fallback when no policy is specified.

Test plan

  • go test ./extensions/controllers/... passes
  • Deploy updated controller, verify resolv.conf in sandbox pods shows cluster DNS (nameserver 10.43.0.10 or equivalent)
  • Verify sidecar containers can resolve cluster-local service names

The secure-by-default DNS policy set DNSNone + 8.8.8.8/1.1.1.1 for
sandboxes without an explicit dnsPolicy. This breaks any sidecar or
init container that needs to resolve cluster-internal names (e.g.
service discovery via *.svc.cluster.local).

Switch to ClusterFirst, which still prevents external DNS enumeration
via the cluster's CoreDNS policy while allowing pods to resolve
cluster services -- needed for health checks, sidecars, and any
multi-container pod pattern.
@netlify
Copy link

netlify bot commented Mar 20, 2026

Deploy Preview for agent-sandbox canceled.

Name Link
🔨 Latest commit 5235430
🔍 Latest deploy log https://app.netlify.com/projects/agent-sandbox/deploys/69bdb234ebb1e600081bc8bd

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: noeljackson
Once this PR has been reviewed and has the lgtm label, please assign igooch for approval. For more information see the Code Review Process.

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

@k8s-ci-robot k8s-ci-robot requested review from igooch and janetkuo March 20, 2026 20:46
@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Mar 20, 2026
@k8s-ci-robot
Copy link
Contributor

Hi @noeljackson. Thanks for your PR.

I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work.

Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@k8s-ci-robot k8s-ci-robot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Mar 20, 2026
@janetkuo
Copy link
Member

/ok-to-test

@k8s-ci-robot k8s-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Mar 21, 2026
@janetkuo
Copy link
Member

@vicentefb @mtaufen

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants