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 doesn't stop if job restartPolicy is wrong #259

Open
icy opened this issue Oct 26, 2020 · 7 comments
Open

kubeval doesn't stop if job restartPolicy is wrong #259

icy opened this issue Oct 26, 2020 · 7 comments
Labels
schema schema issue that should be raised at https://github.com/instrumenta/kubernetes-json-schema

Comments

@icy
Copy link

icy commented Oct 26, 2020

We have some Job configuration and we expect kubeval to stop us if developers provide wrong settings. However, kubeval (0.15.0) simply ignored and at the final step we got an error with helm upgrade

Error: UPGRADE FAILED: failed to create resource: Job.batch "foo-tw-232-tre-two-worker-job" is invalid: 
spec.template.spec.restartPolicy: Unsupported value: "Always": supported values: "OnFailure", "Never"
helm.go:84: [debug] Job.batch "foo-tw-232-tre-two-worker-job" is invalid: 
    spec.template.spec.restartPolicy: Unsupported value: "Always": supported values: "OnFailure", "Never"
failed to create resource
helm.sh/helm/v3/pkg/kube.(*Client).Update.func1
    /home/circleci/helm.sh/helm/pkg/kube/client.go:190
helm.sh/helm/v3/pkg/kube.ResourceList.Visit
    /home/circleci/helm.sh/helm/pkg/kube/resour
@icy icy changed the title kubeval doesn't stop of job restartPolicy is wrong kubeval doesn't stop if job restartPolicy is wrong Oct 26, 2020
@yannh
Copy link

yannh commented Oct 31, 2020

Hi @icy , I would point to my answer here #257 - Kubeval only validates Kubernetes manifests following the Swagger file released by the k8s project. This is not the same validation that kubectl, or the Kubernetes server, would do. In this case it doesnt seem like the list of supported values is a constraint in the swagger file.

@icy
Copy link
Author

icy commented Oct 31, 2020

Hi @icy , I would point to my answer here #257 - Kubeval only validates Kubernetes manifests following the Swagger file released by the k8s project. This is not the same validation that kubectl, or the Kubernetes server, would do. In this case it doesnt seem like the list of supported values is a constraint in the swagger file.

I see. The swagger doesn't provide rich information (e.g, normal Pod can have Always but job doesn't have that value.)

Do you think there is any plug-gable way that allows us to have some kustomization checks other than default kubeval checks?

@yannh
Copy link

yannh commented Oct 31, 2020

Not sure if that is what you re looking for, but from the same author as kubeval: https://github.com/open-policy-agent/conftest
I guess in some cases, actually changing the swagger definition to get it to enforce the list of valid values could help too :)

@icy
Copy link
Author

icy commented Oct 31, 2020

Not sure if that is what you re looking for, but from the same author as kubeval: https://github.com/open-policy-agent/conftest
I guess in some cases, actually changing the swagger definition to get it to enforce the list of valid values could help too :)

Thanks for the link. We haven't had a chance to implement any OPA-related thing yet, though OPA can help to solve many problems.

That's said, implementing our own validations/tests for k8s-server constraints looks like a reinvent-the-wheel job doesn't it?

@yannh
Copy link

yannh commented Dec 24, 2020

it does... I don't know exactly how the Kubernetes Swagger file is generated, but I guess that would be a good place to fix this :)

@yannh
Copy link

yannh commented Dec 24, 2020

I have opened kubernetes/kube-openapi#218 ! I m playing with it but it's not the easiest thing in the world ;)

@icy
Copy link
Author

icy commented Dec 24, 2020

I have opened kubernetes/kube-openapi#218 ! I m playing with it but it's not the easiest thing in the world ;)

Thanks a lot for your time. I totally agree that's not the easiest thing ;)

I see that restartPolicy accepts different set of values. For job there are only two (https://kubernetes.io/docs/concepts/workloads/controllers/job/#pod-template)

Only a RestartPolicy equal to Never or OnFailure is allowed.

I don't now how that ends up; you're right the openApi is quite confusing.

@carlossg carlossg added the schema schema issue that should be raised at https://github.com/instrumenta/kubernetes-json-schema label Mar 30, 2021
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