Skip to content

Feat/add kubernetes labels#13439

Open
TRIVENI206 wants to merge 6 commits intokgateway-dev:mainfrom
TRIVENI206:feat/add-kubernetes-labels
Open

Feat/add kubernetes labels#13439
TRIVENI206 wants to merge 6 commits intokgateway-dev:mainfrom
TRIVENI206:feat/add-kubernetes-labels

Conversation

@TRIVENI206
Copy link

@TRIVENI206 TRIVENI206 commented Jan 28, 2026

Description

#motivation
kgateway deployments currently lack a standard label to distinguish controller and gateway (proxy) components.
This makes it difficult to use selector-based features such as podAntiAffinity and topologySpreadConstraints without injecting custom labels.
#what changed

  • Added the standard Kubernetes label app.kubernetes.io/component to distinguish:
  • controller pods (controller)
  • gateway / proxy pods (gateway)
  • Centralized the label via Helm helper templates so it is applied consistently.
  • Ensured the label is included in both pod labels and Deployment selectors.
  • Existing and user-provided labels are preserved.

Change Type

/kind feature

#related to the
#13429

Add standard Kubernetes component labels (`app.kubernetes.io/component`) to controller and gateway pods so they can be reliably targeted using selectors such as podAntiAffinity and topologySpreadConstraints.

