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

Label Pods of Managed Deployments #81

Open
axisofentropy opened this issue May 31, 2023 · 2 comments
Open

Label Pods of Managed Deployments #81

axisofentropy opened this issue May 31, 2023 · 2 comments

Comments

@axisofentropy
Copy link
Member

axisofentropy commented May 31, 2023

We're currently adding just a couple labels to Pods specified by customer Deployments.

Labels: map[string]string{
"app": deploymentName,
"app.kubernetes.io/managed-by": global.Settings.ManagedApplication,
},

We'd like to add some additional labels that can be used to later do more useful reporting.

Some suggestions and example values:

  • app.uffizzi.com/project-id: "3255"
  • app.uffizzi.com/project-name: "Example Project"
  • app.uffizzi.com/account-id: "3306"
  • app.uffizzi.com/account-name: "Example Account"
  • app.uffizzi.com/user-id: "3465" (value of deployments.deployed_by_id)
  • app.uffizzi.com/user-email: "[email protected]"
  • app.uffizzi.com/deployment-id: "25505"
  • app.uffizzi.com/compose-file-id: "38128"
  • app.uffizzi.com/deployment-metadata: '{"labels": {"gitlab": {"repo": "example/apps/example", "merge_request": {"number": "2666"}}}}'

Note that all values are strings, not numbers!

This info should probably be accepted by the existing ApplyContainers endpoint

func (h *Handlers) handleApplyContainers(w http.ResponseWriter, r *http.Request) {

But I think it should be optional. If this new information is not passed to the HTTP API endpoint, or if any values are "", then we should not add the labels to the Pod template.

I'd love to see some GitHub and GitLab metadata too but that's less important and I'm not sure what the best schema would be. If we include this, we should probably copy this schema from flux, argocd, or someone else who's similarly automating.

This will enable new reporting use cases like:

  • Replacing my clunky Python script and its many queries for customer usage with a single BigQuery query.
  • Probably excluding container logs for specific projects?
  • Other reporting without referencing our Postgres database at all, only querying the k8s Cluster or our cloud infrastructure provider.
@axisofentropy
Copy link
Member Author

If getting or applying any of those values is difficult, just skip them! Literally anything will be better than what we have now.

@axisofentropy
Copy link
Member Author

axisofentropy commented Jun 13, 2023

Note that in addition to the label keys, values also have a restricted character set, so we'll probably need to modify them before use. https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/#syntax-and-character-set

Valid label value:

  • must be 63 characters or less (can be empty),
  • unless empty, must begin and end with an alphanumeric character ([a-z0-9A-Z]),
  • could contain dashes (-), underscores (_), dots (.), and alphanumerics between.

Or maybe base64 encode some of them? But probably not. Emails are right out tho.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Backlog
Development

No branches or pull requests

1 participant