- 
                Notifications
    
You must be signed in to change notification settings  - Fork 1.2k
 
Preserve deployment and its template labels and annotations #16199
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
When running `kubectl rollout restart deployment`, Kubernetes adds the `kubectl.kubernetes.io/restartedAt` annotation to the deployment's pod template to trigger a rolling restart. However, Knative's reconciler was removing this annotation by completely replacing the deployment spec, causing new pods to be immediately terminated instead of completing the rollout. This change preserves externally-added metadata at both the deployment level and template level during reconciliation: - Deployment-level labels (was already the case) and annotations (new) - Pod template labels and annotations (e.g., kubectl.kubernetes.io/restartedAt) The fix uses kmeta.UnionMaps to merge desired state with existing state, allowing external annotations/labels to take precedence while still permitting Knative to manage its own metadata. Changes: - cruds.go: Added preservation of deployment and template-level metadata - table_test.go: Added test case to verify external metadata preservation
f079377    to
    7632241      
    Compare
  
    
          Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@            Coverage Diff             @@
##             main   #16199      +/-   ##
==========================================
- Coverage   80.11%   80.08%   -0.03%     
==========================================
  Files         214      214              
  Lines       16940    16945       +5     
==========================================
  Hits        13571    13571              
- Misses       3011     3014       +3     
- Partials      358      360       +2     ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
  | 
    
| 
           LGTM, but I'd like @dprotaso to take a look as well.  | 
    
| 
           /remove-approve Was added automatically as I'm co-release lead.  | 
    
| 
           [APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. 
Needs approval from an approver in each of these files:
 
      Approvers can indicate their approval by writing   | 
    
| 
           /ok-to-test  | 
    
| 
           /hold Will revisit after the release next Tuesday  | 
    
Hi,
when running
kubectl rollout restart deployment, Kubernetes adds thekubectl.kubernetes.io/restartedAtannotation to the deployment's pod template to trigger a rolling restart. However, Knative's reconciler was removing this annotation by completely replacing the deployment spec, causing new pods to be immediately terminated instead of completing the rollout.This change preserves externally-added metadata at both the deployment level and template level during reconciliation:
The fix uses kmeta.UnionMaps to merge desired state with existing state, allowing external annotations/labels to take precedence while still permitting Knative to manage its own metadata.
Changes:
Fixes #14705
Proposed Changes
Release Note
/kind bug
Thanks for the review!