민한의 블로그

쿠버네티스 기본 구조 및 kubectl 명령어, 오브젝트 설명 (작성중..) 본문

인프라/k8s

쿠버네티스 기본 구조 및 kubectl 명령어, 오브젝트 설명 (작성중..)

minhan2 2021. 9. 23. 15:50
728x90
반응형

yaml 이란? 문법은?


nginx 를 설치
index.html 교체
docker file build commit push

각각 오브젝트 생성하는것
yaml파일로 만들어 놓자.

k8s에서 이미지 설정 및 실행

kubectl 주요 명령어

  • get : 오브젝트 조회
kubectl get pod
  • run, create, apply - 오브젝트 생성
kubectl run nginx --image=nginx

kubectl create deploy nginx --image=nginx

kubectl apply -f ~/minhan/apply-nginx.yaml
  • delete - 오브젝트 삭제
kubectl delete pod nginx

kubectl delete deployments.apps nginx
  • exec - 파드 내부의 컨테이너로 접속
kubectl exec nginx -it -- /bin/bash
  • scale - 파드 갯수를 늘리거나 줄임
kubectl scale deployment nginx --replicas=3
  • edit - 배포된 오브젝트를 수정
kubectl edit deployment nginx

kubectl 주요 상태 확인 명령어

  • events : 쿠버네티스 이벤트 확인
kubectl get events

kubecetl get events -n kube-system
  • describe : 배포된 오브젝트의 상태를 파악
kubectl describe pod nginx
  • logs : 컨테이너의 로그 확인
kubectl logs nginx

kubectl 주요 옵션

  • "-o yaml" : 출력 형태를 변환함 (ex: json, yaml ...등)
kubectl get pod nginx -o yaml
  • "--dry-run=client" : 실제로 실행은 하지않고, 코드를 생성함, "-o yaml"과 자주 함께 사용됨, 테스트용도로 어떻게 실행될지 확인하기 위해
kubectl run nginx --image=nginx --dry-run=client -o yaml > pod-nginx.yaml
  • "-w" : watch. 명령어를 1회로 그치지않고, 계속 보여준다
kubectl get pod -w

K8S 작동 구조

K8S 기본 구성

CONTAINER

NODE

CLUSTER

K8S 배포법

POD

StatefulSet

DEPLOYMENT

REPLICASET

DAEMONSET

JOB

K8S 노출법

SERVICE

NODE_PORT

EXTERNAL_PORT

LOAD_BALANCER

INGRESS

K8S 기타 구성

HPA

VPA

SECRET

VOLUME

728x90
반응형
Comments