1. kubectl get: 리소스 조회
- 전체 파드 목록 조회:
kubectl get pods
- 특정 네임스페이스에서 파드 조회:
kubectl get pods -n <namespace>
- 전체 서비스 목록 조회:
kubectl get svc
- 특정 네임스페이스에서 서비스 조회:
kubectl get svc -n <namespace>
- 전체 디플로이먼트 조회:
kubectl get deployments
2. kubectl describe: 리소스 상세 정보 조회
- 파드 상세 정보 조회:
kubectl describe pod <pod_name>
- 디플로이먼트 상세 정보 조회:
kubectl describe deployment <deployment_name>
3. kubectl logs: 파드 로그 조회
- 특정 파드의 로그 조회:
kubectl logs <pod_name>
- 다중 컨테이너 파드에서 로그 조회:
kubectl logs <pod_name> -c <container_name>
4. kubectl exec: 파드 내에서 명령 실행
- 파드 내에서 명령어 실행:
kubectl exec -it <pod_name> -- <command>kubectl exec -it <pod_name> -- /bin/bash
5. kubectl apply: 리소스 배포/수정
- YAML 파일을 이용한 리소스 배포:
kubectl apply -f <file_name>.yaml
- 디플로이먼트 업데이트:
kubectl apply -f <deployment_file>.yaml
6. kubectl delete: 리소스 삭제
- 특정 파드 삭제:
kubectl delete pod <pod_name>
- 디플로이먼트 삭제:
kubectl delete deployment <deployment_name>
7. kubectl create: 리소스 생성
- 파드 생성:
kubectl create -f <pod_file>.yaml
- 서비스 생성:
kubectl create -f <service_file>.yaml
8. kubectl scale: 리소스 스케일링
- 디플로이먼트의 파드 수 조정:
kubectl scale deployment <deployment_name> --replicas=<number_of_replicas>
9. kubectl get nodes: 노드 조회
- 전체 노드 목록 조회:
kubectl get nodes
10. kubectl port-forward: 로컬에서 포트 포워딩
- 로컬에서 파드의 포트에 접속하기:
kubectl port-forward pod/<pod_name> <local_port>:<pod_port>
11. kubectl top: 리소스 사용량 조회
- 클러스터 노드의 리소스 사용량 조회:
kubectl top nodes
- 파드의 리소스 사용량 조회:
kubectl top pods
12. kubectl config: 설정 관리
- 현재 사용 중인 컨텍스트 확인:
kubectl config current-context
- 새로운 컨텍스트 설정:
kubectl config use-context <context_name>
반응형
'Chapter01 > Kubernetes' 카테고리의 다른 글
[ Kubernetes ] 클러스터의 관리 및 오케스트레이션 (0) | 2025.02.26 |
---|---|
[ Kubernetes ]MetalLB와 Ingress 사용해 배포하기 (0) | 2024.09.30 |
[ Kubernetes ] MetalLB와 Ingress를 사용해 외부에서 접근 가능한 인프라 구축 (0) | 2024.09.30 |
[ Kubernetes ] .yaml로 Nginx Pod을 K8S cluster에 배포하기 (0) | 2024.09.03 |
[ Kubernetes ] 설치하기 (0) | 2024.08.26 |