Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

kubeval should FAIL on underscore in resource names #257

Closed
mjbright opened this issue Sep 30, 2020 · 2 comments
Closed

kubeval should FAIL on underscore in resource names #257

mjbright opened this issue Sep 30, 2020 · 2 comments
Labels
schema schema issue that should be raised at https://github.com/instrumenta/kubernetes-json-schema

Comments

@mjbright
Copy link

The following yaml should FAIL due to the underscore in 'pv_demo', but it PASSes:

apiVersion: v1
kind: Pod
metadata:
  labels:
    run: pv_demo
  name: pv_demo
spec:
  containers:
  - image: mjbright/ckad-demo:alpine1
    name: pv_demo
  dnsPolicy: ClusterFirst
  restartPolicy: Always

Kubeval produces

$ kubeval pod.yaml
PASS - pod.yaml contains a valid Pod (pv_demo)

Trying to create the Pod produces

$ kubectl create -f pod.yaml

The Pod "pv_demo" is invalid:
* metadata.name: Invalid value: "pv_demo": a DNS-1123 subdomain must consist of lower case alphanumeric characters, '-' or '.', and must start and end with an alphanumeric character (e.g. 'example.com', regex used for validation is '[a-z0-9]([-a-z0-9]*[a-z0-9])?(\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*')
* spec.containers[0].name: Invalid value: "pv_demo": a DNS-1123 label must consist of lower case alphanumeric characters or '-', and must start and end with an alphanumeric character (e.g. 'my-name',  or '123-abc', regex used for validation is '[a-z0-9]([-a-z0-9]*[a-z0-9])?')
@yannh
Copy link

yannh commented Oct 18, 2020

Hi @mjbright , this issue, as well as others such as #256 or #253 , are related to the way kubeval does validation. Kubeval uses JSON Schemas derived from the Swagger documentation of the Kubernetes API - this file https://github.com/kubernetes/kubernetes/blob/master/api/openapi-spec/swagger.json .

While this file might tell you that this or that field is required, optional, or must be a string, an array or an integer, what that file does not contain is advanced validation logic that the Kubernetes server does.

This might help - https://prefetch.net/blog/2020/06/29/using-kubernetes-server-side-validation-to-validate-your-deployment-manifests/ but it doesn't seem extremely practical.

@carlossg carlossg added the schema schema issue that should be raised at https://github.com/instrumenta/kubernetes-json-schema label Mar 30, 2021
@carlossg
Copy link
Collaborator

dupe of #214

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
schema schema issue that should be raised at https://github.com/instrumenta/kubernetes-json-schema
Projects
None yet
Development

No branches or pull requests

3 participants