[따배쿠] 5-1-1. 쿠버네티스 Pod - Container 정리와 Single / Multi Container Pod 생성

김승오·2024년 9월 10일

쿠버네티스

목록 보기
2/27

Pod 생성하기

  • kubectl run 명령(CLI)으로 생성

    • $ kubectl run webserver --image=nginx:1.14
  • pod yaml을 이용해 생성

    • yaml파일 생성
      $ kubectl run nginx-pod --image=nginx:1.14 --port 80 --dry-run -o yaml > pod-nginx.yaml

    • pod 실행
      $ kubectl create -f pod-nginx.yaml

    • 현재 동작 중인 pod 확인
      $ kubectl get pods
      $ kubectl get pods -o wide
      $ kubectl get pods -o yaml
      $ kubectl get pods -o json

      $ kubectl get pods webserver -o json | grep -i podip

    • pod에 접속해서 결과보기
      $ curl <pod’s IP>

  • .yaml파일

multi-container pod 생성하기

  • pod 내의 컨테이너는 동일한 ip 사용
  • pod 내의 특정 컨테이너 들어가서 확인
    $ kubectl exec multipod -it -c centos-container — /bin/bash
    /# curl localhost
    /# exit
  • 로그 확인
    $ kubectl logs multipod -c nginx-container
  • .yaml파일
profile
코딩코

0개의 댓글