Skip to content

Label Pods of Managed Deployments #81

@axisofentropy

Description

@axisofentropy

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: "user+uffizzi@example.com"
  • 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status

    Backlog

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions