Search code examples
kuberneteskubernetes-helmkubernetes-ingress

Porting networking.k8s.io/v1beta1 to v1


I try to switch from networking.k8s.io/v1beta1 to networking.k8s.io/v1 but it seems I lost myself. So I have a question to here. I got following error message when try a install dry-run.
Errormessage:
Error: unable to build kubernetes objects from release manifest: error validating "": error validating data: ValidationError(Ingress.spec.rules[0].http.paths[0].backend.service.port): invalid type for io.k8s.api.networking.v1.ServiceBackendPort: got "string", expected "map"

It happen in this parts:

kind: Ingress

apiVersion: {{.Values.ingress.apiVersion}}

metadata:

  name: ingress-backend-route

{{- if .Values.ingress.annotations }}

  annotations:

{{ toYaml .Values.ingress.annotations | indent 4 }}

{{- end }}  

spec:

  rules:

    - host: {{.Values.ingress.host}}

      http:

        paths:

          - path: {{.Values.ingress.path}} 

            pathType: {{.Values.generalPrefix}}

            backend:

              service:

                name: my-service-svc

                port: {{ if .Values.oauth2.enable }}http-protected{{ else }}http{{ end }}

          {{- if  .Values.debug }}   

          - path: /couchdb

            pathType: {{.Values.generalPrefix}}

            backend:

              service:

                name: {{ .Release.Name }}-svc-couchdb

                port:

                  number: 5984 

          - path: /rabbitmq

            pathType: {{.Values.generalPrefix}}

            backend:

              service:

                name: rabbitmq-svc

                port:

                  number: 80

          {{- end }}

I think at line port: {{ if .Values.oauth2.enable }}http-protected{{ else }}http{{ end }} the http-protected / http is defined in my-service.yaml

---
apiVersion: v1
kind: Service
metadata:
  name: my-service-svc
spec:
  selector:
    app: my-service
  ports:
  - name: http
    protocol: TCP
    port: 80
    targetPort: 80
  - name: http-protected
    protocol: TCP
    port: 8080
    targetPort: 8080

The new API use the new syntax for ports, maybe this is the issue, but I do not understand the error message well. MAy someone has a tip here`?


Solution

  • It's your ingress. Port is expecting one further key. Use number if you just want to use the port by its given number or name by the defined service port name.

    In example

    port:
      number: 80
    

    or

    port:
      name: http