Gotta say that I had to jump multiple hoops but I documented the entire step-by-step.
This will be possibly a series of tutorials because I need to create multiple versions of the same API Group to support the work I am contributing to Project Velero.
Very well, in a nutshell, the tutorial creates the following:
$ kubectl get crd rockbands.music.example.io NAME CREATED AT rockbands.music.example.io 2020-10-28T19:51:25Z
Spec of the CRD:
Webhook Mutator Logic:
- if LeadSinger is not specified, set it as "TBD".
- if RockBand CR name is "beatles" and Lead Singer is "John", set it to "John Lennon" Webhook
- We can't create RockBands CRs on "kube-system" namespace
- We can't update Lead Singer as "John" if RockBand CR name is "beatles"
- We can't update Lead Singer as "Ringo" if RockBand CR name is "beatles".
Again, the link to the tutorial and code:
Enjoy!! And comments are appreciated!!