Reputation: 765
I have the following definition of ingress.yaml
{{- if .Values.ingress.enabled -}}
{{- $fullName := include "onion.fullname" . -}}
{{- $svcPort := .Values.service.port -}}
{{- if semverCompare ">=1.14-0" .Capabilities.KubeVersion.GitVersion -}}
apiVersion: networking.k8s.io/v1
{{- else -}}
apiVersion: networking.k8s.io/v1
{{- end }}
kind: Ingress
metadata:
name: {{ $fullName }}
labels:
{{- include "onion.labels" . | nindent 4 }}
{{- with .Values.ingress.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
{{- if .Values.ingress.tls }}
tls:
{{- range .Values.ingress.tls }}
- hosts:
{{- range .hosts }}
- {{ . | quote }}
{{- end }}
secretName: {{ .secretName }}
{{- end }}
{{- end }}
rules:
{{- range .Values.ingress.hosts }}
- host: {{ .host | quote }}
http:
paths:
{{- range .paths }}
- path: {{ . }}
backend:
serviceName: {{ $fullName }}
servicePort: {{ $svcPort }}
{{- end }}
{{- end }}
{{- end }}
And the value.yaml created is as below:
ingress:
name: external
enabled: true
type: LoadBalancer
annotations:
kubernetes.io/ingress.class: "nginx-environment"
hosts:
- host: "onion.api.environment.cloud.google.com"
http:
paths:
- backend:
serviceName: internal
servicePort: 8081
path: "/"
tls:
- secretName: "onion.api.environment.cloud.google.com-tls"
hosts:
- "onion.api.environment.cloud.google.com"
- "*.cloud.google.com"
I keep getting the following error: Error: unable to build kubernetes objects from release manifest: error validating "": error validating data: ValidationError(Ingress.spec.rules[0].http): missing required field "paths" in io.k8s.api.networking.v1.HTTPIngressRuleValue
Can someone advice please what am I doing wrong in the values.yaml file?
Upvotes: 1
Views: 6387
Reputation: 765
The correct template for "ingress api: networking.k8s.io/v1" should be:
spec:
{{- if .Values.ingress.tls }}
tls:
{{- range .Values.ingress.tls }}
- hosts:
{{- range .hosts }}
- {{ . | quote }}
{{- end }}
secretName: {{ .secretName }}
{{- end }}
{{- end }}
rules:
{{- range .Values.ingress.hosts }}
- host: {{ .host | quote }}
http:
paths:
{{- range .paths }}
- path: {{ . }}
pathType: Prefix
backend:
service:
name: {{ $fullName }}
port:
number: {{ $svcPort }}
{{- end }}
{{- end }}
{{- end }}
and hence the following value.yaml would match
ingress:
name: external
enabled: true
type: LoadBalancer
#loadBalancerSourceRanges: ["0.0.0.0/0"]
#externalPort: 443
#internalPort: 80
annotations:
kubernetes.io/ingress.class: "nginx-environment"
nginx.ingress.kubernetes.io/rewrite-target: "/"
nginx.ingress.kubernetes.io/enable-cors: "true"
nginx.ingress.kubernetes.io/cors-allow-methods: "GET, POST, PUT, DELETE, OPTIONS, HEAD"
nginx.ingress.kubernetes.io/cors-allow-origin: "*"
nginx.ingress.kubernetes.io/cors-allow-credentials: "true"
nginx.ingress.kubernetes.io/cors-allow-headers: "*"
nginx.ingress.kubernetes.io/cors-max-age: "3600"
nginx.ingress.kubernetes.io/from-to-www-redirect: "true"
tls: []
# - hosts:
# - "onion.api.environment.cloud.google.com"
# - "*.cloud.ajw-group.com"
# secretName: onion.api.environment.cloud.google.com-tls
hosts:
- host: onion.api.environment.cloud.google.com
#http:
paths:
- /
Upvotes: 1