Last active
March 29, 2023 11:36
-
-
Save geunho/ca30d9ba8447e50ca93e825c9c99cbff to your computer and use it in GitHub Desktop.
kubectl cheat sheet ๐ซ
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ์ด๋ฏธ์ง ํ์ธ์ ์ํด ์์๋ก /bin/bash pod ๋์ฐ๊ธฐ | |
kubectl run $POD_NAME --rm -i --tty --restart=Never --image=$IMAGE:$TAG --command -- /bin/bash | |
# pod ์ํ ๋ณ๊ฒฝ์ ์ถ๋ ฅํ๊ธฐ - OOMKill ๋ฑ ํ์ธ์ ์ฌ์ฉ | |
kubectl get pod -w | |
# pvc ์ฉ๋ ์ฆ์ค (๋ณ๊ฒฝ ์ ์ฅ ํ ๋ฌผ๊ณ ์๋ pod ์ฌ์์ํด์ผํจ) | |
kubectl edit pvc $PVC_NAME | |
# statefulset pod ์ฌ์์ | |
kc scale sts/mysql --replicas=0 | |
kc scale sts/mysql --replicas=1 | |
# ํด๋ฌ์คํฐ ๋ด ๊ตฌ๋์ค์ธ pod์ ๋ชจ๋ ์ด๋ฏธ์ง ๋ฆฌ์คํ | |
# https://kubernetes.io/ko/docs/tasks/access-application-cluster/list-all-running-container-images/ | |
kubectl get pods -o jsonpath="{.items[*].spec.containers[*].image}" | tr -s '[[:space:]]' '\n' | |
# namespace, pod ์ด๋ฆ๊ณผ ์ด๋ฏธ์ง๋ฅผ ๋ฆฌ์คํ | |
kubectl get pods -o jsonpath='{range .items[*]}{@.metadata.namespace}{"\t"}{@.metadata.name}{"\t"}{@.spec.containers[*].image}{"\n"}{end}' | |
# deploy image ์กฐํ | |
kubectl get deploy $DEPLOY_NAME -o=jsonpath='{$.spec.template.spec.containers[:1].image}' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment