Skip to content

Instantly share code, notes, and snippets.

@ambhojgoyal
Forked from jeffjohnson9046/kops-export-config.sh
Created October 11, 2018 19:41
Show Gist options
  • Select an option

  • Save ambhojgoyal/ae101f41611b9be9c81396ae8c22a4de to your computer and use it in GitHub Desktop.

Select an option

Save ambhojgoyal/ae101f41611b9be9c81396ae8c22a4de to your computer and use it in GitHub Desktop.
How to update kubectl to see a new Kubernetes cluster
# This is something that I always forget and had a surprisingly hard time finding (or better yet, understanding). Here's the
# scenario: a colleague creates a new kubernetes cluster, named" cluster-foo.example.com". You want to look at it (for
# troubleshooting, updating the deployment, whatever). To get your kubectl installation to "see" the new cluster, take the
# following steps:
# ASSUMPTION: You have pointed kops to some location where the cluster configurations are stored
# (I have this in my ~/.bash_profile):
export KOPS_STATE_STORE=s3://example-state-store
# Use kops to get the list of clusters
$ kops get clusters
NAME CLOUD ZONES
cluster-alpha.example.com aws us-west-2a
cluster-bravo.example.com aws us-west-2a
cluster-foo.example.com aws us-west-2a
# Export the configuration of the cluster you care about; this will update your ~/.kube/config file, so kubectl knows about it:
$ kops export kubecfg cluster-foo.example.com
Kops has set your kubectl context to awsstaging.sbtds.org
# Now you should see the cluster-foo.example.com in your list of kubectl contexts:
$ kops config get-contexts
CURRENT NAME CLUSTER AUTHINFO NAMESPACE
cluster-alpha.example.com cluster-alpha.example.com cluster-alpha.example.com
cluster-bravo.example.com cluster-bravo.example.com cluster-bravo.example.com
* cluster-foo.example.com cluster-foo.example.com cluster-foo.example.com
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment