konstraint icon indicating copy to clipboard operation
konstraint copied to clipboard

Add templating support

Open mrueg opened this issue 2 years ago • 5 comments

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.

mrueg avatar Feb 11 '22 15:02 mrueg

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?

jpreese avatar Feb 11 '22 17:02 jpreese

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)

mrueg avatar Feb 11 '22 19:02 mrueg

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.

jalseth avatar Feb 13 '22 05:02 jalseth

I think labels and annotations are a great thing to start with, agreed kustomize is a good solution as well!

mrueg avatar Feb 13 '22 18:02 mrueg

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

rossedman avatar Oct 27 '22 16:10 rossedman