Connect to container service clusterip from compute engine instance
I have a few applications that run on regular Compute Engine nodes. In addition I have a Container Cluster that I am migrating applications to. Sooner or later all apps should be in Container Engine so service discovery is straight forward.
But for now the apps on Compute Engine need to be able to talk to the Container Engine apps. The Container Engine apps are all registered as a service.
For the sake of testing I used the “echoheaders” image:
$ kubectl describe svc echoheaders
Port: http 80/TCP
Session Affinity: None
The issue now is that I can only access the pod service from the Compute Engine node directly via 10.112.1.3:8080 but not via its clusterip 10.115.249.140:80. That only works from within the actual Compute Engine nodes.
I already tried to create a bastion route pointing to one of the Container Engine nodes but it still doesn’t work:
$ gcloud compute routes describe gke-cluster-1-services
description: Route to Cluster-1 service IP range
And on the firewall the Compute Node can connect to any.
Anybody happen to have pointers what could be missing to allow the Compute Engine nodes access the Compute Node Services by their ClusterIPs?
Kubernetes expects anything within the cluster to be able to talk with everything else. GKE accomplishes this with advanced routing. By default, this lets GKE containers and GCE nodes on the same network communicate. This is why you could hit your containers directly.
A ClusterIP is only reachable within the Kubernetes cluster. These IPs are managed by iptables on just Kubernetes nodes. This is why you can’t hit your service from the GCE nodes, but you can hit it from your containers.
Bastion routes send all traffic to the cluster’s subnet to a cluster node. The node then routes the flow correctly. Create multiple bastion routes to multiple nodes at the same priority to avoid hotspotting a single node.
Try using the cluster’s full /14, which you can find under the cluster’s description in the container engine UI.
- Database Administration Tutorials
- Programming Tutorials & IT News
- Linux & DevOps World
- Ebook Reviews
- PES Matches, Skills & News