본문 바로가기
Develop

[k8s] 구성 요소별 관련 명령어

by 너드나무 2024. 10. 2.
반응형

노드 관련 명령어 (Node Commands)

kubectl get nodes                 # 클러스터 내 모든 노드 조회
kubectl delete node <node_name>   # 특정 노드 삭제
kubectl label node <node_name> <label_key>=<label_value>  # 노드에 레이블 추가
kubectl describe node <node_name> # 특정 노드의 상세 정보 조회
kubectl top node <node_name>      # 특정 노드의 CPU 및 메모리 사용량 조회

파드 관련 명령어 (Pod Commands)

kubectl get pods                    # 모든 파드 목록 조회
kubectl get pods --output=wide       # 파드에 대한 상세 정보 조회
kubectl run <pod_name> --image=<image_name>  # 특정 이미지를 기반으로 파드 실행
kubectl describe pod <pod_name>      # 특정 파드의 상세 정보 확인
kubectl delete pod <pod_name>        # 특정 파드 삭제
kubectl logs <pod_name>              # 특정 파드의 로그 조회
kubectl exec -it <pod_name> -- <command>  # 파드 내에서 명령 실행

네임스페이스 관련 명령어 (Namespace Commands)

kubectl create namespace <namespace_name>  # 네임스페이스 생성
kubectl get namespace                      # 네임스페이스 목록 조회
kubectl delete namespace <namespace_name>  # 특정 네임스페이스 삭제
kubectl config set-context --current --namespace=<namespace_name>  # 기본 네임스페이스 설정

서비스 관련 명령어 (Service Commands)

kubectl get svc                          # 모든 서비스 조회
kubectl describe svc <service_name>      # 특정 서비스의 상세 정보 조회
kubectl delete svc <service_name>        # 특정 서비스 삭제
kubectl expose pod <pod_name> --port=<external_port> --target-port=<internal_port>  # 파드를 서비스로 노출
kubectl port-forward svc/<service_name> <local_port>:<target_port>  # 포트 포워딩 설정

DaemonSet 관련 명령어 (DaemonSet Commands)

kubectl get daemonsets                    # 모든 DaemonSet 목록 조회
kubectl describe daemonset <daemonset_name>  # 특정 DaemonSet의 상세 정보 조회
kubectl delete daemonset <daemonset_name>  # 특정 DaemonSet 삭제
kubectl rollout restart daemonset <daemonset_name>  # DaemonSet 롤링 재시작

이벤트 관련 명령어 (Event Commands)

kubectl get events                        # 모든 이벤트 조회
kubectl describe events <event_name>      # 특정 이벤트의 상세 정보 조회
kubectl get events --watch                # 실시간 이벤트 모니터링

로그 관련 명령어 (Log Commands)

kubectl logs <pod_name>                   # 특정 파드의 로그 조회
kubectl logs -f <pod_name>                # 특정 파드의 실시간 로그 조회
kubectl logs -l <label_name>              # 특정 레이블을 기준으로 파드 로그 조회
kubectl logs <pod_name> --since=6h        # 마지막 6시간 동안의 로그 조회

상태 및 클러스터 정보 확인 (Cluster Information Commands)

kubectl cluster-info                      # 클러스터 정보 확인
kubectl get nodes                         # 모든 노드 목록 조회
kubectl top nodes                         # 노드별 리소스 사용량 확인
kubectl get pods                          # 파드 목록 확인
kubectl top pod <pod_name>                # 특정 파드의 리소스 사용량 확인
kubectl describe node <node_name>         # 특정 노드의 상세 정보 확인

스토리지 관련 명령어 (Storage Commands)

kubectl get pv                            # 모든 Persistent Volume(PV) 조회
kubectl get pvc                           # 모든 Persistent Volume Claim(PVC) 조회
kubectl create -f <pv.yaml>               # PV 생성
kubectl create -f <pvc.yaml>              # PVC 생성
kubectl delete pv <pv_name>               # 특정 Persistent Volume 삭제
kubectl delete pvc <pvc_name>             # 특정 Persistent Volume Claim 삭제

 

scaleway

728x90
반응형