ingress-nginx
ingress-nginx copied to clipboard
Provide a schema for values for the Helm chart
It would be great to have a schema values file available for the Helm chart.
Artifact Hub seems to be supporting it, making values configuration more searchable.
This would enable auto completion for IDEs supporting it when writing values file.
/kind documentation /remove-kind feature
This would be a great first PR @hamjo
/triage accepted
This is stale, but we won't close it automatically, just bare in mind the maintainers may be busy with other tasks and will reach your issue ASAP. If you have any question or request to prioritize this, please reach #ingress-nginx-dev
on Kubernetes Slack.
Totally agree with @hamjo! Supplying a helm schema would also help against misconfigurations even before installing.
I could see me work on this ticket. My general plan is to utilize helm-schema
to auto-generate the helm values.schema.json
file from the charts existing values.yaml
. helm-schema
allows one to specify additional JSON schema annotations in yaml comments directly in values.yaml
. This allows to enhance the inferred schema with additional validations like enums or length/pattern validations. This can be useful especially for things already defined in external kubernetes json schemas like yannh/kubernetes-json-schema
.
I already started to work a little on this to see if it is feasible and it seems that a rudimentary schema can be generated almost as is.
helm-schema
uses # @schema
lines as delimiters for additional JSON schema properties. Below is an abbreviated example of an additional schema annotations in values.yaml
. Note the # @schema
enclosed additional JSON schema properties and the resulting schema below the values.
Executing helm-schema
against these values:
controller:
image:
chroot: false
image: ingress-nginx/controller
tag: "v1.10.0"
digest: sha256:42b3f0e5d0846876b1791cd3afeb5f1cbbe4259d6f35651dcc1b5c980925379c
# @schema
# enum: [IfNotPresent, Always, Never]
# @schema
pullPolicy: IfNotPresent
# @schema
# type: integer
# minimum: 0
# @schema
# www-data -> uid 101
runAsUser: 101
results in this schema:
{
"properties": {
"controller": {
"properties": {
"image": {
"properties": {
"chroot": { "type": "boolean" },
"digest": { "type": "string" },
"image": { "type": "string" },
"pullPolicy": {
"enum": [ "IfNotPresent", "Always", "Never" ]
},
"runAsUser": {
"type": "integer",
"minimum": 0
},
"tag": { "type": "string" }
},
"type": "object"
}
},
"type": "object"
},
"global": {
"type": "object"
}
},
"$schema": "http://json-schema.org/draft-07/schema#",
"type": "object"
}
Any thoughts @strongjz @Gacko @cpanato
/assign