konstraint
konstraint copied to clipboard
Add templating support
It would be awesome if we could have a user supplied template for constraints and constrainttemplate.
Mainly this would provide the ability to add custom labels and annotations (which could be added here as well) but probably other settings and variables could be transferred as well.
I think the ability to add labels and annotations make sense. Is this your immediate use case? Is there anything else you're wanting to be able to alter in the constraints and templates?
Ideally, support for a static template so I could render the result and use a helm template (so labels and annotations is a first step, but there might be additional fields that others would want exposed or some yaml preprocessing)
I think we could add support for @label
and @annotation
tags in the header if desired, but if the desire is for a general ability to modify all K8s metadata for the Constraint/ConstraintTemplate then I don't think Konstraint is the tool for that. That sounds like it would be better suited for Kustomize which can patch the resources generated by Konstraint to insert labels, annotations, and any other changes.
I think labels and annotations are a great thing to start with, agreed kustomize is a good solution as well!
Chiming in here, there are some use cases where adding full template support would be preferred over just annotations and labels. Most of this revolves around Gatekeeper's unique way of creating CRDs and how that effects systems that automatically roll out and apply these resources. Example here