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

feat: implement support for podOptions and additionalMetadata #871

Merged
merged 7 commits into from
Nov 24, 2023

Conversation

gchiesa
Copy link
Contributor

@gchiesa gchiesa commented Oct 28, 2023

This PR implements the support for additionalMetadata enforced on Pods, similarly to the additionalMetadata for services.

Rationale

In the context of soft-tenancy model, a practical use-case is represented by the need to enforce annotations / labels on Pods so that the information captured by shared cluster level services can be enriched with Tenant domain metadata (e.g. tenant-id, cost-center, etc.)

A practical use-case 1: Scalyr/Dataset Logs

Logging agents are deployed in a cluster governed by Capsule. Multiple tenants are present. Our requirement is to be able to query logs captured from pods part of a specific tenant.
Scalyr offers the possibility to enrich the logs captured from each Pod by leveraging annotations.

With this functionality Pod will be automatically annotated with the information decided by cluster administrator. This will offer the possibility to categorize/query logs by tenant attributes.

A practical use-case 2: Prometheus Metrics

Similarly to the use case above, also prometheus metrics can be enriched with tenant level attributes that will translate in meta labels.

With this functionality and using a proper Prometheus relabeling configuration the pod label/annotation can be translated in metric attributes attached to the specific pod.

How To

Cluster administrators can configure the annotation/labels for the Pods created under a specific tenancies by using the following:

apiVersion: capsule.clastix.io/v1beta2
kind: Tenant
metadata:
  name: oil
spec:
  owners:
    - name: alice
      kind: User
  podOptions:
    additionalMetadata:
      annotations:
        # example for scalyr logging
        log.config.scalyr.com/attributes.tenant-name: oil
      labels:
        tenant-name: oil
        tenant-cost-center: "12345"
        slack: #oil-notifications

References

closes #756

@netlify
Copy link

netlify bot commented Oct 28, 2023

Deploy Preview for capsule-documentation canceled.

Name Link
🔨 Latest commit c4fdcef
🔍 Latest deploy log https://app.netlify.com/sites/capsule-documentation/deploys/655f5b39c0e18300089fd9ff

@oliverbaehler oliverbaehler self-requested a review October 28, 2023 18:29
Copy link
Collaborator

@oliverbaehler oliverbaehler left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your awesome pr, generally it looks good to me. We will have to discuss, if it would also make sense to implement #737 along-side with this feature. WDYT @prometherion

Please sign of all your commits.

Makefile Outdated Show resolved Hide resolved
@gchiesa gchiesa force-pushed the pod-labels-support branch 2 times, most recently from 75f4266 to 8505be4 Compare October 30, 2023 15:49
@gchiesa gchiesa requested a review from oliverbaehler October 30, 2023 16:45
Copy link
Member

@prometherion prometherion left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM as a contribution, just let's try to address the comments! 🚀

Makefile Outdated Show resolved Hide resolved
api/v1beta2/tenant_types.go Outdated Show resolved Hide resolved
pkg/api/pod_options.go Outdated Show resolved Hide resolved
controllers/podlabels/abstract.go Outdated Show resolved Hide resolved
controllers/podlabels/pod.go Outdated Show resolved Hide resolved
@gchiesa gchiesa force-pushed the pod-labels-support branch 8 times, most recently from cd3af1c to ee5662c Compare November 23, 2023 07:23
prometherion and others added 7 commits November 23, 2023 15:00
Signed-off-by: Dario Tranchitella <[email protected]>
Co-authored-by: Giuseppe Chiesa <[email protected]>
Signed-off-by: Dario Tranchitella <[email protected]>
Co-authored-by: Giuseppe Chiesa <[email protected]>
Signed-off-by: Dario Tranchitella <[email protected]>
Co-authored-by: Giuseppe Chiesa <[email protected]>
Signed-off-by: Dario Tranchitella <[email protected]>
Co-authored-by: Giuseppe Chiesa <[email protected]>
Signed-off-by: Dario Tranchitella <[email protected]>
Co-authored-by: Giuseppe Chiesa <[email protected]>
Signed-off-by: Dario Tranchitella <[email protected]>
Co-authored-by: Giuseppe Chiesa <[email protected]>
Signed-off-by: Dario Tranchitella <[email protected]>
Co-authored-by: Giuseppe Chiesa <[email protected]>
@prometherion prometherion changed the title feat(manager): implement support for podOptions and additionalMetadata feat: implement support for podOptions and additionalMetadata Nov 23, 2023
Copy link
Member

@prometherion prometherion left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @gchiesa for nailing this, as we agreed I helped in some refactoring of your code, this is the stepping stone for the v0.5.0 release!

@prometherion prometherion merged commit 8695dfb into projectcapsule:main Nov 24, 2023
24 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Feature: additional pod metadata
3 participants