Basic ingress configuration

5/16/2021

Hi I'm learning kubernetes and I'm having trouble exposing the service. I want to route traffic to my cluster from HAProxy. I'm using my own bare-metal server.

example config:

deployment.yaml

apiVersion: apps/v1
kind: Deployment
metadata:
  name: apache
  labels:
    app: apache-test
spec:
  replicas: 1
  selector:
    matchLabels:
      app: apache-test
  template:
    metadata:
      labels:
        app: apache-test
    spec:
      containers:
      - name: apache
        image: httpd
        ports:
        - containerPort: 80

service.yaml

apiVersion: v1
kind: Service
metadata:
  name: apache-test-service
spec:
  selector:
    app: apache-test
  ports:
  - protocol: TCP
    port: 80
    targetPort: 80
    name: http

ingress.yaml

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: apache-test-ingress
spec:
  rules:
  - host: apache-test.com
    http:
      paths:
      - pathType: Prefix
        path: "/"
        backend:
          service:
            name: apache-test-service
            port:
              number: 80

What's wrong?

-- Paweł Zając
kubernetes
kubernetes-ingress

1 Answer

5/16/2021

In general, setting up the ingress resource is not enough. You have to deploy an ingress controller as well: https://kubernetes.io/docs/concepts/services-networking/ingress-controllers/ .

I have no experience with HAProxy specifically, but I would get started with https://haproxy-ingress.github.io/docs/getting-started/ .

-- Mark
Source: StackOverflow