API 리소스

 

alt text

Pod

Pod
쿠버네티스가 컨테이너를 다루는 기본 단위
Pod is a collection of containers that can run on a host.

  1. 1개 이상의 컨테이너로 구성된 컨테이너 집합
  2. 동일 파드 내 컨테이너는 여러 리눅스 네임스페이스를 공유
    • 네트워크 네임스페이스 공유 (동일 노드, IP 사용)
  3. 사용자가 파드를 직접 관리하는 경우는 거의 없음

Manifest

apiVersion: v1
kind: Pod
metadata:
  name: hello
spec:
  containers:
  - name: nginx
    image: nginxdemos/hello:plain-text
    ports:
    - name: http
      containerPort: 80
      protocol: TCP
  - name: debug
    image: posquit0/doraemon:latest

Pod 관련 kubectl 명령어

kubectl apply -f multi.yaml
kubectl delete -f multi.yaml
kubectl get pod
kubectl describe pod hello
kubectl exec -it hello -- bash   # exec default container
kubectl exec -it hello -c debug -- bash   # exec 'debug' container
kubectl logs pod/hello
kubectl logs pod/hello -c debug  # select 'debug' container
kubectl logs pod/hello -o wide
kubectl delete pod/hello
kubectl delete pod debug
kubectl api-resources | grep pod
  • Cluster 접속 후 healthcheck
      minikube ssh
      curl [IP]
    

멀티 컨테이너 파드와 사이드카 패턴

Side-car Pattern
메인 컨테이너를 보조하는 컨테이너와 같이 실행하는 구조 \

  • Examples
    • Filebeat: 로그 에이전트로 파드 로그 수집
    • Envoy: 프록시 서버로 서비스메시 구성
    • Vault Agent: 기밀 데이터 전달
    • Nginx: 설정 리로드 역할 에이전트

ReplicaSet

ReplicaSet
정해진 수의 파드가 항상 실행될 수 있도록 관리
ReplicaSet ensures that a specified number of pod replicas are running at any given time.

  1. selector를 통해 replica의 개수를 조정
    • matchLabels 등
  2. 기존 실행 중이던 파드에 문제가 생기면 파드를 다시 스케줄링
  3. 레플리카셋을 직접 관리하는 경우는 거의 없음

Manifest

apiVersion: apps/v1
kind: ReplicaSet
metadata:
  name: hello
spec:
  replicas: 3
  selector:
    matchLabels:
      app: hello
  template:
    metadata:
      name: hello
      labels:
        app: hello
    spec:
      containers:
      - name: nginx
        image: nginxdemos/hello:plain-text
        ports:
        - name: http
          containerPort: 80
          protocol: TCP

ReplicaSet 관련 kubectl 명령어

kubectl apply -f replicaset.yaml
kubectl delete -f replicaset.yaml
kubectl edit pod [POD]
kubectl get rs
kubectl api-resources | grep replicasets

Deployment

Deployment
파드의 이미지 버전이 갱신될 때 배포 전략을 설정
Deployment enables declarative updates for Pods and ReplicaSets.