Accessing Kubernetes master and nodes

8/14/2018

I created 1 AWS ec2 instance and using that I setup kubernetes cluster 1 master with 2 nodes(using kops) and it's running properly. now i want to access kubernetes cluster in another aws ec2 instance how can I do that.

-- Devendra Pal Singh
kops
kubectl
kubernetes

1 Answer

8/14/2018

I'm assuming you have created Amazon S3 bucket for each cluster. Now you have to export KOPS_STATE_STORE variable for each cluster for kops to know which environment to load.

Something like the following:

cluster_1.env:

export KOPS_STATE_STORE=s3://aws-kops-bucket-1

cluster_2.env:

export KOPS_STATE_STORE=s3://aws-kops-bucket-2

If you are running these clusters under two different accounts, you also need to export AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY variables for the given s3 bucket's account authorization.into each .env file appropriate credentials:

export AWS_ACCESS_KEY_ID=id_key export AWS_SECRET_ACCESS_KEY=secret_access_key

So, in order to switch the cluster, you would just need source cluster_1.env or source cluster_2.env that would load the desired environment.

I also found a GitHub issue for kops Enable Cluster Switching - Map kops clusters to aws buckets and profiles #1177 that might be helpful to you.

-- Crou
Source: StackOverflow