본문 바로가기
K8S

Pod & multi Pod

by ohrohi 2024. 12. 27.
반응형

▶Pod 란?

  • 컨테이너를 표현하는 k8s API의 최소단위
    (Control Plane의 API에서 컨테이너를 실행은 불가)
  • pod에는 하나 또는 여러개의 컨테이너가 포함될 수 있음

▶ pod 생성하기

  • 명령어로 생성하기
kubectl run [파드명] --image=nginx:1.18

 

  • pod yaml을 이용해서 생성
kubectl create -f pod-nginx.yaml

 

  • 현재 동작중인 pod 확인pod에서 실행중인 컨테이너 확인하기
kubectl describe pod [pod NAME]

 

▶ multiple container pod 생성하기

  • yaml 파일안에 'container'가 두개가 들어가있다.
apiVersion: v1
kind: Pod
metadata:
  name: multipod
spec:
  containers:
  - name: nginx-container
    image: nginx:1.18
    ports:
    - containerPort: 80
      protocol: TCP
  - name: centos-container
    image: centos:8
    command:
    - sleep
    - "10000"



  • pod내의 특정 container로 접속하기
kubectl exec [pod명] -c [접속할 컨테이너명] -it -- /bin/bash

 

 

※ multi-container pod에서 container들의 pod명과 IP는 동일

 

  • Container의 로그 확인
kubectl logs multipod -c [container 명]

 

 

pod 관리 하기

  • 동작중인 파드 정보 보기
kubectl get pods
kubectl get pods -o wide
kubectl describe pod [파드명]
  • 동작중인 파드 수정
kubectl edit pod [파드명]
  • 동작중인 파드 삭제
kubectl delete pod [파드명]
kubectl delete pod --all



반응형

'K8S' 카테고리의 다른 글

init container를 적용한 Pod  (0) 2024.12.27
liveness probe (health check)  (0) 2024.12.27
yaml 템플릿 & API  (0) 2024.12.27
Namespace 정리  (0) 2024.12.27
컴포넌트 정의  (0) 2024.12.27