Kubernetes

Get Informations

kubectl get {pods/svc/pvc}: list availables {pods/svc/pvc} in your namespace
kubectl logs POD_NAME: return stdout of the pod POD_NAME

Create and delete from yaml file:

kubectl apply -f YAML_FILE

Create a new {pod/svc/pvc} based on the given yaml file.

kubectl delete {pod/svc/pvc} NAME

Delete the {pod/svc/pvc} named NAME.

Connect to a pod

kubectl exec -it POD_NAME -- /bin/bash

Connect and launch a terminal on the pod POD_NAME.

Port forward

kubectl port-forward POD_NAME local_port_number:pod_port_number

Copy

From pod to local machine

kubectl cp POD_NAME:SOURCE_PATH TARGET_PATH

From local machine to pod

kubectl cp SOURCE_PATH POD_NAME:TARGET_PATH

  • Natively handles recursive copy (for directories)