728x90
반응형
kubectl run
Pod 실행
# sudo kubectl run Pod명 --image 이미지명 --restart Never [root@]$ sudo kubectl run devpd --image nginx --restart Never pod/devpd created |
kubectl get pod
pod 조회
# sudo kubectl get pod Pod명 [root@]$ sudo kubectl get pod devpd NAME READY STATUS RESTARTS AGE devpd 1/1 Running 0 4m33s |
-o yaml
yaml파일 출력
-o: output
# sudo kubectl get pod Pod명 -o yaml [root@]$ sudo kubectl get pod devpd -oyaml apiVersion: v1 kind: Pod metadata: creationTimestamp: "2024-08-12T06:47:32Z" labels: run: devpd name: devpd namespace: default resourceVersion: "2956" selfLink: /api/v1/namespaces/default/pods/devpd uid: 4a57107a-2cfb-4110-b6bb-1eb339d19715 |
kubectl describe
Pod 상태 확인
# sudo kubectl describe pod Pod명 [root@]$ sudo kubectl describe pod devpd Name: devpd Namespace: default Priority: 0 Node: master/IP Start Time: Mon, 12 Aug 2024 15:47:32 +0900 Labels: run=devpd Annotations: <none> Status: Running |
kubectl exec
Pod 명령어 실행
# sudo kubectl exec Pod명 -- 명령어 [root@]$ sudo kubectl exec devpd -- apt update WARNING: apt does not have a stable CLI interface. Use with caution in scripts. Ign:1 http://deb.debian.org/debian bookworm InRelease Ign:2 http://deb.debian.org/debian bookworm-updates InRelease Ign:3 http://deb.debian.org/debian-security bookworm-security InRelease Ign:1 http://deb.debian.org/debian bookworm InRelease Ign:2 http://deb.debian.org/debian bookworm-updates InRelease Ign:3 http://deb.debian.org/debian-security bookworm-security InRelease Ign:1 http://deb.debian.org/debian bookworm InRelease |
-- printenv
환경변수 조회
#sudo kubectl exec pod이름 -- printenv [root@]$ sudo kubectl exec devpd -- printenv PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin HOSTNAME=devpd KUBERNETES_PORT_443_TCP_PROTO=tcp KUBERNETES_PORT_443_TCP_PORT=443 KUBERNETES_PORT_443_TCP_ADDR=10.43.0.1 KUBERNETES_SERVICE_HOST=10.43.0.1 KUBERNETES_SERVICE_PORT=443 KUBERNETES_SERVICE_PORT_HTTPS=443 KUBERNETES_PORT=tcp://10.43.0.1:443 KUBERNETES_PORT_443_TCP=tcp://10.43.0.1:443 NGINX_VERSION=1.27.1 NJS_VERSION=0.8.5 NJS_RELEASE=1~bookworm PKG_RELEASE=1~bookworm DYNPKG_RELEASE=2~bookworm HOME=/root |
kubectl logs
Pod 로그 확인
# sudo kubectl logs Pod명 [root@]$ sudo kubectl logs devpd /docker-entrypoint.sh: /docker-entrypoint.d/ is not empty, will attempt to perform configuration /docker-entrypoint.sh: Looking for shell scripts in /docker-entrypoint.d/ /docker-entrypoint.sh: Launching /docker-entrypoint.d/10-listen-on-ipv6-by-default.sh 10-listen-on-ipv6-by-default.sh: info: Getting the checksum of /etc/nginx/conf.d/default.conf 10-listen-on-ipv6-by-default.sh: info: Enabled listen on IPv6 in /etc/nginx/conf.d/default.conf /docker-entrypoint.sh: Sourcing /docker-entrypoint.d/15-local-resolvers.envsh /docker-entrypoint.sh: Launching /docker-entrypoint.d/20-envsubst-on-templates.sh /docker-entrypoint.sh: Launching /docker-entrypoint.d/30-tune-worker-processes.sh /docker-entrypoint.sh: Configuration complete; ready for start up |
kubectl delete
Pod 삭제
# sudo kubectl delete pod Pod명 [root@]$ sudo kubectl delete pod devpd pod "devpd" deleted |
kubectl cp
서버 내 파일을 Pod로 복사
# sudo kubectl cp 파일경로 Pod명:경로 [root@]$ sudo kubectl cp ./cpTest devpd:/. [root@]$ sudo kubectl exec devpd -- cat /cpTest cpTest |
kubectl --namespace
namespace별 Pod 조회
# sudo kubectl get po -n 네임스페이스 [root@]$ sudo kubectl get po -n kube-system NAME READY STATUS RESTARTS AGE local-path-provisioner-58fb86bdfd-l29xt 1/1 Running 1 44h coredns-6c6bb68b64-ssccc 1/1 Running 1 44h |
kubectl label node
노드에 라벨 추가
# sudo kubectl label node 노드명 key=value [root@]$ sudo kubectl label node master weather=tooHot [root@]$ sudo kubectl get node master -o yaml apiVersion: v1 kind: Node labels: weather: tooHot name: master ... |
728x90
반응형
'클라우드 > 쿠버네티스' 카테고리의 다른 글
[클라우드/쿠버네티스] 라벨, 노드셀렉터 (0) | 2024.08.23 |
---|---|
[클라우드/쿠버네티스] Pod 구조 (0) | 2024.08.20 |
[클라우드/쿠버네티스] 쿠버네티스 윈도우 설치 (0) | 2024.08.12 |
[클라우드/쿠버네티스] ConfigMap (0) | 2024.06.29 |
[클라우드/쿠버네티스] 쿠버네티스 배포 (0) | 2024.06.26 |
댓글