grimoire

personal wiki
git clone git://git.pyratebeard.net/grimoire.git
Log | Files | Refs

kubernetes.md (570B)


      1 # kubernetes
      2 
      3 * list pods for all namespaces
      4 ```
      5 kubectl get pods --all-namespaces
      6 ```
      7 
      8 * get list of containers in pod
      9 ```
     10 kubectl -n <namespace> get pods <pod_name> -o jsonpath='{.spec.containers[*].name}'
     11 ```
     12 
     13 * connect to shell on pod
     14 ```
     15 kubectl exec -it pods/demo -- /bin/bash
     16 ```
     17 
     18 * list all completed pods
     19 
     20 ```
     21 kubectl get pod --field-selector=status.phase==Succeeded
     22 ```
     23 
     24 * delete all completed pods
     25 ```
     26 kubectl delete pod --field-selector=status.phase==Succeeded
     27 ```
     28 
     29 * delete all errored pods
     30 ```
     31 kubectl delete pod --field-selector=status.phase==Failed
     32 ```
     33