명령어 설명
apply 원하는 상태를 적용합니다. 보통 -f 옵션으로 파일과 함께 사용합니다.
get 리소스 목록을 보여줍니다.
describe 리소스의 상태를 자세하게 보여줍니다.
delete 리소스를 제거합니다.
logs 컨테이너의 로그를 봅니다.
exec 컨테이너에 명령어를 전달합니다. 컨테이너에 접근할 때 주로 사용합니다.
config kubectl 설정을 관리합니다.

apply


kubectl apply -f [파일명 또는 URL]

ex)
kubectl apply -f <https://subicura.com/k8s/code/guide/index/wordpress-k8s.yml>

get


kubectl get [TYPE]

ex)
# Pod 조회
kubectl get pod
kubectl get pod -o wide #추가정보 확인가능
kubectl get pod -o yaml #yaml로 표현가능
kubectl get pod -o json #json으로 표현가능
kubectl get pod --show-labels #현재 팟에 할당된 라벨명을 확인가능

# 줄임말(Shortname)과 복수형 사용 가능
kubectl get pods
kubectl get po

# 여러 Type 입력
kubectl get pod,service
kubectl get po,svc

# Pod, ReplicaSet, Deployment, Service, Job 조회 -> all
kubectl get all

describe


kubectl describe [TYPE]/[NAME] 또는 [TYPE] [NAME]

ex)
# pod이면서 이름이 wordpress-74757b6ff-nrx9x 인것을 확인 
kubectl describe po/wordpress-74757b6ff-nrx9x

delete


kubectl delete [TYPE]/[NAME] 또는 [TYPE] [NAME]

ex)
# pod 이면서 이름이 wordpress-74757b6ff-nrx9x 인 pod를 제거
kubectl delete pod/wordpress-74757b6ff-nrx9x