Skip to main content

☑️ Ensure workload has valid label values

Labels are nothing more than custom key-value pairs that are attached to objects and are used to describe and manage different Kubernetes resources. If the labels do not follow Kubernetes label syntax requirements (see links below), they will not be applied properly.

info

FYI

Labels' keys and values are case-sensitive!

Targeted resources by this rule (types of kind): Deployment / Pod / DaemonSet / StatefulSet / ReplicaSet / CronJob / Job

Enabled by default? True

Policy as code identifier: WORKLOAD_INVALID_LABELS_VALUE


This rule will fail

If one of the keys under labels contains an invalid value

metadata:
labels:
on-call: yoda@datree.io

Rule output in the CLI

$ datree test *.yaml

>> File: failExample.yaml
❌ Ensure workload has valid label values [1 occurrence]
💡 Incorrect value for key(s) under `labels` - the vales syntax is not valid so the Kubernetes engine will not accept it

How to fix this failure

Use valid values only (see links below for valid syntax)

metadata:
labels:
on-call: yoda-at-datree.io

Read more