Labels and Selectors¶
Labels are key/value pairs that are attached to Kubernetes objects, such as pods (this is usually done indirectly via deployments). Labels are intended to be used to specify identifying attributes of objects that are meaningful and relevant to users. Labels can be used to organize and to select subsets of objects. See Labels and Selectors in the Kubernetes documentation for more information.
The following Kubernetes labels have a defined meaning in our Zalando context:
- Application ID as defined in our Kio application registry. Example: “zmon-controller”
- User-defined application version. This is used as input for the CI/CD pipeline and usually references a Docker image tag. Example: “cd53”
- Incrementing release counter. This is generated by the CI/CD pipeline and is used for traffic switching. Example value: “4”
- Deployment stage to allow canary deployments. Allowed values are “canary” and “production”.
- Owner of the Kubernetes resource. This needs to reference a valid organizational entity in the context of the cluster’s business partner. Example value: “team/eagleeye”
Some labels are required for every deployment resource:
Example deployment metadata:
metadata: labels: application: my-app version: "v31" release: "r42" stage: production
Kubernetes services will usually select only on
kind: Service apiVersion: v1 metadata: name: my-app spec: selector: application: my-app stage: production ports: - port: 80 targetPort: 8080 protocol: TCP
You can always define additional custom labels as long as they don’t conflict with the above label catalog.