Comments (4)
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.
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.
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.
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)
- Support Validation rules
- Private repo support?
- New release with latest Go version? HOT 2
- Missing file is never reached in openapi2jsonschema.py HOT 2
- Failing on ConfigMap empty key values? HOT 1
- GitHub Action that downloads, installs, and adds CLI tool to PATH HOT 3
- Schema for v1.26.10 is missing HOT 2
- Bug: Junit output shows top-level error count, but not error-count within a test suite HOT 1
- Schema Recognition issue in kubeconform v0.6.3 and above HOT 3
- Question: Can kubeconform report deprecated APIs? HOT 2
- Enhance schema-location to support HTTP basic authentication HOT 1
- Unable to pipe YAMLs to the kubeconform container HOT 1
- Feature request: Support skipping kind/name HOT 1
- [Bug] -skip uses first element in comma separated list only HOT 2
- Kubeconform errors out with DestinationRule, cannot find ':'
- Kubeconform does not report invalid metadata.name HOT 1
- Better/less verbose error formatting? HOT 2
- Could not find schema for HTTPRoute,GCPGatewayPolicy and HealthCheckPolicy HOT 1
- Time to upgrade golang, there are quite a few HIGH findings in kubeconform v0.6.4 HOT 3
- Dockerfile has deprecated `MAINTAINER` label HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from kubeconform.