Directorio de artículos
–
1. Antecedentes
Es muy tedioso cuando lo escribimos de nuevo vaule.yaml
y lo escribimos de nuevo . value.schema.json
Por lo tanto, existe un complemento sobre el timón que se puede lograr con un comando.
2. Instalación
Este complemento funciona con Helm v2 y v3, ya que es independiente del binario de Helm.
$ helm plugin install https://github.com/karuppiah7890/helm-schema-gen.git
karuppiah7890/helm-schema-gen info checking GitHub for tag '0.0.4'
karuppiah7890/helm-schema-gen info found version: 0.0.4 for 0.0.4/Darwin/x86_64
karuppiah7890/helm-schema-gen info installed ./bin/helm-schema-gen
Installed plugin: schema-gen
O también puede descargar el comando helm-schema-gen
tar tvf helm-schema-gen_0.0.4_Linux_x86_64.tar
./helm-schema-gen --help
mv helm-schema-gen /usr/local/bin/
3. Uso
Este complemento funciona con Helm v2 y v3
Tomemos valores.yaml como ejemplo
replicaCount: 1
image:
repository: nginx
pullPolicy: IfNotPresent
imagePullSecrets: []
nameOverride: ""
fullnameOverride: ""
serviceAccount:
# Specifies whether a service account should be created
create: true
# The name of the service account to use.
# If not set and create is true, a name is generated using the fullname template
name:
podSecurityContext: {
}
# fsGroup: 2000
securityContext: {
}
# capabilities:
# drop:
# - ALL
# readOnlyRootFilesystem: true
# runAsNonRoot: true
# runAsUser: 1000
service:
type: ClusterIP
port: 80
ingress:
enabled: false
annotations: {
}
# kubernetes.io/ingress.class: nginx
# kubernetes.io/tls-acme: "true"
hosts:
- host: chart-example.local
paths: []
tls: []
# - secretName: chart-example-tls
# hosts:
# - chart-example.local
resources: {
}
# We usually recommend not to specify default resources and to leave this as a conscious
# choice for the user. This also increases chances charts run on environments with little
# resources, such as Minikube. If you do want to specify resources, uncomment the following
# lines, adjust them as necessary, and remove the curly braces after 'resources:'.
# limits:
# cpu: 100m
# memory: 128Mi
# requests:
# cpu: 100m
# memory: 128Mi
nodeSelector: {
}
tolerations: []
affinity: {
}
Ahora, si usa el complemento y values.yaml
lo pasa, obtendrá JSONSchemavalues.yaml
$ helm schema-gen values.yaml
{
"$schema": "http://json-schema.org/schema#",
"type": "object",
"properties": {
"affinity": {
"type": "object"
},
"fullnameOverride": {
"type": "string"
},
"image": {
"type": "object",
"properties": {
"pullPolicy": {
"type": "string"
},
"repository": {
"type": "string"
}
}
},
"imagePullSecrets": {
"type": "array"
},
"ingress": {
"type": "object",
"properties": {
"annotations": {
"type": "object"
},
"enabled": {
"type": "boolean"
},
"hosts": {
"type": "array",
"items": {
"type": "object",
"properties": {
"host": {
"type": "string"
},
"paths": {
"type": "array"
}
}
}
},
"tls": {
"type": "array"
}
}
},
"nameOverride": {
"type": "string"
},
"nodeSelector": {
"type": "object"
},
"podSecurityContext": {
"type": "object"
},
"replicaCount": {
"type": "integer"
},
"resources": {
"type": "object"
},
"securityContext": {
"type": "object"
},
"service": {
"type": "object",
"properties": {
"port": {
"type": "integer"
},
"type": {
"type": "string"
}
}
},
"serviceAccount": {
"type": "object",
"properties": {
"create": {
"type": "boolean"
},
"name": {
"type": "null"
}
}
},
"tolerations": {
"type": "array"
}
}
}
Puedes guardarlo en un archivo como este
$ helm schema-gen values.yaml > values.schema.json
Si es el comando helm-schema-gen descargado
helm-schema-gen value.yaml > values.schema.json
✈ Lectura recomendada: