instrumenta / kubeval

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

Failed initializing schema ingress-networking-v1.json 404 #301

Open dombisza opened 3 years ago

dombisza commented 3 years ago

hello there, i was trying to validate ingresses, but I cannot do so because the schema URL gives me 404.

linux@sdombi-vpc-bastion:~$ cat ingress2.yaml
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: minimal-ingress
  annotations:
    nginx.ingress.kubernetes.io/rewrite-target: /
spec:
  rules:
  - http:
      paths:
      - path: /testpath
        pathType: Prefix
        backend:
          service:
            name: test
            port:
              number: 80
linux@sdombi-vpc-bastion:~$ kubeval ingress2.yaml
ERR  - ingress2.yaml: Failed initializing schema https://kubernetesjsonschema.dev/master-standalone/ingress-networking-v1.json: Could not read schema from HTTP, response status is 404 Not Found
linux@sdombi-vpc-bastion:~$ kubeval --version
Version: 0.16.1
Commit: f5dba6b486fa18b9179b91e15eb6f2b0f7a5a69e
Date: 2021-03-30T15:17:06Z

Am i doing something wrong here? Thanks for the help in advance.

izorster commented 3 years ago

Not isolated to ingress: Failed initializing schema https://kubernetesjsonschema.dev/master-standalone/certificate-cert-manager-v1.json: Could not read schema from HTTP, response status is 404 Not Found

andrei-dascalu commented 3 years ago

Likewise. I can use versions that appear on main page https://kubernetesjsonschema.dev

But for example I can't specify various 1.20.x patches (or anything 1.20 for that matter) or 1.19 or the like

tmikulin commented 3 years ago

Will there be a patch soon? Or is there a workaround?

yannh commented 3 years ago

For newer versions of Kubernetes, try using kubeval with my fork of the json schema repos: https://github.com/yannh/kubernetes-json-schema See README for how to use those with kubeval. It contains schemas for all versions of Kubernetes post 1.15.

This should solve the errors related to Kubernetes versions.

Things such as certificate-cert-manager-v1.json I believe are CRDs from https://github.com/jetstack/cert-manager , and a different problem?

knkarthik commented 2 years ago

For newer versions of Kubernetes, try using kubeval with my fork of the json schema repos: https://github.com/yannh/kubernetes-json-schema See README for how to use those with kubeval. It contains schemas for all versions of Kubernetes post 1.15.

This should solve the errors related to Kubernetes versions.

Things such as certificate-cert-manager-v1.json I believe are CRDs from https://github.com/jetstack/cert-manager , and a different problem?

@yannh Nice work! Wondering if you tried getting your changes merged to this repo. It would be nice to have only one place to refer. That being said I don't know what's the process of merging PRs here, as I can see lots of them still unmerged.

jeremybusk commented 2 years ago

As noted above to use newer schemas use command like below

kubeval --schema-location https://raw.githubusercontent.com/yannh/kubernetes-json-schema/master -d mydirectory

aguglie commented 2 years ago

Thank you @jeremybusk and @yannh 🚀

For a long lasting fix, I applied an alias:

alias kubeval="kubeval --schema-location https://raw.githubusercontent.com/yannh/kubernetes-json-schema/master "
mmisztal1980 commented 2 years ago

I've tried applying the fix:

for file in $(find ./output -type f -iname '*.y*ml'); do
  kubeval --schema-location https://raw.githubusercontent.com/yannh/kubernetes-json-schema/master $file --strict
done

I'm getting:

1 error occurred:
    * Failed initalizing schema https://raw.githubusercontent.com/yannh/kubernetes-json-schema/master/master-standalone-strict/ingress-networking-v1.json: Get https://raw.githubusercontent.com/yannh/kubernetes-json-schema/master/master-standalone-strict/ingress-networking-v1.json: EOF

1 error occurred:
    * Failed initalizing schema https://raw.githubusercontent.com/yannh/kubernetes-json-schema/master/master-standalone-strict/service-v1.json: Get https://raw.githubusercontent.com/yannh/kubernetes-json-schema/master/master-standalone-strict/service-v1.json: EOF

1 error occurred:
    * Failed initalizing schema https://raw.githubusercontent.com/yannh/kubernetes-json-schema/master/master-standalone-strict/deployment-apps-v1.json: Get https://raw.githubusercontent.com/yannh/kubernetes-json-schema/master/master-standalone-strict/deployment-apps-v1.json: EOF

1 error occurred:
    * Failed initalizing schema https://raw.githubusercontent.com/yannh/kubernetes-json-schema/master/master-standalone-strict/cronjob-batch-v1.json: Get https://raw.githubusercontent.com/yannh/kubernetes-json-schema/master/master-standalone-strict/cronjob-batch-v1.json: EOF

Am I doing anything wrong?

alfchee commented 1 year ago

For newer versions of Kubernetes, try using kubeval with my fork of the json schema repos: https://github.com/yannh/kubernetes-json-schema See README for how to use those with kubeval. It contains schemas for all versions of Kubernetes post 1.15.

This should solve the errors related to Kubernetes versions.

Things such as certificate-cert-manager-v1.json I believe are CRDs from https://github.com/jetstack/cert-manager , and a different problem?

thanks! this is very helpful

jheidbrink commented 1 month ago

For anyone stumbling upon this: Since october 2022, the readme states that this project is unmaintained and recommends kubeconform instead.