Skip to content

Conversation

@salonichf5
Copy link
Contributor

Cherry-pick for #4468

Problem: Users want that deployments and daemonSet preserve external annotations like how we do for services

Solution: Adds a solution to track internal annotations and preserver external annotations.

Testing: I verified the behavior by manually adding an annotation to both to deployment and waiting if controller overwrites it and watching the generation

kubectl annotate deploy gateway-nginx \
  field.cattle.io/publicEndpoints='[{"addresses":["x"],"port":80}]' --overwrite
deployment.apps/gateway-nginx annotated


 kubectl describe deploy gateway-nginx | sed -n '/Annotations:/,/Selector:/p'

Annotations:            deployment.kubernetes.io/revision: 1
                        field.cattle.io/publicEndpoints: [{"addresses":["x"],"port":80}]
Selector:               app.kubernetes.io/instance=nginx-gateway,app.kubernetes.io/managed-by=nginx-gateway-nginx,app.kubernetes.io/name=gateway-nginx,gateway.networking.k8s.io/gateway-name=gateway
  Annotations:      prometheus.io/port: 9113
                    prometheus.io/scrape: true

kubectl get deploy gateway-nginx -o jsonpath="{.metadata.generation}  {.metadata.resourceVersion}  {.metadata.annotations.field\.cattle\.io/publicEndpoints}{\"\n\"}" --watch
2  2046  [{"addresses":["x"],"port":80}]

Daemonset

 kubectl annotate daemonsets.apps gateway-nginx \ 
  field.cattle.io/publicEndpoints='[{"addresses":["x"],"port":80}]' --overwrite
daemonset.apps/gateway-nginx annotated

kubectl describe daemonsets.apps gateway-nginx | sed -n '/Annotations:/,/Selector:/p' 
Annotations:    deprecated.daemonset.template.generation: 1
                field.cattle.io/publicEndpoints: [{"addresses":["x"],"port":80}]
Desired Number of Nodes Scheduled: 1
Current Number of Nodes Scheduled: 1

controller  Created pod: gateway-nginx-gdvd7
sa.choudhary@N9939CQ4P0 nginx-gateway-fabric % kubectl get daemonsets.apps gateway-nginx -o jsonpath="{.metadata.generation}  {.metadata.resourceVersion}  {.metadata.annotations.field\.cattle\.io/publicEndpoints}{\"\n\"}" --watch 
1  26427  [{"addresses":["x"],"port":80}]

Please focus on (optional): If you any specific areas where you would like reviewers to focus their attention or provide
specific feedback, add them here.

Closes #4447

Checklist

Before creating a PR, run through this checklist and mark each as complete.

  • I have read the CONTRIBUTING doc
  • I have added tests that prove my fix is effective or that my feature works
  • I have checked that all unit tests pass after adding my changes
  • I have updated necessary documentation
  • I have rebased my branch onto main
  • I will ensure my PR is targeting the main branch and pulling from my branch from my own fork

Release notes

If this PR introduces a change that affects users and needs to be mentioned in the release notes,
please add a brief note that summarizes the change.

Fixes a bug to preserve external controller annotations for Deployment and DaemonSets to avoid constant updates. 

…#4468)

Problem: Users want that deployments and daemonSet preserve external annotations like how we do for services

Solution: Adds a solution to track internal annotations and preserver external annotations.
@salonichf5 salonichf5 requested a review from a team as a code owner December 16, 2025 21:28
@github-actions github-actions bot added the bug Something isn't working label Dec 16, 2025
@salonichf5 salonichf5 enabled auto-merge (squash) December 16, 2025 21:29
@codecov
Copy link

codecov bot commented Dec 16, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 86.22%. Comparing base (0cd966b) to head (413c24e).
⚠️ Report is 1 commits behind head on release-2.3.

Additional details and impacted files
@@             Coverage Diff              @@
##           release-2.3    #4473   +/-   ##
============================================
  Coverage        86.21%   86.22%           
============================================
  Files              132      132           
  Lines            14557    14560    +3     
  Branches            35       35           
============================================
+ Hits             12551    12554    +3     
  Misses            1792     1792           
  Partials           214      214           

☔ View full report in Codecov by Sentry.
📢 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.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@salonichf5 salonichf5 merged commit 15d7261 into release-2.3 Dec 16, 2025
98 of 101 checks passed
@salonichf5 salonichf5 deleted the bug/preserver-annotations-deployments branch December 16, 2025 22:18
@github-project-automation github-project-automation bot moved this from 🆕 New to ✅ Done in NGINX Gateway Fabric Dec 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working release-notes

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

4 participants