1. Get
# default namespace의 pod 보기
kubectl get pod
# default namespace의 pod 자세히 보기
kubectl get pod -o wide
# 모든 namespace의 pod 보기
kubectl get pod --all-namespaces
# pod watch mode로 보기
kubectl get pod -w
# default namespace의 deployment 조회
kubectl get deploy
# 모든 namespace의 모든 deployment 조회
kubectl get deploy --all-namespaces
# default namespace의 service 조회
kubectl get service
kubectl get svc
# 모든 namespace의 모든 service 조회
kubectl get service --all-namespaces
kubectl get svc --all-namespaces
# node 조회
kubectl get node
2. Create
# sample.yaml로 생성하기
kubectl create -f sample.yaml
# yaml 파일의 코드가 맞는지 확인하기
kubectl create -f sample.yaml --dry-run=client
# 명령어로 create 후 yaml 파일 생성하기
kubectl create deploy {deploy name} --image=nginx --dry-run=client -o yaml > nginx.yaml
3. Delete
# sample.yaml로 생성된 내용 삭제
kubectl delete -f sample.yaml
# 포드 삭제
kubectl delete {Pod 명}
# 모든 자원 삭제
kubectl delete all --all
4. Describe
# node 정보 확인
kubectl get nodes
kubectl describe nodes {node 명}
# pod 정보 확인
kubectl get pods
kubectl describe pod {pod 명}
5. Exec
# pod에 bash로 들어가기
kubectl exec -it {Pod 명} /bin/bash
# pod에서 curl 실행하기
kubectl exec {Pod 명} --curl localhost:8080
6. Log
# pod 로그 확인
kubectl logs {Pod 명}
# pod 로그 trail
kubectl logs -f {Pod 명}
7. Edit
# 현재 동작 중인 Pod 수정
kubectl edit pod {Pod 명}
kubectl replace --force -f {temp yaml 경로}