kubectl
This guide assumes that you've set up saml2aws.
Setup + connect
Add kubectl to local tools
Update ~/.tool-versions to include the following:
terraform 1.0.2
kubectl 1.21.2
awscli 2.2.13
Connect to a cluster from your local command line
- Login to the AWS CLI using credentials sent via slack (search for the
External CI'app')
Set those credentials using aws config (or just modify the file at ~/.aws/credentials)
- Set AWS CLI to the correct cluster
$ aws eks --region us-east-1 update-kubeconfig --name product-eng-stg
$ aws eks --region us-east-1 update-kubeconfig --name product-eng-prod
- Test it out by retrieving the cluster's namespaces
$ kubectl get ns
Common commands
Cheat Sheet: https://kubernetes.io/docs/reference/kubectl/cheatsheet/
Get namespaces
$ kubectl get ns
Get deployments
$ kubectl -n my-namespace get deploy
Get jobs (migrations)
$ kubectl -n my-namespace get jobs
View logs for a deployment
$ kubectl -n my-namespace logs deploy/my-deploy -f
View logs for a job
$ kubectl -n my-namespace logs job/my-job -f
Get pods in a namespace
$ kubectl -n my-namespace get pods
View pods performance in a namespace
$ kubectl -n my-namespace top pods
SSH into a running pod
$ kubectl -n my-namespace exec my-pod -it -- /bin/sh
Delete a pod
$ kubectl -n my-namespace delete pod my-pod