Kops commands

March 7, 2019

Quick commands for Kops.

First set the environment variable $NAME and KOPS_STATE_STORE.

$ export NAME=kubernetes-cluster.example.com
$ export KOPS_STATE_STORE=s3://kops

Get kubecfg

You can export a kubecfg file for a cluster from the state store. The config will be save in ~/.kube/conf, after that you can use the command kubectl.

$ kops export kubecfg $NAME 

List of clusters

$ kops get cluster

Get cluster config

$ kops get --name $NAME -o yaml

Edit cluster

You can download the current configuration to your computer and edit with some text editor, also this method allow to you to modified the instances groups for the master and nodes.

$ kops get --name $NAME -o yaml > kops.yml
$ vi kops.yml
$ kops replace -f kops.yml
$ kops update cluster $NAME
$ kops rolling-update cluster $NAME

# Rolling update only AWS layer.
# This helps if you lose connectivity with the Kubernetes API.
$ kops rolling-update cluster --cloudonly --force

The commands for update and rolling-update runs as dry-run, you need to add --yes to apply the configuration.

Create cluster from yaml file

If you have already the yaml file with the cluster configuration you can create a cluster from it.

You need a SSH public key for the admin user.

$ kops replace -f cluster_config.yml --force
$ kops create secret --name $NAME sshpublickey admin -i ssh_public_key.pub
$ kops update cluster $NAME
$ kops update cluster $NAME --yes