Connect to different VPC inside of Kubernetes pod

12/30/2018

I have two VPCs, VPC A and VPC B . I have one service running in VPC B. Kubernetes cluster is in VPC A. I am using KOPS in AWS cloud and VPC peering enabled between two VPCs. I can connect to the service running in VPC B from the Kubernetes deployment server host in VPC A. But, I can not connect to the service inside the Kubernetes pod. It is giving timed out. I searched on internet and I found that IPTABLE rules could work. I have gone through this article, https://ben.straub.cc/2015/08/19/kubernetes-aws-vpc-peering/

But it is not possible to manually ssh into Kubernetes node servers and set the IPTABLE rules. I want to add it as a part of deployment.

This is my service looks like,

apiVersion: v1
kind: Service
metadata:
  name: test-microservice
  namespace: development
spec:
#  type: LoadBalancer
  type: NodePort
 # clusterIP: None
  ports:
  - name: http
    port: 80
    protocol: TCP
    targetPort: 80
  selector:
    run: test-microservice
-- Dinesh Ahuja
amazon-elb
amazon-web-services
containers
kops
kubernetes

0 Answers