-
Kubernetes (K8S): Object - 2. POD공부합시다!/Kubernetes 2022. 12. 30. 16:32728x90
1. 개요
1.1. K8S 구성요소 중 가장 작은 단위
1.2. Cluster의 Running Process
1.3. K8S의 Container 역할
1.3.1. docker 에서는 단일 Container가 가장 작은 단위의 객체
1.3.2. K8S에서는 POD 내에 여러 Container 존재 - 권장하지 않습니다.
1.4. POD내의 Container 들은 IP주소와 Port 공간을 공유, Localhost를 통해서 서로 검색가능
2. LifeCycle
2.1. Pending
2.1.1. POD가 K8S에 의해서 승인
2.1.2. 아직 Container 이미지가 생성이 완료되지 않은 상태
2.1.3. node에 배치되기 이전 시간 및 이미지 다운로드 시간 포함
2.2. Running
2.2.1. POD가 Node에 결합되었고 모든 Container 생성 완료
2.2.2. 적어도 하나의 Container가 동작중이거나, 시작 또는 재시작 상태
2.3. Succeeded
2.3.1. POD 에 있는 모든 Container가 성공적으로 생성된 상태
2.4. Failed
2.4.1. POD의 모든 Container 종료
2.4.2. 적어도 하나 이상의 Container가 실패로 종료된 상태
2.5. Unknown
2.5.1. POD의 상태를 얻을 수 없는 상태
2.5.2. POD Host와 통신 오류
3. POD 생성, 확인, 수정, 삭제
3.1. config file 작성 - container 1개
3.1.1. pod.yml 생성
pod.yml 3.2. pod 생성 및 세부 정보확인
3.2.1. pod 생성
3.2.2. pod 세부 정보 출력
3.3. config file 작성 - container 2개
3.3.1. pod1.yml
pod1.yml 3.4. POD 세부 설정 확인
3.4.1. pod 생성
3.4.2. pod 세부 정보 출력
파일적용 및 세부정보 pod 세부정보2 3.5. POD 수정
3.5.1. 구성 파일 작성
# vi ./pod/nginx.yml apiVersion: v1 kind: Pod metadata: name: nginx-edit lables: env: proc app: web spec: containers: - name: nginx image: nginx:1.22 ports: - containerPort: 80
3.5.2. 적용 및 pod 확인
# kubectl apply -f ./pod 디렉토리내의 모든 구성파일을 실행 위의 경우에는 ./pod 디렉토리에 nginx.yml파일 하나만 존재 # kubectl get pod -o wide default namespace의 pod 정보를 자세히 출력함 # kubectl describe pod nginx-edit 지정한 pod의 세부 정보 출력 # kubectl exec nginx-edit -it -- bash nginx-edit pod의 default container에 bash에 tty를 대화형으로 실행
3.5.3. 기본 페이지 변경 후 Test
# kubectl exec nginx-edit --it -- bash 아래는 컨테이너 내부에서 작업 nginx-edit) # cat > /usr/share/nginx/html/index.html << EOF <html><body><h1>K8S-NGINX-WEB</h1></body></html> EOF exit # curl 10.32.0.2
3.5.4. 구성 파일에서 nginx 버젼을 1.23으로 변경
# vi ./pod/nginx.yml apiVersion: v1 kind: Pod metadata: name: nginx-edit lables: env: proc app: web spec: containers: - name: nginx image: nginx:1.23 ports: - containerPort: 80
3.5.5. 적용 후 Container 변경 사항 확인
3.6. pod를 이용한 구성파일 수정
3.6.1. pod내 저장된 정보를 직접 변경
# kubectl edit pod nginx-edit 버젼 부분을 1.23 -> 1.22 로 변경하면 바로 적용됨
3.6.2. 변경된 정보 확인
# kubectl get pod -o wide default namespace에 pod가 nginx-edit 하나뿐임으로 # kubectl describe pod nginx-edit 변경된 버젼 정보 확인
3.7. pod 삭제
3.7.1. pod 자체 삭제
# kubectl delete pods nginx-edit kubectl delete pods <pod name>
3.7.2. 구성 파일을 이용한 삭제
# kubectl delete -f ./pod/nginx.yml kubectl delete -f <config filename>
자! 그럼 다음시간에는 Deployment에 대해서 살펴보도록 하겠습니다.
Have a nice day!
728x90'공부합시다! > Kubernetes' 카테고리의 다른 글
Kubernetes(K8S): Job & CronJob (0) 2023.01.03 Kubernetes(K8S): Multi Container POD (0) 2023.01.02 Kubernetes (K8S): Scheduling (0) 2022.12.30 Kubernetes(K8S): yaml 파일 분석 (0) 2022.12.29 Kubernetes (K8S): Network - 2. POD Networking (0) 2022.12.29