Skip to content

503 ingress when spec.service is defined #575

@thokra-nav

Description

@thokra-nav

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions