yannh / kubeconform

A FAST Kubernetes manifests validator, with support for Custom Resources!
Apache License 2.0
2.22k stars 123 forks source link

Should a resource with an empty name be accepted? #122

Closed PawelLipski closed 2 years ago

PawelLipski commented 2 years ago

Each of the following is accepted bykubeconform:

apiVersion: v1
kind: Secret
metadata:
  name:
---
apiVersion: v1
kind: Secret
metadata:
---
apiVersion: v1
kind: Secret

But I'm getting, as expected, from server for: "....yaml": resource name may not be empty from k8s server :/

eyarz commented 2 years ago

This is actually the expected behavior. Name check is NOT part of the K8s schema and therefore, it's not validated by kubeconform. Why it's not part of the schema, and it's part of the server validation script? I don't know 🤷‍♂️

BTW, the key can be metadata.name OR metadata.generateName: https://hub.datree.io/built-in-rules/ensure-resource-name

yannh commented 2 years ago

Closing, I believe @eyarz is right here... and yes, sometimes the server validation is more stringent than the schema itself :(