
현재 클러스터에 생성된 Pod 목록을 조회합니다.
$ kubectl get pods
로컬 머신에서 특정 포트를 Pod 내부 포트로 연결합니다.
# kubectl port-forward pod/[파드명] [로컬 포트]:[Pod 포트]
$ kubectl port-forward pod/nginx-pod 80:80
특정 Pod를 삭제합니다.
# kubectl delete pod [파드명]
$ kubectl delete pod nginx-pod
Pod의 상세 정보를 확인합니다.
# kubectl describe pods [파드명]
$ kubectl describe pods nginx-pod
Pod 내부 애플리케이션에서 출력한 로그를 확인합니다.
# kubectl logs [파드명]
$ kubectl logs nginx-pod
Pod 내부에 접속하여 상태를 점검하거나 명령을 실행합니다.
# bash 쉘로 접속
$ kubectl exec -it nginx-pod -- bash
# sh 쉘로 접속 (bash가 없는 경우)
$ kubectl exec -it nginx-pod -- sh
매니페스트 파일에 정의된 리소스를 생성합니다.
# kubectl apply -f [파일명]
$ kubectl apply -f nginx-pod.yaml
현재 클러스터에 생성된 Deployment 목록을 조회합니다.
$ kubectl get deployment
특정 Deployment를 삭제합니다.
# kubectl delete deployment [디플로이먼트명]
$ kubectl delete deployment spring-deployment
현재 클러스터에 생성된 Service 목록을 조회합니다.
$ kubectl get service
특정 Service를 삭제합니다.
# kubectl delete service [서비스명]
$ kubectl delete service spring-service
매니페스트 파일에 정의된 리소스(파드, 디플로이먼트, 서비스 등)를 생성합니다.
# kubectl apply -f [파일명]
$ kubectl apply -f nginx-pod.yaml
클러스터 내 모든 리소스를 삭제합니다.
$ kubectl delete all --all