You are here: Home » kubernetes » kubectl
Differences
This shows you the differences between two versions of the page.
| Both sides previous revision Previous revision Next revision | Previous revision | ||
|
kubernetes:kubectl [2022/06/05 12:51] admin |
kubernetes:kubectl [2024/11/22 08:24] (current) admin |
||
|---|---|---|---|
| Line 1: | Line 1: | ||
| ====== Pods ====== | ====== Pods ====== | ||
| + | |||
| + | ==Debug running pod without shell access== | ||
| + | < | ||
| + | kubectl debug [existing-pod-name] -it --image alpine --share-processes --copy-to=my-new-debug-pod-name | ||
| + | </ | ||
| + | |||
| + | < | ||
| + | kubectl debug -it [existing-pod-name] --share-processes --image=apko.kontain.me/ | ||
| + | </ | ||
| ==Delete terminated pods== | ==Delete terminated pods== | ||
| Line 35: | Line 44: | ||
| </ | </ | ||
| - | ==Get secrets with name wildcard== | + | ==Delete all secrets |
| < | < | ||
| - | kubectl get secret --no-headers=true | awk '/db-container-v8-credentials/{print $1}' | xargs kubectl delete secret | + | kubectl get secret --no-headers=true | awk '/[secret-partial-name]/{print $1}' | xargs kubectl delete secret |
| </ | </ | ||
| + | ====== Configmaps ====== | ||
| + | |||
| + | ==Delete all configmaps with custom label== | ||
| + | < | ||
| + | kubectl get configmap | ||
| + | </ | ||
| ====== Wait ====== | ====== Wait ====== | ||
| Line 48: | Line 63: | ||
| kubectl wait --for=delete kind/name -n default --timeout=1200s | kubectl wait --for=delete kind/name -n default --timeout=1200s | ||
| </ | </ | ||
| + | |||
| + | ====== CRD ====== | ||
| + | |||
| + | == Get an object by querying a specific API version == | ||
| + | |||
| + | < | ||
| + | kubectl get [crd].[version].[group] | ||
| + | </ | ||
| + | |||
| + | Example: | ||
| + | < | ||
| + | kubectl get applications.v1alpha1.argoproj.io | ||
| + | </ | ||
| + | |||
| + | ====== GET ========== | ||
| + | |||
| + | == Get objects sorted by creation date == | ||
| + | |||
| + | < | ||
| + | kubectl get [crd] --sort-by=.metadata.creationTimestamp | ||
| + | </ | ||
| + | |||
| + | ====== LABEL ========== | ||
| + | |||
| + | == Label a node == | ||
| + | |||
| + | < | ||
| + | kubectl label nodes k8-master role=master | ||
| + | </ | ||
| + | |||
| + | ====== Volumes ====== | ||
| + | ==Resize statefulset PVC== | ||
| + | < | ||
| + | # for prometheus volumes, delete operator pod first | ||
| + | k scale deploy monitoring-operator --replicas=0 | ||
| + | kubectl delete sts --cascade=orphan sts_name | ||
| + | # update pvc size | ||
| + | kubectl edit pvc pvc_name | ||
| + | # update pvc size in sts | ||
| + | kubectl -n ns edit sts sts_name | ||
| + | </ | ||
| + | |||