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

refactor(lint): add helm templates validation #452

Merged
merged 3 commits into from
Oct 16, 2024

Conversation

diafour
Copy link
Member

@diafour diafour commented Oct 16, 2024

Description

  • Use kubeconform to validate helm templates with OpenAPI schemas
  • Add task to run validation in CI and locally.
  • kubeconform will run via Docker if not installed locally.
  • Download Deckhouse CRDs from main branch.
  • Virtualization module CRDs are used from /crds directory.

Why do we need it, and what problem does it solve?

Helm templates are error-prone, kubeconform helps us to catch various problems.

What is the expected result?

kubeconform report should be in the job output.

Report example:

--- Kubeconform report ---
VALID     APIService v1alpha2.subresources.virtualization.deckhouse.io
VALID     Certificate virtualization
... skip long output with valid resources ...
VALID     VirtualMachineClass host-passthrough
ERROR     Job virtualization-pre-delete-hook
  error unmarshalling resource: error converting YAML to JSON: yaml: unmarshal errors:
    line 21: key "labels" already set in map
ERROR     ServiceMonitor virtualization-virt-handler
  error unmarshalling resource: error converting YAML to JSON: yaml: unmarshal errors:
    line 235: key "namespaceSelector" already set in map
    line 238: key "selector" already set in map
    line 19: key "spec" already set in map
INVALID   Service virtualization-controller-metrics
  - /spec/ports/0:
      additionalProperties 'clusterIP', 'type' not allowed
------- Summary -------
      valid: 97
    skipped: 0
  no schema: 0
     errors: 2
    invalid: 1
task: Failed to run task "validation:helm-templates": exit status 3

Checklist

  • The code is covered by unit tests.
  • e2e tests passed.
  • Documentation updated according to the changes.
  • Changes were tested in the Kubernetes cluster manually.

- Use kubeconform to validate helm templates with OpenAPI schemas
- Add task to run validation in CI and locally.
- kubeconform will run via Docker if not installed locally.

Signed-off-by: Ivan Mikheykin <ivan.mikheykin@flant.com>
Signed-off-by: Ivan Mikheykin <ivan.mikheykin@flant.com>
Signed-off-by: Ivan Mikheykin <ivan.mikheykin@flant.com>
@diafour diafour merged commit 3aee8c9 into main Oct 16, 2024
21 of 22 checks passed
@diafour diafour deleted the refactor/lint/validate-helm-templates-with-kubeconform branch October 16, 2024 16:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
validation/skip/helm_templates Skip validating helm templates
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants