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

[processor/k8sattributes] Allow adding custom attributes from the ownerReferences chain #25837

Closed
kamalmarhubi opened this issue Aug 16, 2023 · 3 comments
Labels
closed as inactive enhancement New feature or request needs triage New item requiring triage processor/k8sattributes k8s Attributes processor Stale

Comments

@kamalmarhubi
Copy link
Contributor

kamalmarhubi commented Aug 16, 2023

Component(s)

processor/k8sattributes

Is your feature request related to a problem? Please describe.

We use Argo Rollouts to allow us to do canary deployments. There are effectively a replacement for the Deployment resource, but with some additional control over the rollout process. Under the hood it works similarly to the Deployment controller: it creates ReplicaSets and adjusts their relative sizes; it just uses different criteria for making those adjustments.

Until #14003, the k8sattributeprocessor happily put the rollout's name in the k8s.deployment.name attribute, because the deployment name was based on a regex of the replicaset name. This wasn't exactly accurate, but it was definitely handy to have a common attribute across pods belonging to a Rollout.

We haven't upgraded yet, but when we do this change will mean we lose this common attribute for pods in our lower-case-deployments, which are Rollouts instead of Deployments.

Describe the solution you'd like

I'd like to be able to configure the processor to add the name of a specific resource kind in the ownerRef chain. For my example of a Rollout, I'm imagining adding an PodOwners along side Metadata, Labels, and Annotations in the ExtractConfig.

The semantics would be to follow ownerReferences from the pod, and if one matches the configured api version and kind, add its name and/or uid as an attribute.

This would mean my Rollout example could look like

k8sattributes:
  # [...]
  extract:
    metadata:
    - k8s.pod.name
    - k8s.pod.uid
    - k8s.deployment.name
    - k8s.namespace.name
    - k8s.node.name
    - k8s.pod.start_time
    pod_owners:
    - tag_name_prefix: argocd.rollout
      api_version: argoproj.io/v1alpha1
      kind: Rollout
      attributes:
      - name
      - uid

or some similar alternative, eg require the .uid and .name fields to be listed individually:

    pod_owners:
    - tag_name: argocd.rollout.name
      api_version: argoproj.io/v1alpha1
      kind: Rollout
      metadata_field: name
    - tag_name: argocd.rollout.uid
      api_version: argoproj.io/v1alpha1
      kind: Rollout
      metadata_field: uid

I'm not sure if it's necessary to allow arbitrarily long ownerReferences chains. For Rollouts, it happens to have the same number of levels as Deployments (pod -> replicaset -> "real owner"). But if someone were using Flagger, then it manages a pair of deployments rather than managing replicasets directly, so the chain to the Canary object is pod -> replicaset -> deployment -> Canary.

Describe alternatives you've considered

The main alternatives I see are:

Additional context

There's some conversation in #23067 which is slightly relevant but doesn't get in the way of implementing this. The suggestion there is to stop tracking replicasets, and instead walk the ownerReferences chain from the pod directly, storing the replicasets' deployment metadata in an LRU cache.

@kamalmarhubi kamalmarhubi added enhancement New feature or request needs triage New item requiring triage labels Aug 16, 2023
@github-actions github-actions bot added the processor/k8sattributes k8s Attributes processor label Aug 16, 2023
@github-actions
Copy link
Contributor

Pinging code owners:

See Adding Labels via Comments if you do not have permissions to add labels yourself.

@github-actions
Copy link
Contributor

This issue has been inactive for 60 days. It will be closed in 60 days if there is no activity. To ping code owners by adding a component label, see Adding Labels via Comments, or if you are unsure of which component this issue relates to, please ping @open-telemetry/collector-contrib-triagers. If this issue is still relevant, please ping the code owners or leave a comment explaining why it is still relevant. Otherwise, please close it.

Pinging code owners:

See Adding Labels via Comments if you do not have permissions to add labels yourself.

Copy link
Contributor

This issue has been closed as inactive because it has been stale for 120 days with no activity.

@github-actions github-actions bot closed this as not planned Won't fix, can't repro, duplicate, stale Dec 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
closed as inactive enhancement New feature or request needs triage New item requiring triage processor/k8sattributes k8s Attributes processor Stale
Projects
None yet
Development

No branches or pull requests

1 participant