1

I am trying to access the kubectl of the master node that is running on an ec2 instance. I want to do this from another ec2 instance running on a different vpc. What steps should I take to make this possible?

I have the kubeconfig file on my second machine already but on running kubectl, it gives me a connection error,

Edit: Both the vpcs are private and have the similar CIDR.

user3192295
  • 358
  • 2
  • 13
Aditya
  • 25
  • 4

2 Answers2

2
  • If both of your EC2 are in diff VPCs you can do the VPC peering.
  • If you want to expose your master and K8s setup you can directly use the public IP(if exist) of EC2 and kubectl will connect to k8s cluster over the internet.

You can also checkout peering multiple VPC with same cidr range if you are looking for that way : Multiple VPC and Subnet with same CIDR blocks

Or : https://docs.aws.amazon.com/vpc/latest/peering/peering-configurations-partial-access.html#two-vpcs-peered-specific-cidr

Harsh Manvar
  • 27,020
  • 6
  • 48
  • 102
1
  • If your eks api server is private, create peering between the VPCs and allow your Second EC2 server's private IP
  • If your eks api server is public, you can allow your Second EC2 instance's public IP from the aws console, in the eks security or network section
fedonev
  • 20,327
  • 2
  • 25
  • 34
Phani Kumar
  • 158
  • 5
  • Hi Phani, both vpcs are private and have similar CIDR and I have not used eks. Would peering still work in this case?? – Aditya May 20 '22 at 06:00