☑️ Ensure resource has a configured name
metadata.generateName is a mandatory property in every K8s resource type.
Validation that this property exists occurs is on the k8s server-side only, and is not enforced as part of the official schema.
Therefore, a YAML without this property will pass k8s schema validation, but will fail when pushed into a cluster (i.e. when running kubectl apply/create).
Targeted objects by this rule (types of
Complexity: medium (What does this mean?)
Policy as code identifier: RESOURCE_MISSING_NAME
This rule will fail
If a resource does not contain one of the propreties
Rule output in the CLI
$ datree test *.yaml
>> File: failExample.yaml
❌ Ensure resource has a configured name [1 occurrence]
💡 Missing key `name` or `generateName` - one of them must be set to apply resource to a cluster
How to fix this failure
generateName and give it a value