kubectl commands Flashcards
Show Merged kubeconfig settings
kubectl config view
Use multiple kubeconfig files at the same time
KUBECONFIG=~/.kube/config:~/.kube/kubconfig2
Get the password for the e2e user
kubectl config view -o jsonpath=’{.users[?(@.name == “e2e”)].user.password}’
Display list of contexts
kubectl config get-contexts
Display the current-context
kubectl config current-context
Set the default context to my-cluster-name
kubectl config use-context my-cluster-name
Add a new user to your kubeconf that supports basic auth
kubectl config set-credentials kubeuser/foo.kubernetes.com –username=kubeuser –password=kubepassword
Permanently save the namespace for all subsequent kubectl commands in that context
kubectl config set-context –current –namespace=ggckad-s2
Set a context utilizing a specific username and namespace
kubectl config set-context gce –user=cluster-admin –namespace=foo && kubectl config use-context gce
Delete user foo
kubectl config unset users.foo
Create resource(s)
kubectl apply -f ./my-manifest.yaml
Create from multiple files
kubectl apply -f ./my1.yaml -f ./my2.yaml
Create resource(s) in all manifest files in dir
kubectl apply -f ./dir
Create resource(s) from url
kubectl apply -f https://git.io/vPieo
Start a single instance of nginx
kubectl create deployment nginx –image=nginx