Cluster Management and CommandsKubectl ContextsChecking Cluster ConnectionUsing kubectl
NamespacesSwitching Contexts
Our cluster runs remotely on Amazon EKS cloud infrastructure. The easiest way to communicate with it from your local machine is through the kubectl
command line utility.
The cluster is separated into three main namespaces: production
, staging
and default
.1 Each namespace functions like a separate virtual cluster, using the same hardware resources. The purposes of the first two are pretty self-explanatory; the last is a general testing ground.
This section gives a quick summary of some useful setup steps.
Whenever you're using kubectl
, it will have an active context. A context is the combination of:
default
You can check that you're talking to the right cluster with:
And make sure you're connected with:
Name | Ready | Status | Restarts | Age |
hello-node-5776cf4bcf-4sjrt | 1/1 | Running | 0 | 3s |
kubectl
There's plenty of articles introducing kubectl
, so I'll mostly skip that and just give the necessary command for a situation. That said, I recommend:
kubectl get <resource-type>
whenever you want to list a type of resource.kubectl get <resource-type> <resource-name> -o yaml
whenever you want to see one object in detail.
Pretty much all objects except for Nodes are specific to a namespace. In order to access them, you'll need to be in the right namespace. Objects in different namespaces can have the same names, so you need to be careful with this one. Your active context is always associated with a namespace, which all your commands will be run in automatically.
You can check the current active namespace on Mac with:
on Windows:
You can change the current context namespace with:
You can run a kubectl
command in a different namespace than the current context using the -n
flag. For example:
Name | Ready | Status | Restarts | Age |
hello-node-5776cf4bcf-4sjrt | 1/1 | Running | 0 | 3s |
vs:
Name | Ready | Status | Restarts | Age |
converter-54dd9668b6-lvhc8 | 1/1 | Running | 0 | 23d |
graphql-77bf76b879-qkbf7 | 1/1 | Running | 0 | 20m |
ui-cddc5db5d-tw2wd | 1/1 | Running | 0 | 23d |
Do you have a different cluster you want to talk to? Then you'll need to change the active context. This will be the case if you want to play around with minikube
at all, for example.
To see available contexts, use:
CURRENT | NAME | CLUSTER | AUTHINFO | NAMESPACE |
* | arn:.../clustername | arn:.../clustername | arn:.../clustername | default |
minikube | minikube | minikube |
This will let you see the contexts available to you. To switch contexts, you'll need their name from the NAME
column:
You can switch back in the same way. If you want to change any of the names, you can edit the ~/.kube/config
file directly.
prometheus
and kube-system
. These are for monitoring and administrating the cluster. ↩