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

Feature request: Map k8s pod labels as project tags #172

Closed
muellerst-hg opened this issue Sep 11, 2022 · 5 comments
Closed

Feature request: Map k8s pod labels as project tags #172

muellerst-hg opened this issue Sep 11, 2022 · 5 comments
Labels
kind/feature Categorizes issue or PR as related to a new feature.
Milestone

Comments

@muellerst-hg
Copy link
Contributor

As a System Operator,
I would like to add pod labels as project tags in DependencyTrack
So that grouping/filtering by label in dtrack is possible

Background: We use k8s pod labels to determine and group things like application, stage, department, ...

Given the following deployment was applied to k8s cluster:
  ---
  apiVersion: apps/v1
  kind: Deployment
  metadata:
    name: dependencytrack-frontend
    namespace: dependencytrack-sales-live
  spec:
    template:
        metadata:
          labels:
            app=dependencytrack
            stage=live
            department=sales
            service=inventory
        spec:
          containers:
            - name: dependencytrack-frontend
              image: dependencytrack-frontend:4.5.1
  ---
When the sbom-operator scans the pod and adds the project to dtrack
Then the following tags should be added to dtrack:
  [namespace=dependencytrack-sales-live, app=dependencytrack, stage=live, department=sales, ...]
But currently only the following tags are added:
  [namespace=dependencytrack-sales-live, ...]

What do you think about the idea of adding Labels map[string]string to struct libk8s.PodInfo and allow custom mapping of labels to dtrack project tags?
What would be an appropriate way to configure the custom mapping?

sbom-operator is awesome. Thank you!

@muellerst-hg muellerst-hg changed the title Feature request: Add selected k8s labels as project tags Feature request: Add selected k8s pod labels as project tags Sep 11, 2022
@muellerst-hg muellerst-hg changed the title Feature request: Add selected k8s pod labels as project tags Feature request: Map k8s pod labels as project tags Sep 11, 2022
@ckotzbauer ckotzbauer added kind/feature Categorizes issue or PR as related to a new feature. target/dtrack labels Sep 11, 2022
@ckotzbauer
Copy link
Owner

Hi @muellerst-hg,
thanks for your request. Sure, the Dependency Track integration can be extended with the pod-labels as you specified.
What do you mean with "custom mapping"? Can you give a few more details about this?

@muellerst-hg
Copy link
Contributor Author

muellerst-hg commented Sep 11, 2022

Maybe "custom mapping" isn't the right term.

Given I have the following labels:
  spec:
    template:
        metadata:
          labels:
            app=dependencytrack
            stage=live
            department=sales
            service=inventory
            pod-template-hash=12c5401afc
And I have selected "app" and "stage" as labels to be added as tags
Then the following project tags should be added to dtrack
    app=dependencytrack
    stage=live

@muellerst-hg
Copy link
Contributor Author

With two labels "app=dependencytrack" and "app=nginx", some magic would be required to identify both by matching "app" left of the equals sign.

@muellerst-hg
Copy link
Contributor Author

A user could provide a regex for matching labels like SBOM_DTRACK_LABEL_TAG_MATCHER="^(?:app|stage)="

@ckotzbauer
Copy link
Owner

ckotzbauer commented Sep 12, 2022

I got it, you want to control which pod-labels should be mapped to Dependency Track.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/feature Categorizes issue or PR as related to a new feature.
Projects
None yet
Development

No branches or pull requests

2 participants