@gateway-bot gateway-bot added do-not-merge/release-note-invalid Indicates that a PR should not merge because it's missing one of the release note labels. kind/feature Categorizes issue or PR as related to a new feature. labels Jan 28, 2026
Signed-off-by: TRIVENI206 <trivenireddy206@gmail.com>
Signed-off-by: TRIVENI206 <trivenireddy206@gmail.com>
@TRIVENI206 TRIVENI206 force-pushed the feat/add-kubernetes-labels branch from 5c11151 to 095bff1 Compare January 29, 2026 04:30
@gateway-bot gateway-bot added release-note and removed do-not-merge/release-note-invalid Indicates that a PR should not merge because it's missing one of the release note labels. labels Jan 29, 2026
agentgateway: agentgateway
app.kubernetes.io/name: {{ include "agentgateway.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/component: controller
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's add the type to the controller here and in install/helm/kgateway/templates/_helpers.tpl:

Suggested change
app.kubernetes.io/component: controller
app.kubernetes.io/component: agentgateway-controller

Signed-off-by: TRIVENI206 <trivenireddy206@gmail.com>
@npolshakova
Copy link
Contributor

Awesome! Just a heads up, you'll need to regen the unit tests with REFRESH_GOLDEN=true go test ./test/deployer to fix the deployer tests to have the new label.

Signed-off-by: trivenireddy <triveni@Asus.localdomain>
@TRIVENI206 TRIVENI206 force-pushed the feat/add-kubernetes-labels branch from 353fd51 to 5804c28 Compare February 3, 2026 12:55
@TRIVENI206
Copy link
Author

Thanks for the heads up! I’ve regenerated the deployer golden tests using REFRESH_GOLDEN=true go test ./test/deployer and updated the outputs to include the new component labels. The changes are pushed and CI should be rerunning now.

@npolshakova
Copy link
Contributor

Looks like there are still some diff failures in the unit tests, maybe try REFRESH_GOLDEN=true go test ./test/deployer and check the diff. https://github.com/kgateway-dev/kgateway/actions/runs/21631036858/job/62354622370?pr=13439

2026-02-03T14:39:56.9761827Z         	Error Trace:	/home/runner/work/kgateway/kgateway/test/deployer/deployer_helm.go:297
2026-02-03T14:39:56.9769112Z         	            				/home/runner/work/kgateway/kgateway/test/deployer/internal_helm_test.go:710
2026-02-03T14:39:56.9770053Z         	Error:      	Should be empty, but was   []uint8(
2026-02-03T14:39:56.9770442Z         	            	  	"""
2026-02-03T14:39:56.9770867Z         	            	  	... // 3 identical lines
2026-02-03T14:39:56.9771266Z         	            	  	metadata:
2026-02-03T14:39:56.9771610Z         	            	  	  labels:
2026-02-03T14:39:56.9772238Z         	            	+ 	    app.kubernetes.io/component: agentgateway-gateway
2026-02-03T14:39:56.9772822Z         	            	  	    app.kubernetes.io/instance: gw
2026-02-03T14:39:56.9773595Z         	            	  	    app.kubernetes.io/managed-by: kgateway
2026-02-03T14:39:56.9774093Z         	            	  	... // 208 identical lines
2026-02-03T14:39:56.9774481Z         	            	  	metadata:
2026-02-03T14:39:56.9774922Z         	            	  	  labels:
2026-02-03T14:39:56.9775547Z         	            	+ 	    app.kubernetes.io/component: agentgateway-gateway
2026-02-03T14:39:56.9776125Z         	            	  	    app.kubernetes.io/instance: gw
2026-02-03T14:39:56.9776725Z         	            	  	    app.kubernetes.io/managed-by: kgateway
2026-02-03T14:39:56.9777209Z         	            	  	... // 11 identical lines
2026-02-03T14:39:56.9777739Z         	            	  	    overlay-source: from-gateway
2026-02-03T14:39:56.9778126Z         	            	  	  labels:
2026-02-03T14:39:56.9778733Z         	            	+ 	    app.kubernetes.io/component: agentgateway-gateway
2026-02-03T14:39:56.9779299Z         	            	  	    app.kubernetes.io/instance: gw
2026-02-03T14:39:56.9779868Z         	            	  	    app.kubernetes.io/managed-by: kgateway
2026-02-03T14:39:56.9780355Z         	            	  	... // 11 identical lines
2026-02-03T14:39:56.9780791Z         	            	  	    targetPort: 8080
2026-02-03T14:39:56.9781184Z         	            	  	  selector:
2026-02-03T14:39:56.9781796Z         	            	+ 	    app.kubernetes.io/component: agentgateway-gateway
2026-02-03T14:39:56.9782378Z         	            	  	    app.kubernetes.io/instance: gw
2026-02-03T14:39:56.9782951Z         	            	  	    app.kubernetes.io/name: gw
2026-02-03T14:39:56.9783425Z         	            	  	... // 11 identical lines
2026-02-03T14:39:56.9784009Z         	            	  	    overlay-source: from-gateway
2026-02-03T14:39:56.9784386Z         	            	  	  labels:
2026-02-03T14:39:56.9785073Z         	            	+ 	    app.kubernetes.io/component: agentgateway-gateway
2026-02-03T14:39:56.9785662Z         	            	  	    app.kubernetes.io/instance: gw
2026-02-03T14:39:56.9786275Z         	            	  	    app.kubernetes.io/managed-by: kgateway
2026-02-03T14:39:56.9786763Z         	            	  	... // 10 identical lines
2026-02-03T14:39:56.9787170Z         	            	  	  selector:
2026-02-03T14:39:56.9787577Z         	            	  	    matchLabels:
2026-02-03T14:39:56.9788239Z         	            	+ 	      app.kubernetes.io/component: agentgateway-gateway
2026-02-03T14:39:56.9788826Z         	            	  	      app.kubernetes.io/instance: gw
2026-02-03T14:39:56.9789369Z         	            	  	      app.kubernetes.io/name: gw
2026-02-03T14:39:56.9789841Z         	            	  	... // 8 identical lines
2026-02-03T14:39:56.9790365Z         	            	  	        prometheus.io/scrape: "true"
2026-02-03T14:39:56.9790776Z         	            	  	      labels:
2026-02-03T14:39:56.9791435Z         	            	+ 	        app.kubernetes.io/component: agentgateway-gateway
2026-02-03T14:39:56.9792021Z         	            	  	        app.kubernetes.io/instance: gw
2026-02-03T14:39:56.9792545Z         	            	  	        app.kubernetes.io/name: gw
2026-02-03T14:39:56.9793127Z         	            	  	... // 81 identical lines
2026-02-03T14:39:56.9793553Z         	            	  	"""
2026-02-03T14:39:56.9793844Z         	            	  )
2026-02-03T14:39:56.9794358Z         	Test:       	TestRenderHelmChart/envoy_overlay_ordering_-_GWC_first_then_GW
2026-02-03T14:39:56.9794796Z         	Messages:   	  []uint8(
2026-02-03T14:39:56.9795111Z         	            	  	"""
2026-02-03T14:39:56.9795524Z         	            	  	... // 3 identical lines
2026-02-03T14:39:56.9795900Z         	            	  	metadata:
2026-02-03T14:39:56.9796245Z         	            	  	  labels:
2026-02-03T14:39:56.9796859Z         	            	+ 	    app.kubernetes.io/component: agentgateway-gateway
2026-02-03T14:39:56.9797425Z         	            	  	    app.kubernetes.io/instance: gw
2026-02-03T14:39:56.9797998Z         	            	  	    app.kubernetes.io/managed-by: kgateway
2026-02-03T14:39:56.9798477Z         	            	  	... // 208 identical lines
2026-02-03T14:39:56.9798851Z         	            	  	metadata:
2026-02-03T14:39:56.9799195Z         	            	  	  labels:
2026-02-03T14:39:56.9799824Z         	            	+ 	    app.kubernetes.io/component: agentgateway-gateway
2026-02-03T14:39:56.9800386Z         	            	  	    app.kubernetes.io/instance: gw
2026-02-03T14:39:56.9800952Z         	            	  	    app.kubernetes.io/managed-by: kgateway
2026-02-03T14:39:56.9801429Z         	            	  	... // 11 identical lines
2026-02-03T14:39:56.9801925Z         	            	  	    overlay-source: from-gateway
2026-02-03T14:39:56.9802304Z         	            	  	  labels:
2026-02-03T14:39:56.9802975Z         	            	+ 	    app.kubernetes.io/component: agentgateway-gateway
2026-02-03T14:39:56.9803541Z         	            	  	    app.kubernetes.io/instance: gw
2026-02-03T14:39:56.9804131Z         	            	  	    app.kubernetes.io/managed-by: kgateway
2026-02-03T14:39:56.9804618Z         	            	  	... // 11 identical lines
2026-02-03T14:39:56.9805065Z         	            	  	    targetPort: 8080
2026-02-03T14:39:56.9805440Z         	            	  	  selector:
2026-02-03T14:39:56.9806058Z         	            	+ 	    app.kubernetes.io/component: agentgateway-gateway
2026-02-03T14:39:56.9806632Z         	            	  	    app.kubernetes.io/instance: gw
2026-02-03T14:39:56.9807132Z         	            	  	    app.kubernetes.io/name: gw
2026-02-03T14:39:56.9807601Z         	            	  	... // 11 identical lines
2026-02-03T14:39:56.9808252Z         	            	  	    overlay-source: from-gateway
2026-02-03T14:39:56.9808692Z         	            	  	  labels:
2026-02-03T14:39:56.9809460Z         	            	+ 	    app.kubernetes.io/component: agentgateway-gateway
2026-02-03T14:39:56.9810085Z         	            	  	    app.kubernetes.io/instance: gw
2026-02-03T14:39:56.9810659Z         	            	  	    app.kubernetes.io/managed-by: kgateway
2026-02-03T14:39:56.9811147Z         	            	  	... // 10 identical lines
2026-02-03T14:39:56.9811543Z         	            	  	  selector:
2026-02-03T14:39:56.9811946Z         	            	  	    matchLabels:
2026-02-03T14:39:56.9812590Z         	            	+ 	      app.kubernetes.io/component: agentgateway-gateway
2026-02-03T14:39:56.9813403Z         	            	  	      app.kubernetes.io/instance: gw
2026-02-03T14:39:56.9813934Z         	            	  	      app.kubernetes.io/name: gw
2026-02-03T14:39:56.9814399Z         	            	  	... // 8 identical lines
2026-02-03T14:39:56.9814932Z         	            	  	        prometheus.io/scrape: "true"
2026-02-03T14:39:56.9815363Z         	            	  	      labels:
2026-02-03T14:39:56.9816001Z         	            	+ 	        app.kubernetes.io/component: agentgateway-gateway
2026-02-03T14:39:56.9816609Z         	            	  	        app.kubernetes.io/instance: gw
2026-02-03T14:39:56.9817150Z         	            	  	        app.kubernetes.io/name: gw
2026-02-03T14:39:56.9817614Z         	            	  	... // 81 identical lines
2026-02-03T14:39:56.9817957Z         	            	  	"""
2026-02-03T14:39:56.9818242Z         	            	  )
2026-02-03T14:39:56.9818499Z         	            	
2026-02-03T14:39:56.9819655Z         	            	the golden file, which can be refreshed via `REFRESH_GOLDEN=true go test ./test/deployer`, is

You can run the unit tests locally with make unit

@TRIVENI206
Copy link
Author

I reran REFRESH_GOLDEN=true go test ./test/deployer after clearing the test cache.
The tests pass locally and git status is clean, so there are no additional golden diffs to push.
Let me know if there’s a specific failing file or test in CI you’d like me to update.

@npolshakova
Copy link
Contributor

Look at the diff here: https://github.com/kgateway-dev/kgateway/actions/runs/21636858458/job/62368669512?pr=13439

2026-02-03T16:31:37.2065834Z === �[31mFAIL�[0m: test/helm TestHelmChartTemplate/kgateway/service-full-config (0.06s)
2026-02-03T16:31:37.2066164Z     helm_version_test.go:381: helm template output differs from golden file (-want +got):
2026-02-03T16:31:37.2066268Z           (
2026-02-03T16:31:37.2066382Z           	"""
2026-02-03T16:31:37.2066554Z           	... // 10 identical lines
2026-02-03T16:31:37.2066778Z           	    app.kubernetes.io/name: kgateway
2026-02-03T16:31:37.2067037Z           	    app.kubernetes.io/instance: test-release
2026-02-03T16:31:37.2073988Z         + 	    app.kubernetes.io/component: agentgateway-controller
2026-02-03T16:31:37.2074316Z           	    app.kubernetes.io/version: "0.0.1"
2026-02-03T16:31:37.2074562Z           	    app.kubernetes.io/managed-by: Helm
2026-02-03T16:31:37.2074754Z           	... // 221 identical lines
2026-02-03T16:31:37.2074990Z           	    app.kubernetes.io/name: kgateway
2026-02-03T16:31:37.2075251Z           	    app.kubernetes.io/instance: test-release
2026-02-03T16:31:37.2075599Z         + 	    app.kubernetes.io/component: agentgateway-controller
2026-02-03T16:31:37.2075836Z           	    app.kubernetes.io/version: "0.0.1"
2026-02-03T16:31:37.2076062Z           	    app.kubernetes.io/managed-by: Helm
2026-02-03T16:31:37.2076244Z           	... // 45 identical lines
2026-02-03T16:31:37.2076459Z           	    app.kubernetes.io/name: kgateway
2026-02-03T16:31:37.2076720Z           	    app.kubernetes.io/instance: test-release
2026-02-03T16:31:37.2077052Z         + 	    app.kubernetes.io/component: agentgateway-controller
2026-02-03T16:31:37.2077175Z           	---
2026-02-03T16:31:37.2077441Z           	# Source: kgateway/templates/deployment.yaml
2026-02-03T16:31:37.2077618Z           	... // 8 identical lines
2026-02-03T16:31:37.2077838Z           	    app.kubernetes.io/name: kgateway
2026-02-03T16:31:37.2078226Z           	    app.kubernetes.io/instance: test-release
2026-02-03T16:31:37.2078547Z         + 	    app.kubernetes.io/component: agentgateway-controller
2026-02-03T16:31:37.2078846Z           	    app.kubernetes.io/version: "0.0.1"
2026-02-03T16:31:37.2079075Z           	    app.kubernetes.io/managed-by: Helm
2026-02-03T16:31:37.2079245Z           	... // 5 identical lines
2026-02-03T16:31:37.2079471Z           	      app.kubernetes.io/name: kgateway
2026-02-03T16:31:37.2079732Z           	      app.kubernetes.io/instance: test-release
2026-02-03T16:31:37.2080064Z         + 	      app.kubernetes.io/component: agentgateway-controller
2026-02-03T16:31:37.2080208Z           	  template:
2026-02-03T16:31:37.2080348Z           	    metadata:
2026-02-03T16:31:37.2080517Z           	... // 6 identical lines
2026-02-03T16:31:37.2080752Z           	        app.kubernetes.io/name: kgateway
2026-02-03T16:31:37.2081017Z           	        app.kubernetes.io/instance: test-release
2026-02-03T16:31:37.2081362Z         + 	        app.kubernetes.io/component: agentgateway-controller
2026-02-03T16:31:37.2081492Z           	    spec:
2026-02-03T16:31:37.2081767Z           	      serviceAccountName: test-release-kgateway
2026-02-03T16:31:37.2081946Z           	... // 70 identical lines
2026-02-03T16:31:37.2082128Z           	"""
2026-02-03T16:31:37.2082239Z           )
2026-02-03T16:31:37.2082329Z         
2026-02-03T16:31:37.2082406Z         
2026-02-03T16:31:37.2082646Z         To refresh: REFRESH_GOLDEN=true go test ./test/helm

Again, it should be reproducible by running make unit locally.

Signed-off-by: trivenireddy <triveni@Asus.localdomain>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/feature Categorizes issue or PR as related to a new feature. release-note

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants