BryGom
BryGom

Reputation: 699

Kubernetes like Apache or Nginx Virtual Host

I have a cluster of Kubernetes with two web apps deployed , I can't understand the way of assign same port 80 and 443 for this apps for access everyone with you own domain, web1.com and web2.com redirects to specific service. Looking in the web i found topics like a : Ingress Controller with Nginx Proxy reverse and traefik for manage request and route.

How can I do this?

Thank you

Upvotes: 2

Views: 3269

Answers (1)

Janos Lenart
Janos Lenart

Reputation: 27100

I will assume you already have 2 Services defined for your apps (s1 and s2 below).

Kubernetes Ingress supports named based virtual hosting (and much more):

The following Ingress tells the backing loadbalancer to route requests based on the Host header.

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: test
spec:
  rules:
  - host: foo.bar.com
    http:
      paths:
      - backend:
          serviceName: s1
          servicePort: 80
  - host: bar.foo.com
    http:
      paths:
      - backend:
          serviceName: s2
          servicePort: 80

Upvotes: 1

Related Questions