클러스터와 컨텍스트 ⤢ kubectl cluster-info컨트롤 플레인과 핵심 서비스가 어디서 실행되는지 보여줍니다. kubectl cluster-info ⤢ kubectl config get-contexts전환할 수 있는 클러스터와 namespace를 나열합니다. kubectl config get-contexts ⤢ kubectl config use-context다른 클러스터 또는 namespace 컨텍스트로 전환합니다. kubectl config use-context my-prod ⤢ kubectl config set-context --current --namespace현재 컨텍스트의 기본 namespace를 설정합니다. kubectl config set-context --current --namespace=staging ⤢ kubectl config rename-contextkubeconfig에 저장된 컨텍스트의 이름을 바꿉니다. kubectl config rename-context old-name prod ⤢ kubectl api-resources클러스터가 알고 있는 모든 리소스 유형을 나열합니다. kubectl api-resources ⤢ kubectl version클라이언트와 서버의 쿠버네티스 버전을 출력합니다. kubectl version ⤢ kubectl explainAPI 스키마에서 읽어 온 리소스의 필드를 보여줍니다. kubectl explain pod.spec.containers ⤢ kubectl auth can-i현재 사용자가 주어진 동작을 실행할 수 있는지 확인합니다. kubectl auth can-i delete pods 워크로드 조회 ⤢ kubectl get podsPod와 상태를 나열합니다. -o wide를 붙이면 노드와 IP도 보여줍니다. kubectl get pods -A ⤢ kubectl get all한 번의 호출로 namespace의 주요 리소스를 나열합니다. kubectl get all ⤢ kubectl get -o wide모든 get 명령에 노드와 IP 열을 추가합니다. kubectl get pods -o wide ⤢ kubectl get -o yaml리소스를 뒷받침하는 전체 YAML 매니페스트로 출력합니다. kubectl get deploy/web -o yaml ⤢ kubectl get deploymentsDeployment와 준비된 레플리카 수를 나열합니다. kubectl get deployments ⤢ kubectl get statefulsetsStatefulSet과 준비된 레플리카를 나열합니다. kubectl get statefulsets ⤢ kubectl get jobs, cronjobs배치 Job과 예약된 CronJob을 나열합니다. kubectl get jobs,cronjobs ⤢ kubectl describe podPod 하나의 이벤트, 레이블, 상태를 보여줍니다. kubectl describe pod web-abc ⤢ kubectl describe node노드의 용량, 조건, 실행 중인 Pod를 보여줍니다. kubectl describe node node-1 ⤢ kubectl logsPod의 stdout을 출력합니다. -f는 추적, --previous는 마지막 크래시 분입니다. kubectl logs -f web-abc ⤢ kubectl exec실행 중인 Pod 안에서 명령을 실행합니다. kubectl exec -it web-abc -- sh ⤢ kubectl topPod 또는 노드의 실시간 CPU와 메모리입니다(metrics-server 필요). kubectl top pods ⤢ kubectl get events이미지 가져오기 실패, 백오프 같은 최근 이벤트를 나열합니다. kubectl get events -A --sort-by=.lastTimestamp ⤢ kubectl get ingressIngress 규칙과 로드밸런서 주소를 나열합니다. kubectl get ingress ⤢ kubectl cp내 컴퓨터와 실행 중인 Pod 사이에 파일을 복사합니다. kubectl cp web-abc:/var/log/app.log ./app.log ⤢ kubectl wait리소스가 조건을 충족할 때까지 대기합니다. kubectl wait --for=condition=ready pod -l app=web ⤢ kubectl run이미지에서 일회용 Pod를 시작합니다. 매니페스트가 필요 없습니다. kubectl run debug --rm -it --image=busybox -- sh 적용, 스케일, 롤아웃 ⤢ kubectl diffapply가 변경할 내용을 실제로 변경하지 않고 보여줍니다. kubectl diff -f deploy.yaml ⤢ kubectl apply -f매니페스트 파일에서 리소스를 만들거나 업데이트합니다. kubectl apply -f deploy.yaml ⤢ kubectl apply --prune매니페스트를 적용하고 빠져나간 객체는 삭제합니다. kubectl apply -f dir/ --prune -l app=web ⤢ kubectl edit라이브 리소스를 편집기로 열고 저장 시 적용합니다. kubectl edit deploy/web ⤢ kubectl patch라이브 리소스의 일부 필드를 변경합니다. kubectl patch deploy/web --patch-file fix.json ⤢ kubectl set imageDeployment의 컨테이너를 새 이미지로 가리키게 합니다. kubectl set image deploy/web web=nginx:1.27 ⤢ kubectl replace --force객체를 교체하며, 필요하면 삭제 후 다시 만듭니다. kubectl replace --force -f deploy.yaml ⤢ kubectl delete -f매니페스트 파일에 선언된 리소스를 제거합니다. kubectl delete -f deploy.yaml ⤢ kubectl scaleDeployment의 레플리카 수를 변경합니다. kubectl scale deploy/web --replicas=4 ⤢ kubectl rollout status롤아웃이 완료되거나 실패하는 것을 지켜봅니다. kubectl rollout status deploy/web ⤢ kubectl rollout history롤아웃이 거쳐 온 리비전을 나열합니다. kubectl rollout history deploy/web ⤢ kubectl rollout restartDeployment의 모든 Pod를 한 번에 하나씩 재시작합니다. kubectl rollout restart deploy/web ⤢ kubectl rollout undoDeployment를 이전 리비전으로 되돌립니다. kubectl rollout undo deploy/web 서비스와 네트워킹 ⤢ kubectl get svc서비스와 유형, 클러스터 IP를 나열합니다. kubectl get svc ⤢ kubectl get endpoints현재 각 서비스를 지탱하는 Pod IP를 보여줍니다. kubectl get endpoints web ⤢ kubectl exposePod 집합 앞에 서는 서비스를 만듭니다. --type=NodePort 또는 LoadBalancer는 클러스터 밖에서 접근합니다. kubectl expose deploy/web --port=80 ⤢ kubectl ingress status각 Ingress 뒤에 있는 로드밸런서 주소를 보여줍니다(alpha). kubectl ingress status -A ⤢ kubectl get networkpoliciesPod 트래픽을 제한하는 정책을 나열합니다. kubectl get networkpolicies ⤢ kubectl port-forward로컬 포트를 Pod 또는 서비스로 터널링합니다. kubectl port-forward svc/web 8080:80 노드와 유지보수 ⤢ kubectl get nodes클러스터 노드와 상태를 나열합니다. kubectl get nodes -o wide ⤢ kubectl cordon노드를 스케줄 불가로 표시합니다(새 Pod 없음). kubectl cordon node-1 ⤢ kubectl uncordon노드를 다시 스케줄 가능으로 표시합니다. kubectl uncordon node-1 ⤢ kubectl drain노드에서 Pod를 축출하고 스케줄 불가로 표시합니다. kubectl drain node-1 --ignore-daemonsets ⤢ kubectl taint노드에서 Pod를 밀어내는 taint를 추가하거나 제거합니다. kubectl taint node node-1 key=value:NoSchedule ⤢ kubectl delete pod --grace-period=0 --force정상 종료를 건너뛰고 걸린 Pod를 즉시 삭제합니다. kubectl delete pod web-abc --grace-period=0 --force 객체와 설정 ⤢ kubectl create namespace리소스 범위를 지정할 새 namespace를 만듭니다. kubectl create namespace staging ⤢ kubectl get namespacesnamespace와 상태를 나열합니다. kubectl get namespaces ⤢ kubectl create configmap설정 키나 파일을 클러스터 객체로 저장합니다. kubectl create configmap app --from-file=config.yaml ⤢ kubectl get configmapsnamespace의 ConfigMap을 나열합니다. kubectl get configmaps ⤢ kubectl create secret비밀번호나 인증서를 Secret으로 저장합니다. kubectl create secret generic db --from-literal=password=s3cret ⤢ kubectl get secretsnamespace의 Secret을 나열합니다. kubectl get secrets ⤢ kubectl label리소스에 레이블을 붙이거나 제거합니다. kubectl label pod web-abc tier=backend ⤢ kubectl annotate셀렉터가 매칭할 수 없는 메타데이터를 붙입니다. kubectl annotate deploy/web release=july