Ingress resource hostname

6/11/2021

I have kube cluster & its control plane endpoint is haproxy. I want to use hostname of system where haproxy lies and use it as hostname in the ingress resource. Is it possible to achieve this. The request ha proxy backend config is below:

frontend k8s_frontend
    bind *:6443
    mode tcp
    default_backend k8s_backend

backend k8s_backend
    mode tcp
    balance roundrobin
    server master1  10.50.8.117:6443
    server master2  10.50.8.118:6443
    server master3  10.50.8.119:6443

frontend http_frontend
    bind :80
    bind :443 ssl crt /com.pem
    default_backend servers

backend servers
    balance roundrobin
    server worker1 10.50.8.120:443 ssl verify none
    server worker2 10.50.8.121:443 ssl verify none

Below is my ingress resource:

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: dashboard-ingress
  namespace: kubernetes-dashboard
  annotations:
    nginx.ingress.kubernetes.io/ssl-passthrough: "true"
    nginx.ingress.kubernetes.io/backend-protocol: "HTTPS"
spec:
  rules:
  - host: "HAPROXY_HOSTNAME"
    http:
      paths:
      - pathType: Prefix
        path: "/k8s"
        backend:
          service:
            name: kubernetes-dashboard
            port:
              number: 443
-- Surya Teja
haproxy
kubernetes
kubernetes-ingress
nginx-ingress

1 Answer

6/15/2021

Yes, you can mention the hostname of HAProxy in the ingress source. The ingress controller node can be resolved as hostname along with deploying and exposing the echo server service as shown below. Kindly refer to this document.

apiVersion: networking.k8s.io/v1beta1 kind: Ingress metadata: annotations: kubernetes.io/ingress.class: haproxy name: echoserver spec: rules:

  • host: $HOST http: paths: - backend: serviceName: echoserver servicePort: 8080 path: / EOF

More details on HAProxy Ingress Controller can be found here.

-- Anbu Thirugnana Sekar
Source: StackOverflow