kubectl api-resources
오브젝트들의 종류와 약어를 출력한다.

ex) kubectl get po 는 kubectl get pods와 같다.
kubectl --help
kubectl의 명령어 도움말
ex) kubectl logs --help 는 logs에 관한 도움말이다.
kubectl get nodes
node들의 정보를 출력한다.
ex) kubectl get nodes -o wide 는 node들의 정보를 자세히 출력한다.
kubectl describe node [node 이름]
node의 정보를 아주 자세히 출력한다.

kubectl run [pod 이름] --image=[이미지 종류] [옵션]
pod를 생성하여 실행한다.
ex) kubectl run webserver --image=nginx:1.14 --port 80

ex) kubectl run webserver --image=nginx:1.14 --port 80 --dry-run -o yaml > webserver-pod.yaml
실행할 수 있는 pod를 --dry-run 옵션으로 확인한 후 쿠버네티스가 사용할 수 있는 webserver-pod.yaml 이라는 파일을 생성한다.

그 후 vi 에디터로 webserver-pod.yaml를 아래와 같이 수정한다.

kubectl create deployment [pod 이름] --image=[이미지 종류] [옵션]
pod를 생성시킨다.
ex) kubectl create deployment mainui --image=httpd --replicas=3 은 아파치 이미지 pod를 mainui라는 이름으로 3개 생성한다.


kubectl exec [pod 이름] [옵션]
컨테이터 속으로 접속할 수 있다.
ex) kubectl exec webserver -it -- /bin/bash 는 이전에 생성한 nginx pod인 webserver에 접속한다.
kubectl logs [pod 이름]
컨테이너에 접속한 기록을 볼 수 있다.
kubectl port-forword [pod 이름] [포트번호]
컨테이너를 포트포워딩 할 수 있다.

kubectl edit deployments.apps [pod 이름]
deploy한 pod를 편집한다.
ex)


replicas를 3 대신 2로 수정하면 mainui는 2개로 줄어든다.


kubectl delete pod [pod 이름]
pod를 삭제한다.
ex)


kubectl create -f [yaml 파일 이름]
yaml파일을 이용해서 pod를 생성한다.
ex) kubectl create -f webserver-pod.yaml

'따배쿠' 카테고리의 다른 글
| [따배쿠] 5-1-2. 쿠버네티스 Pod - Pod 동작 flow (0) | 2022.11.01 |
|---|---|
| [따배쿠] 5-1-1. 쿠버네티스 Pod - Container 정리와 Single / Multi Container Pod 생성 (0) | 2022.11.01 |
| [따배쿠] 4-3. 쿠버네티스 아키텍처 - yaml템플릿과 API (0) | 2022.11.01 |
| [따배쿠] 4-2. 쿠버네티스 아키텍처 - namespace (0) | 2022.11.01 |
| [따배쿠] 4-1. 쿠버네티스 아키텍처 - Kubernetes 동작원리 (0) | 2022.11.01 |