Skip to content

fix: replace projectcalico.org/name with kubernetes.io/metadata.name in NetworkPolicies - #5151

Open
sivasubramanian95 wants to merge 1 commit into
tigera:masterfrom
sivasubramanian95:fix/use-kubernetes-metadata-name-label
Open

fix: replace projectcalico.org/name with kubernetes.io/metadata.name in NetworkPolicies#5151
sivasubramanian95 wants to merge 1 commit into
tigera:masterfrom
sivasubramanian95:fix/use-kubernetes-metadata-name-label

Conversation

@sivasubramanian95

Copy link
Copy Markdown

Type: Bug fix / enhancement

Why: On platforms where the Calico namespace controller is not enabled (e.g., EKS with AmazonVPC CNI, where ENABLED_CONTROLLERS=node,loadbalancer), the projectcalico.org/name label is never applied to
namespaces. Operator-managed NetworkPolicies reference this label in namespace selectors, so their rules never match — breaking DNS resolution for components like Whisker and Goldmane.

Fix: Replace all uses of projectcalico.org/name with kubernetes.io/metadata.name in namespace selectors (both Calico v3 and Kubernetes NetworkPolicies). This label is automatically applied by
Kubernetes to all namespaces since v1.21 and requires no controller.

Components affected:

  • pkg/render/common/networkpolicy/ — core DNS egress and entity rule helpers
  • pkg/render/common/selector/ — CalicoNameLabel constant
  • pkg/render/logcollector/, pkg/render/logstorage/, pkg/render/intrusion_detection.go
  • pkg/controller/policyrecommendation/ — namespace exclusion selectors
  • 58 test fixture JSON files

Testing:

  • All unit tests pass (29 packages including render, tiers, logcollector, logstorage, gateway, gatewayapi, policyrecommendation, whisker)
  • Pre-commit hooks pass

Issue: #4624 (#4624)

Fixes #4624

Release Note

Operator-managed NetworkPolicies now use the kubernetes.io/metadata.name label for namespace selectors instead of projectcalico.org/name. This fixes DNS resolution failures on platforms where the
Calico namespace controller is not enabled (e.g., EKS with AmazonVPC CNI).

For PR author

  • Tests for change.
  • If changing pkg/apis/, run make gen-files (not applicable — no API changes)
  • If changing versions, run make gen-versions (not applicable)

…in NetworkPolicies

Replace all uses of the projectcalico.org/name label with the built-in
kubernetes.io/metadata.name label in operator-managed NetworkPolicy namespace
selectors (both Calico v3 and Kubernetes NetworkPolicies).

On platforms where the Calico namespace controller is not enabled (e.g., EKS
with AmazonVPC CNI), the projectcalico.org/name label is never applied to
namespaces, causing NetworkPolicy rules that reference it to never match.
This breaks DNS resolution for operator components like Whisker and Goldmane.

The kubernetes.io/metadata.name label is automatically applied by Kubernetes
to all namespaces since v1.21 and requires no controller.

Fixes tigera#4624
@CLAassistant

CLAassistant commented Aug 10, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@caseydavenport

Copy link
Copy Markdown
Member

Thansk for the PR! Before merging, you will need to sign the CLA to make the bot happy.

@caseydavenport caseydavenport self-assigned this Aug 10, 2026
@sivasubramanian95

Copy link
Copy Markdown
Author

Just signed the CLA. thanks

@caseydavenport caseydavenport left a comment

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.

LGTM!

@sivasubramanian95

Copy link
Copy Markdown
Author

Thanks for the review, @caseydavenport ! - looks like the GitHub Actions checks are stuck in action_required and need a maintainer to approve the workflow run. Could you kick that off when you get a chance?

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Namespace controller not enabled on EKS but operator-managed NetworkPolicies reference projectcalico.org/name labels

4 participants