Run Multiple Services on Port 80 in same Kubernetes Cluster on Google Container Engine
Kubernetes 1.1 has an Ingress
type, which allows you to route different dns names/ips to different services. From github
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
Yes,multiple services can have same ports as it doesn't matter because each service gets it own IP address. In google kubernetes console run
kubectl get svc
This will list out all services and EXTERNAL IP can be checked by copying it in browser with the respective port number.
As of today GKE relies on Kubernetes 0.4.x which allocates ports on every nodes for each services. With this configuration you can't have multiple services listening on port 80.
Kubernetes 0.5.x introduced a new networking model, which map an separate IP for each services. So once GKE upgrade you will be able to have multiple services exposed on different IP/ports.