instrumenta / kubeval

Validate your Kubernetes configuration files, supports multiple Kubernetes versions
https://kubeval.com
Other
3.16k stars 229 forks source link

Doesnt catch invalid `env` indentation #62

Closed allenhartwig closed 6 years ago

allenhartwig commented 6 years ago

The following spec passes kubeval but fails kubectl apply with the error "ValidationError(CronJob.spec.jobTemplate.spec.template.spec): unknown field "env" in io.k8s.api.core.v1.PodSpec" as the env spec doesn't have the right indentation.

apiVersion: batch/v1beta1
kind: CronJob
metadata:
  name: my-cron
spec:
  schedule: "0 2 * * *"
  jobTemplate:
    spec:
      template:
        spec:
          containers:
          - name: my-cron
            image: my-image:latest
            command: ["...]
          env:
          - name: VAR
            value: test
garethr commented 6 years ago

You should be able to trigger the error by passing the --strict flag. Realising I need to update the documentation with details of that option.

The reason for this is the above YAML is valid for the API, in that it happily accepts additional properties. However kubectl doesn't.