naiserator icon indicating copy to clipboard operation
naiserator copied to clipboard

503 ingress when spec.service is defined

Open thokra-nav opened this issue 1 year ago • 1 comments

If you have an application with both ingresses and service defined, the generated ingress uses wrong port when referencing the service

app.yaml

apiVersion: nais.io/v1alpha1
kind: Application
metadata:
  name: some-name
spec:
  # ....
  ingresses:
  - https://some-name.dev.dev-nais.cloud.nais.io
  service:
    port: 8080
    protocol: http

It generates

Ingress:

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  # ...
  name: some-name-nais-ingress-9a3064dc
spec:
  ingressClassName: nais-ingress
  rules:
  - host: some-name.dev.dev-nais.cloud.nais.io
    http:
      paths:
      - backend:
          service:
            name: some-name
            port:
              number: 80
        path: /
        pathType: ImplementationSpecific

Service:

apiVersion: v1
kind: Service
metadata:
  # ...
  name: some-name
spec:
  # ...
  ports:
  - name: http
    port: 8080
    protocol: TCP
    targetPort: http

As the port number is not 80 in the generated service, there's no port mapping that matches the ingress expectation.

Suggestions:

  • Switch the port in the ingress to the one defined in spec.service if provided
  • Use named ports insted of numbers

thokra-nav avatar Nov 19 '24 12:11 thokra-nav

Per i dag ser det ut som at det i NAV er 3 instanser som bruker det, to er oss selv, og en er en redis. Ingen av disse har en ingress i tillegg

thokra-nav avatar Nov 19 '24 12:11 thokra-nav