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

Using --additional-schema-locations doesn't seem to actually validate CRDs configuration #247

Closed
B-Souty opened this issue Jul 31, 2020 · 2 comments

Comments

@B-Souty
Copy link

B-Souty commented Jul 31, 2020

Hi, I tried using the --additional-schema-location to validate CRDs like HelmRelease or ServiceMonitor but I was unable to trigger an error by voluntarily misconfiguring one of those resource.

Expected Behavior

Setting a custom resource field type to something different than what is defined in the CRD schema should trigger an error when running kubeval against it.

Current Behavior

Running kubeval against a badly configured custom resource result in a PASS.

Steps to reproduce

Given the following badly configured resource bad-helmrelease.yaml:

apiVersion: helm.fluxcd.io/v1
kind: HelmRelease
metadata:
  name: demo-helmrelease
  namespace: default
spec:
  releaseName: demo-helmrelease
  chart:
    # repository key should be a string as defined in the crd schema. 
    # Here I set it to a map instead to try to trigger an error
    repository: 
      name: http://example.com
    name: demo-helmrelease
    version: 1.0.0
  helmVersion: v3
  values: {}

Using the helmrelease CRD schema located at https://github.com/ams0/kubernetes-json-schema/blob/master/master-standalone/helmrelease-helm-v1.json where the repository key is defined as follow:

"repository": {
  "description": "RepoURL is the URL of the Helm repository, e.g. `https://kubernetes-charts.storage.googleapis.com` or `https://charts.example.com`.",
  "type": "string"
},

Running kubeval against this resource result in the following output:

kubeval bad-helmrelease.yml --additional-schema-locations https://raw.githubusercontent.com/ams0/kubernetes-json-schema/master

PASS - bad-helmrelease.yml contains a valid HelmRelease (default.demo-helmrelease)
@joshuaspence
Copy link

joshuaspence commented Sep 1, 2020

I think this is an issue with the JSON schemas rather than Kubeval and I think that I have a solution in #47 (comment)

@B-Souty
Copy link
Author

B-Souty commented Sep 3, 2020

Indeed, using @joshuaspence repository as target to --additional-schema-locations now correctly validates crds.

@B-Souty B-Souty closed this as completed Sep 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants