Home > Net >  Kubernetes helm "Ingress.spec.rules[0].http.paths" got "map", expected "arr
Kubernetes helm "Ingress.spec.rules[0].http.paths" got "map", expected "arr

Time:07-29

So I have been trying to fix some charts we inherited and all the others went fine except this 1 which is giving me a headache.

I understand what thew error is telling me Error: unable to build kubernetes objects from release manifest: error validating "": error validating data: ValidationError(Ingress.spec.rules[0].http.paths): invalid type for io.k8s.api.networking.v1.HTTPIngressRuleValue.paths: got "map", expected "array" but I can't find where this map appears in the spec below. I see the paths being in list format.

Does anyone have any idea where exactly the problem is?

Azure AKS 1.24.0

{{- if .Values.ingress.enabled -}}
{{- $fullName := include "something.fullname" . -}}
{{- $servicePort := .Values.service.port -}}
{{- $ingressPath := .Values.ingress.path -}}
{{- if .Capabilities.APIVersions.Has "networking.k8s.io/v1" }}
apiVersion: networking.k8s.io/v1
{{- else if .Capabilities.APIVersions.Has "extensions/v1beta1" }}
apiVersion: extensions/v1beta1
{{- else }}
{{ fail "Unsupported API version"}}
{{- end }}
kind: Ingress
metadata:
  name: {{ $fullName }}
  labels:
    app.kubernetes.io/name: {{ .Chart.Name }}
    app.kubernetes.io/instance: {{ .Release.Name }}
    app.kubernetes.io/version: {{ .Chart.AppVersion }}
    app.kubernetes.io/component: {{ .Values.component }}
    app.kubernetes.io/part-of: {{ .Values.partof }}
    app.kubernetes.io/managed-by: {{ .Release.Service }}
    helm.sh/chart: {{ .Chart.Name }}-{{ .Chart.Version | replace " " "_" }}

    {{- with .Values.labels.something}}
    {{ toYaml . }}
    {{- end }}
{{- with .Values.ingress.annotations }}
  annotations:
{{ toYaml . | indent 4 }}
{{- end }}
spec:
{{- if .Values.ingress.tls }}
  tls:
  {{- range .Values.ingress.tls }}
    - hosts:
      {{- range .hosts }}
        - {{ . }}
      {{- end }}
      secretName: {{ .secretName }}
  {{- end }}
{{- end }}
  rules:
  {{- range .Values.ingress.hosts }}
    - host: {{ . }}
  {{- end }}
      http:
        paths:
          {{- if .Capabilities.APIVersions.Has "networking.k8s.io/v1" }}
          pathType: Prefix
          backend:
            service:
              name: {{ default $fullName .Values.service.name }}
              port:
                number: {{ .Values.service.port }}
          {{- else if .Capabilities.APIVersions.Has "extensions/v1beta1" }}
            backend:
              serviceName: {{ default $fullName .Values.service.name }}
              servicePort: {{ .Values.service.port }}
          {{- end }}
{{- end }}

EDIT 1 Doing a helm lint . with the same flags that the helm upgrade --install would do, throws no errors

CodePudding user response:

You have:

    paths:
      {{- if .Capabilities.APIVersions.Has "networking.k8s.io/v1" }}
      pathType: Prefix
      ... 

You're missing the actual path:

    paths:
      - path: /
        {{- if .Capabilities.APIVersions.Has "networking.k8s.io/v1" }}
        pathType: Prefix
        ... 
  • Related