← Main page

Kubernetes commands

Useful aliases

kp='kubectl -n my-namespace --kubeconfig ~/.kube/config-prod'

kp-port-forward='kp port-forward svc/elasticsearch-master 9200:9200'

Show pods in all namespaces

kp get pod -A

Show services

kp get service

Show deployments

kp get deployment

Show nodes

kp get node

Show persistence volume claims

kp get pvc

Run shell in a pod container

kp exec -ti pod-name -c container-name -- /bin/bash

Copy a file from a pod

kp cp -c container-name pod-name:/srv/app/file_name.log file_name.log

Double dash in a command

The double dash ( -- ) in kubectl command separates the arguments you want to pass to the command from the kubectl arguments.