1

I am currently running a small K3S cluster in order to get familiar with K8S.

I am able to set up pods with ordinary LoadBalancers and get it to work without any problem. However, when I try to get it to work with Ingresses (HAProxy in my case) - I only end up with "default backend -404".

This is the deployment of the pods, based on the default NGINX container:

apiVersion: apps/v1
kind: Deployment
metadata:
  name: notesncrap
  labels:
    app: notesncrap
spec:
  replicas: 2
  selector:
    matchLabels:
      app: notesncrap
  template:
    metadata:
      labels:
        app: notesncrap
    spec:
      containers:
      - name: notesncrap
        image: jselea/notesncrap 
        ports:
        - containerPort: 80

I have also created a Service:

apiVersion: v1
kind: Service
metadata:
  name: notesncrap
  labels:
    app: notesncrap
spec:
  ports:
    - port: 80
  selector:
    app: notesncrap
    tier: frontend

And now the Ingress:

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: notesncrap
spec:
  rules:
  - host: k8scrap.selea.se
    http:
      paths:
      - path: /
        backend:
          serviceName: notesncrap
          servicePort: 80

I have the understanding that the name and label should be consistent over the .yaml files, and I personally can't see anything really wrong with what I have written.

Thankful for any pointers

EDIT:

As pointed out by the comments - the Ingress is behind a Apache Reverseproxy:

ProxyPass "/" "http://x.x.x.x:80"
ProxyPassReverse "/" "http://x.x.x.x:80"
ProxyRequests On
ProxyPreserveHost On

When I try curl directly against the ingress:

╭─root@sshgateway ~
╰─➤  curl -H "Host:k8scrap.selea.se" http://x.x.x.x                                                                                                                                   
default backend - 404#
Orphans
  • 111
  • 1
  • 5

1 Answers1

0

Apparently - I forgot annotations and ingressclass:

I first added this:

apiVersion: networking.k8s.io/v1
kind: IngressClass
metadata:
  annotations:
    ingressclass.kubernetes.io/is-default-class: "true"
  generation: 1
  labels:
    app.kubernetes.io/component: controller
    app.kubernetes.io/instance: haproxy
    app.kubernetes.io/managed-by: Helm
    app.kubernetes.io/name: haproxy-ingress-controller
  name: haproxy
spec:
  controller: haproxy.org/ingress-controller

And in the ingress:

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: notesncrap
  annotations:
    kubernetes.io/ingress.class: "haproxy"
  generation: 1
spec:
  rules:
  - host: k8scrap.selea.se
    http:
      paths:
      - path: /
        backend:
          serviceName: notesncrap
          servicePort: 80

Please observe the annotation.

Orphans
  • 111
  • 1
  • 5