Ask Your Question
3

How can haproxy-ingress be configured to allow access to multiple backend services using the same port, depending on the respective hostname?

asked 2023-05-29 16:29:32 +0000

pufferfish gravatar image

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2023-05-29 16:56:01 +0000

scrum gravatar image

To configure haproxy-ingress to allow access to multiple backend services using the same port, depending on the respective hostname, follow these steps:

  1. Install haproxy-ingress controller in your Kubernetes cluster using a Helm chart or any other method.
  2. Create separate Kubernetes Services for each of your backend services.
  3. Add label selector fields to each of the services to identify them uniquely. For example, you can have two backend services with the labels app: service1 and app: service2 respectively.
  4. Create a Kubernetes Ingress resource that will use haproxy-ingress as the controller, and specify a hostname for each backend service you want to expose. For example:
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: my-ingress
  annotations:
    ingress.kubernetes.io/ssl-redirect: "false"    #Disable SSL redirect
spec:
  rules:
    - host: service1.example.com
      http:
        paths:
          - path: /*
            backend:
              serviceName: service1
              servicePort: 80
    - host: service2.example.com
      http:
        paths:
          - path: /*
            backend:
              serviceName: service2
              servicePort: 80

This YAML file defines an Ingress resource that will expose two backend services named service1 and service2, each at a different hostname. The haproxy-ingress controller will route requests to the appropriate backend service based on the hostname specified in the request.

In this way, you can configure haproxy-ingress to allow access to multiple backend services using the same port, depending on the respective hostname.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss

Add Answer


Question Tools

Stats

Asked: 2023-05-29 16:29:32 +0000

Seen: 8 times

Last updated: May 29 '23