Repository navigation
feat: support custom labels on versioned Deployments - #639
Conversation
|
|
jaypipes
left a comment
There was a problem hiding this comment.
I like it. Thank you @paulhobbel! I'm targeting this for the v1.14.0 release (end of October), just FYI.
|
@paulhobbel You'll need to rebase to main in order to fix the failed e2e tests. |
tomba7
left a comment
There was a problem hiding this comment.
Thanks for putting this together, @paulhobbel!
|
Hi all, will update this PR today |
Add spec.deploymentLabels to WorkerDeployment. The labels are applied to the metadata of each versioned Deployment the controller creates, so tools that act on the Deployment object (admission webhooks that opt workloads in or out by label, cost allocation) can see them. Controller-managed selector labels always win, and a CEL rule rejects attempts to set them. Closes temporalio#187
6f802f6 to
3b7bcb4
Compare
Address review feedback on temporalio#639: - The validating webhook now checks deploymentLabels keys and values with ValidateLabels. Before, an invalid value such as "foo bar" passed admission and the controller then failed to create the versioned Deployment. - Label changes are applied in place to the Deployments of every version the controller manages, in the same write as the strategy sync, without restarting pods. The keys the controller applied are recorded in the temporal.io/managed-deployment-labels annotation, so a key removed from the spec is removed from the Deployments while labels added by other tools are kept. Amp-Thread-ID: https://ampcode.com/threads/T-01a1548c-55d5-7376-87f5-86064575b53a Co-authored-by: Paul Hobbel <paul@enapi.com>
jaypipes
left a comment
There was a problem hiding this comment.
One small bug I think I've uncovered @paulhobbel but overall this is great, thank you so much for this PR!
Address review feedback on temporalio#639: - The validating webhook now checks deploymentLabels keys and values with ValidateLabels. Before, an invalid value such as "foo bar" passed admission and the controller then failed to create the versioned Deployment. - Label changes are applied in place to the Deployments of every version the controller manages, in the same write as the strategy sync, without restarting pods. The keys the controller applied are recorded in the temporal.io/managed-deployment-labels annotation, so a key removed from the spec is removed from the Deployments while labels added by other tools are kept.
f942c28 to
cc3e43c
Compare
Address review feedback on temporalio#639: - The validating webhook now checks deploymentLabels keys and values with ValidateLabels. Before, an invalid value such as "foo bar" passed admission and the controller then failed to create the versioned Deployment. - Label changes are applied in place to the Deployments of every version the controller manages, in the same write as the strategy sync, without restarting pods. The keys the controller applied are recorded in the temporal.io/managed-deployment-labels annotation, so a key removed from the spec is removed from the Deployments while labels added by other tools are kept.
cc3e43c to
c34260f
Compare
Address review feedback on temporalio#639: - The validating webhook now checks deploymentLabels keys and values with ValidateLabels. Before, an invalid value such as "foo bar" passed admission and the controller then failed to create the versioned Deployment. - Label changes are applied in place to the Deployments of every version the controller manages, in the same write as the strategy sync, without restarting pods. The keys the controller applied are recorded in the temporal.io/managed-deployment-labels annotation, so a key removed from the spec is removed from the Deployments while labels added by other tools are kept.
c34260f to
b92ea9f
Compare
jaypipes
left a comment
There was a problem hiding this comment.
Great stuff @paulhobbel thank you!
|
Hi @jaypipes it looks like I still need to accept the license. However, I already did and if I try to accept again it gives me an error |
Nah, it's just a flaky issue with the CLA assistant thing :) I'll update the branch to main HEAD which should (hopefully) kick the CLA job into action... |
What was changed
Adds
spec.deploymentLabelstoWorkerDeployment. The controller copies these labels onto the metadata of each versioned Deployment it creates.temporal.io/build-idandtemporal.io/deployment-name.temporal.io/managed-deployment-labelsannotation, so removing a key fromdeploymentLabelsremoves it from the Deployments, while labels added by other tools are kept.Why?
Today the generated Deployment only carries
temporal.io/build-idandtemporal.io/deployment-name. Labels in the pod template reach the pods, but tools that act on the Deployment object itself never see them. The case we hit: an admission webhook that opts workloads out by a label on the Deployment. It couldn't see the opt-out, so it instrumented the versioned Deployments and rewrote their pod template.I chose an explicit field over copying the WorkerDeployment's own
metadata.labels. Those often carry GitOps tracking labels (e.g. Argo CD'sapp.kubernetes.io/instance) or kustomizecommonLabels. Copying them would make controller-owned Deployments look like resources managed by the GitOps tool, which can then report them as out of sync or prune them.Checklist
Closes [Feature Request] Support custom labels on generated Kubernetes Deployment resources #187
How was this tested:
ApplyDeploymentLabels: adding labels to existing Deployments, changing and removing keys, keeping labels from other tools, never touching selector labels, and no change when in sync.NewDeploymentWithOwnerRef: labels land on the Deployment, not on the pods or the selector, and selector keys win on conflict.make generate manifests,make test-unitandmake lint-codepass locally.Any docs updates needed?
Added a "Labels on versioned Deployments" section to
docs/configuration.md.🤖 Generated with Claude Code