github.com/ashedmitr/helmolint
main / published Oct 8, 2021 / repository
Helm Ingress Linter
HELMOLINT
Description
You can use server-snippet annotations in ingress manifests. If an incorrect nginx expression is used in the annotation,
the annotation will still be loaded into the ingress config.
But it will not be able to apply due to an error and thus will block the next changes in the entire ingress config.
To check annotations, you can use admissionWebhooks setting in ingress controller:
## nginx configuration
## Ref: https://github.com/kubernetes/ingress/blob/master/controllers/nginx/configuration.md
If you can't enable admissionWebhooks, you can use helmolint (helm ingress linter) in the gitlab pipeline.
Build image
- run
docker build -t helmolint:0.1.0 . - tag and save image in private registry
- or use
.gitlab-ci.ymlfor auto builds (look.gitlab-ci.yml.example)
Use helm ingress linter in GitLab CI
- Save rendered helm template with name
helm_template.yamlin helm_lint job
helm_lint:
script:
- helm repo update
- helm template $CHART_APP_NAME $CHART $CHART_VALUES --version $CHART_VERSION --debug
- helm template $CHART_APP_NAME $CHART $CHART_VALUES --version $CHART_VERSION --debug > ./helm_template.yaml
stage: lint
artifacts:
paths:
- ./helm_template.yaml
expire_in: 30m
- Run check job
lint:helm:ingress:
image: registry.local/kube-public/helmolint:0.1.0
stage: ingress_lint
dependencies:
- helm_lint
script:
- echo "Check ingress snippets."
Linter algorithm
- find ingress manifests in rendered helm template
- load objects
server-snippetfrom file - put snippets in nginx config
- validate config
nginx -t -c custom.conf
API
This version publishes no documented types.