✨ Tag Controller CRD, Controller & Webhooks - #1865
Conversation
1ad11fd to
ab81886
Compare
2e1c8e8 to
cba1e09
Compare
Minimum allowed line rate is |
| // both operations are denied, which wedges owner-reference cleanup and | ||
| // namespace termination respectively. | ||
| var allowedSystemAccountsForTag = map[string]struct{}{ | ||
| "system:serviceaccount:kube-system:generic-garbage-collector": {}, |
There was a problem hiding this comment.
Is this defined elsewhere in upstream k8s/k8s so we don't have to have strings here? There's also a worry of these service accounts changing which may break this code.
There was a problem hiding this comment.
We have a bunch of similar strings defined in webhooks/persistentvolumeclaim/validation/persistentvolumeclaim_validator.go
| // validateLabelKey requires spec.key to be non-empty and a valid | ||
| // Kubernetes label key. | ||
| func validateLabelKey(key string) field.ErrorList { | ||
| return unversionedvalidation.ValidateLabelName(key, specKeyPath) | ||
| } | ||
|
|
||
| // validateLabelValue requires spec.value to be a valid Kubernetes label | ||
| // value. An empty value is permitted. | ||
| func validateLabelValue(value string) field.ErrorList { | ||
| var fieldErrs field.ErrorList | ||
| for _, msg := range utilvalidation.IsValidLabelValue(value) { | ||
| fieldErrs = append(fieldErrs, field.Invalid(specValuePath, value, msg)) | ||
| } | ||
|
|
||
| return fieldErrs | ||
| } |
There was a problem hiding this comment.
Why not use https://pkg.go.dev/k8s.io/apimachinery@v0.37.0/pkg/apis/meta/v1/validation#ValidateLabels?
That seems to combine both of these?
There was a problem hiding this comment.
There is separate validation as the spec contains spec.key & spec.value.
The fieldPath argument accepts a single path.
| } | ||
| }() | ||
|
|
||
| return r.ReconcileNormal(ctx, &obj) |
There was a problem hiding this comment.
Hmm. Shouldn't we handle Tags that are marked for deletion (e.g., a non-zero DeletionTimestamp)?
There was a problem hiding this comment.
Tags are garbage collected. Do you think we still need explicit deletion?
cba1e09 to
416f92b
Compare
416f92b to
8e1f341
Compare
What does this PR do, and why is it needed?
Add Tag CRD, controller, and webhook for VM tagging
Add a new Tag CRD (vsphere.policy.vmware.com/v1alpha1) with a
controller and a validating webhook. A Tag stands for one vCenter
tag (a key/value pair) used for VM affinity. It is owned by one or
more VirtualMachines. The controller marks a Tag Ready, copies its
key/value onto labels, and deletes the Tag once all owners are gone.
Which issue(s) is/are addressed by this PR? (optional, in
fixes #<issue number>(, fixes #<issue_number>, ...)format, will close the issue(s) when PR gets merged):Fixes # vmop-3882
Are there any special notes for your reviewer: NA
Please add a release note if necessary: