Open voor opened 2 years ago
Hello @voor! Welcome to the Cartographer community and thank you for opening your first issue, we appreciate your contributions
@voor Can you accomplish what you want by leveraging params in your workload?
E.g. instead of this workload (which is not possible today):
kind: Workload
metadata:
name: example
spec:
iAmBadAtNamingThingsLabels:
bob: alice
another: example
Use this workload (which is possible today):
kind: Workload
metadata:
name: example
spec:
params:
iAmBadAtNamingThingsLabels:
bob: alice
another: example
I should probably preference this with the fact I'm not a ClusterSourceTemplate author, so while it might be possible in Cartographer, it would need to be better advertised to creators of those templates that label propagation is something that should be added and supported. It might be easier to explicitly put something like that into Cartographer, though.
I'm in favor of propagating all labels from the parent (Workload) resource down to the resources stamped out by a Cartographer template. This is easy for the .metadata.labels
because they are in a common location for every k8s resource. However, this becomes trickier when your resource is a Deployment and you also want the labels to end up on the Pod. In that case the labels need to be set at .spec.template.spec.metadata.labels
(in addition to .metadata.labels
). But for a CronJob, that location changes to .spec.jobTemplate.spec.template.metadata.labels
. Other resources could be yet more different.
Long story short, the component template needs to participate in where the labels land on the stamped resource. What could be helpful is for Cartographer to compute the set of labels it thinks should be applied to the resource (parent labels +. cartographer labels) and pass those as part of the template context to the stamper. The template can decide how to apply the labels. The stamper can follow up to define/override an "essential" set of labels on .metadata.labels
as it sees fit; similar to setting .metadata.ownerReferences
, or how labels are applied today.
Description of problem
The Cartographer workload creates a whole host of other objects based on the clustersupplychains, this results in lots of objects that correctly have the owner references:
And have cartographer's labels:
But I want to put my own propagated labels, specifically from the workload:
I am able to use ownershiplabelrules so Cartographer does not need to take the labels from the workload metadata. (It can, if that makes sense to you, but I don't want to restrict that line of thinking)
Proposed solution
<Please describe your proposed solution, preferably in the following style:>
Example
For example, if I was to have:
Then an implementation of
ClusterSourceTemplate
could do something like this:(this is quasicode it's really not tested or functional)
Additional Context
I would like to be able to see all objects associated with a Workload using kapp inspect.