Giter VIP home page Giter VIP logo

Comments (4)

yannh avatar yannh commented on May 10, 2024 1

Hi @svmundada , I think it might have to do with your schema file: it contains this:

  "$ref": "#/definitions/io.k8s.apimachinery.pkg.apis.meta.v1.ObjectMeta",

And that reference to definitions might be missing - I suspect your schema is not valid.

From your command "kustomize fetch openapi" I guess it might return an openapi schema, which you would need to convert to jsonschema using https://github.com/yannh/openapi2jsonschema first (kubeconform, like kubeval, uses jsonschema and not openapi for validation, mostly due to availability of validation libraries).

If this is for the Prometheus operators, these are the openapi files I use: https://github.com/prometheus-operator/prometheus-operator/tree/master/example/prometheus-operator-crd :

$ openapi2jsonschema https://raw.githubusercontent.com/prometheus-operator/prometheus-operator/master/example/prometheus-operator-crd/monitoring.coreos.com_servicemonitors.yaml
JSON schema written to servicemonitor_v1.json

^ This is the file to validate against.

I'll leave this open - good luck!

from kubeconform.

yannh avatar yannh commented on May 10, 2024 1

Hi @svmundada , I ll be closing this for now since it looks like there is no issue with kubeconform itself. Let me know if I can maybe make the documentation better! 👍

from kubeconform.

svmundada avatar svmundada commented on May 10, 2024

Hi @yannh, Thanks for your reply, I understand the process better but still stuck.

I tried this openapi2jsonschema openapi.json --kubernetes --strict --stand-alone --expanded and it created schemas/servicemonitor-monitoring-v1.json. My requirement is to have multiple apiversions that's why using --expanded.

Can you please tell what would be the correct template string ? I tried this schemas/{{ .ResourceKind }}{{ .KindSuffix }}-{{ .ResourceAPIVersion}}.json but its not working.


Edit: It worked, after changing the template to schemas/{{ .ResourceKind }}{{ .KindSuffix }}.json, but its failing for core types. But I mitigated by adding -schema-location=default. Is there any way to incorporate core ones? For core types it generates schemas/pod-core-v1.json and may be kubeconform is looking for schemas/pod-v1.json.

from kubeconform.

yannh avatar yannh commented on May 10, 2024

Well done! You can provide several -schema-locations:

kubeconform -schema-location 'schemas/{{ .ResourceKind }}{{ .KindSuffix }}.json' -schema-location default .....

Default is an alias for this repository: https://github.com/yannh/kubernetes-json-schema , and Kubeconform will download the files as required. Kubeconform will look into each of these "schema locations" and try to find a match for the schema.

I hope this helps, best,
Yann

from kubeconform.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.