I created an CRD
like this:
import v1 "k8s.io/api/core/v1"
type ApplicationSpec struct {
Name string `json:"name"`
PodSpec v1.PodSpec `json:"podSpec"`
...
}
notice that I reused PodSpec
from core apigroup in my CRD
To avoid user apply invalid yaml files, I decided to add validation logic in my CRD controller, for simple fields like Name
, it’s easy to check it’s correctness using regex, while for complex and native kind like PodSpec
, since k8s already have validation logic for that, I feel the right way is reuse that in my controller, but how can I do that?