AWS cross-cluster comunication with Kubernetes pods

2/24/2017

I've question with cross-cluster communication between pods on AWS.

I am using kubernetes to deploy clusters on AWS. Both clusters are in same region and AZ. Both clusters are deployed in their own VPC with non-overlapping subnets. I've successfully created VPC Peering to establish communication between two VPCs. and Minions (instances) from VPC can ping each other through private IP.

Question is, Kubernetes pods from one Cluster (VPC) can not ping Pod in another cluster through it's internal IP. I see traffic leaving pod and minion but dont see it on other VPC.

Here is IP info:

Cluster 1 (VPC 1) - subnet 172.21.0.0/16 Minion(Instance)in VPC 1 - internal IP - 172.21.0.232 Pod on Minion 1 - IP - 10.240.1.54

Cluster 2 (VPC 2) - subnet 172.20.0.0/16 Minion(instance) in VPC 2 - internal IP - 172.20.0.19 Pod on Minion 1 - IP - 10.241.2.36

I've configured VPC Peering between two VPC and I can ping Minion in VPC 1 (172.21.0.232) to Minion in VPC 2 through IP 172.20.0.19

But when I try to ping pod on VPC 1, Minion 1 - IP 10.240.1.54 from VPC 2, Minion Pod 10.241.2.36, it can not ping.

Is this supported use case in AWS? How can I achieve it. I have configured security group on both instance to allow all traffic from source 10.0.0.0/8 as well but it did not help.

Really appreciate your help!

-- ndalal
amazon-ec2
amazon-vpc
amazon-web-services
kubernetes

1 Answer

2/24/2017

direct communication with the pods from outside the cluster is not supposed to work. Pods can be exposed to the outside through services.

There is a wide range of options, but a basic services with a definition like the following could expose a pod through a predefined port to the other cluster:

---
kind: Service
apiVersion: v1
metadata:
  name: my-service
spec:
  selector:
    app: MyApp
  ports:
  - protocol: TCP
    port: 80
    targetPort: 9376
    nodePort: 34567

With that you could access your pod through the port 34567 which is mapped on any of the kubernetes nodes.

Besides that you should also consider to check out ingress configurations.

A very good summary besides the official documentation is the Kubernetes Services and Ingress Under X-ray blog post.

-- pagid
Source: StackOverflow