Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

propagate labels to deployments and pods #2446

Closed
lburgazzoli opened this issue Jun 24, 2021 · 8 comments · Fixed by #2609
Closed

propagate labels to deployments and pods #2446

lburgazzoli opened this issue Jun 24, 2021 · 8 comments · Fixed by #2609
Assignees
Labels
area/managed-service Camel K as a Managed Service area/observability Logging, monitoring and tracing
Milestone

Comments

@lburgazzoli
Copy link
Contributor

lburgazzoli commented Jun 24, 2021

I've configured a KameletBinding to propagate some labels to generated resources, ad that work till the Integration:

➜ k get KameletBinding/c6911f7b28b7443f090b779dfcc404a90 --show-labels 
acme.com/my-label.generated=true,acme.com/my-label.id=1uPZZ2GK5dNNY87It5oa3AwEOxE,acme.com/my-label.operator=camel-k,acme.com/my-label.type.id=log

➜ k get Integration/c6911f7b28b7443f090b779dfcc404a90 --show-labels 
acme.com/my-label.generated=true,acme.com/my-label.id=1uPZZ2GK5dNNY87It5oa3AwEOxE,acme.com/my-label.operator=camel-k,acme.com/my-label.type.id=log

Those labels are then not propagated down to the POD:

➜ k get Pod/c6911f7b28b7443f090b779dfcc404a90-844d994877-vcxgn --show-labels 
camel.apache.org/integration=c6911f7b28b7443f090b779dfcc404a90,pod-template-hash=844d994877

it would be nice to get such labels propagated to each direct or indirect generated resource

@lburgazzoli
Copy link
Contributor Author

/cc @astefanutti @nicolaferraro

@lburgazzoli lburgazzoli added area/managed-service Camel K as a Managed Service area/observability Logging, monitoring and tracing labels Jun 24, 2021
@nicolaferraro nicolaferraro added this to the 1.5.0 milestone Jun 25, 2021
@nicolaferraro
Copy link
Member

I think there's a trait to control that: owner.target-labels...
May we change the default to transfer them all?

@lburgazzoli
Copy link
Contributor Author

This stops at the Integration level, pods and deployment does not have such labels propagated (unless I missed something)

@nicolaferraro nicolaferraro modified the milestones: 1.5.0, 1.6.0 Jul 5, 2021
@squakez
Copy link
Contributor

squakez commented Aug 30, 2021

The correct way to have it working with the actual owner trait is the following one:

apiVersion: camel.apache.org/v1alpha1
kind: KameletBinding
...
metadata:
...
  labels:
    my-key: my-val
    ...
  annotations:
    trait.camel.apache.org/owner.target-labels: "my-key"
k get pod --show-labels -n operator-test
NAME                            READY   STATUS    RESTARTS   AGE   LABELS
timer-to-log-686fc7f567-gfhb6   1/1     Running   0          8s    camel.apache.org/integration=timer-to-log,my-key=my-val,pod-template-hash=686fc7f567

Basically we need to specify in the KameletBinding which labels (and/or annotations) we want to have in the underlying Pod.

In the KameletBinding usage, I think it's a bit cumbersome as we need to re-declare a list of variables we already defined. In my opinion we should add a owner.target-labels-all to cover the generic usage of including all labels/annotations. We can also consider if the default for the KameletBinding is to use the owner trait, so the user won't have to bother to configure (he can disable by turning enabled=false).

@lburgazzoli
Copy link
Contributor Author

The correct way to have it working with the actual owner trait is the following one:

apiVersion: camel.apache.org/v1alpha1
kind: KameletBinding
...
metadata:
...
  labels:
    my-key: my-val
    ...
  annotations:
    trait.camel.apache.org/owner.target-labels: "my-key"
k get pod --show-labels -n operator-test
NAME                            READY   STATUS    RESTARTS   AGE   LABELS
timer-to-log-686fc7f567-gfhb6   1/1     Running   0          8s    camel.apache.org/integration=timer-to-log,my-key=my-val,pod-template-hash=686fc7f567

Basically we need to specify in the KameletBinding which labels (and/or annotations) we want to have in the underlying Pod.

This is what I did in my set-up but was based on an 1.4 version so it may have been solved, need to re-test.

In the KameletBinding usage, I think it's a bit cumbersome as we need to re-declare a list of variables we already defined. In my opinion we should add a owner.target-labels-all to cover the generic usage of including all labels/annotations. We can also consider if the default for the KameletBinding is to use the owner trait, so the user won't have to bother to configure (he can disable by turning enabled=false).

copying all the labels/annotations by default is a little bit risky imho, may be nice to have some support for regexp

@squakez
Copy link
Contributor

squakez commented Aug 30, 2021

Yes, I've tested with 1.5, so probably it was a bug in 1.4. Let me know if upgrading version fixes for you as well.

@squakez squakez self-assigned this Aug 30, 2021
@squakez
Copy link
Contributor

squakez commented Aug 30, 2021

I managed to reproduce in 1.5 as well. Likely the problem is because of the syntax expected by the array values. It expects to be like trait.camel.apache.org/owner.target-labels: "[\"my-key.1\", \"my-key.2\"]". I'm adding a note to have it correctly documented, in the while, please @lburgazzoli confirm if that fixes the problem.

squakez added a commit to squakez/camel-k that referenced this issue Aug 30, 2021
@lburgazzoli
Copy link
Contributor Author

@squakez yes, using "array" seems to work

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/managed-service Camel K as a Managed Service area/observability Logging, monitoring and tracing
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants