Running multiple services on port 80 in the same Kubernetes cluster in Google Container Engine

Can I run multiple services on port 80 in Kubernetes in the Google Container Engine? Each service has a dedicated external IP address, so theoretically a router should be able to route each service based on its IP address.

So far I have created containers for frontend-1 and frontend-2 in the Container Engine. I tried to create separate services for them running on port 80 with unique external IP addresses, but this did not work. Is there any other way to do this in Kubernetes without using a dedicated routing service?

service 1.yaml:

id: service-1 port: 80 containerPort: 8080 selector: name: frontend-1 createExternalLoadBalancer: true 

2.yaml service:

 id: service-2 port: 80 containerPort: 8081 selector: name: frontend-2 createExternalLoadBalancer: true 
+8
google-container-engine kubernetes
source share
3 answers

Today, GKE relies on Kubernetes 0.4.x, which allocates ports on each host for each service. With this configuration, you cannot have multiple services listening on port 80.

Kubernetes 0.5.x introduced a new network model that displays a separate IP for each service. Thus, after updating GKE, you can use several services on different IP ports.

+2
source share

Kubernetes 1.1 has an Ingress type that allows you to route different / ips DNS names for 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 
+6
source share

Yes, multiple services can have the same ports, since it does not matter, because each service gets its own IP address. In google-kubernet launch console

 kubectl get svc 

This will list all the services, and the EXTERNAL IP can be checked by copying it to the browser with the corresponding port number.

0
source share

All Articles