Reputation: 3205
According to Kubebuilder documentation, it is possible to implement immutable fields for a given CRD:
We separate out ValidateCreate from ValidateUpdate to allow behavior like making certain fields immutable, so that they can only be set on creation.
Would some of you have some examples or code samples about implementing this?
Upvotes: 0
Views: 1488
Reputation: 559
Using the Kubebuilder example:
func (r *CronJob) ValidateUpdate(old runtime.Object) error {
oldCronJob, _ := old.(*CronJob)
if r.Spec.ImmutableField != oldCronJob.Spec.ImmutableField {
// accumulate errors
}
...
// return all errors
}
Upvotes: 2