들어가기전에 넘사로 너무 정리 잘해주신 분이 있어서 공유합니다...
[https://bcho.tistory.com/1256
포드란? 쿠버네티스에서 container 가 존재하는 공간이다. 각각의 pods 는 각각의 IP를 가진다. 포드는 여러개의 컨테이들을 수유할 수 있고 이들은 자원을 공유한다.]
DESCRIPTION:
Pod is a collection of containers that can run on a host. This resource is
created by clients and scheduled onto hosts.
FIELDS:
apiVersion <string>
APIVersion defines the versioned schema of this representation of an
object. Servers should convert recognized schemas to the latest internal
value, and may reject unrecognized values. More info:
https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources
kind <string>
Kind is a string value representing the REST resource this object
represents. Servers may infer this from the endpoint the client submits
requests to. Cannot be updated. In CamelCase. More info:
https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds
metadata <Object>
Standard object's metadata. More info:
https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#metadata
spec <Object>
Specification of the desired behavior of the pod. More info:
https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status
status <Object>
Most recently observed status of the pod. This data may not be up to date.
Populated by the system. Read-only. More info:
https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#spec-and-status
쿠버네티스에서는 위와 같이 설명하고 있다. 다시 node 내부에 pods 가 위치하고 pods 내부에 container 가 위치하는 개념이다.
hjkasbnm@cloudshell:~ (booming-rush-384703)$ kubectl get pods -o wide
NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES
hello-world-rest-api-55d9d4c59d-tg6qr 1/1 Running 0 30h 10.112.1.8 gke-cluster-in28minutes-default-pool-a01db792-c40d <none> <none>
hjkasbnm@cloudshell:~ (booming-rush-384703)$ kubectl delete pods hello-world-rest-api-55d9d4c59d-tg6qr
pod "hello-world-rest-api-55d9d4c59d-tg6qr" deleted
hjkasbnm@cloudshell:~ (booming-rush-384703)$ kubectl get pods -o wide
NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES
hello-world-rest-api-55d9d4c59d-rnmwf 1/1 Running 0 13s 10.112.0.2 gke-cluster-in28minutes-default-pool-a01db792-r17p <none> <none>
위의 터미널에서 내가 pods 를 삭제해도 다시 replicatsets에 의해서 pods가 생성되는 것을 알 수 있다.
hjkasbnm@cloudshell:~ (booming-rush-384703)$ kubectl get pods -o wide
NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES
hello-world-rest-api-55d9d4c59d-tg6qr 1/1 Running 0 30h 10.112.1.8 gke-cluster-in28minutes-default-pool-a01db792-c40d <none> <none>
//초기에 하나의 pods 가 실행 중인것을 알 수 있다 물론 하나의 ip를 사용중 이때
hjkasbnm@cloudshell:~ (booming-rush-384703)$ kubectl scale deployment hello-world-rest-api --replicas=3
//replicas=3 으로 늘린다면 자동으로 pods의 수를 3개로 늘리는 작업을 relicasets이 수행한다. 수행이후 상태는 다음과 같다.
hjkasbnm@cloudshell:~ (booming-rush-384703)$ kubectl get pods -o wide
NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES
hello-world-rest-api-55d9d4c59d-cn6k2 1/1 Running 0 8s 10.112.2.3 gke-cluster-in28minutes-default-pool-a01db792-l504 <none> <none>
hello-world-rest-api-55d9d4c59d-gkqnk 1/1 Running 0 8s 10.112.2.2 gke-cluster-in28minutes-default-pool-a01db792-l504 <none> <none>
hello-world-rest-api-55d9d4c59d-rnmwf 1/1 Running 0 3m32s 10.112.0.2 gke-cluster-in28minutes-default-pool-a01db792-r17p <none> <none>
//3개로 늘어난 것을 관찰가능!!
kubectl set image deployment hello-world-rest-api hello-world-rest-api=in28min/hello-world-rest-api:0.0.2.RELEASE
위의 명령줄을 실행해서 deployment에 이미지를 업데이트 해야한다. 위를 실행하면 pods 에서 pulling을 진행한다. 만일 이미지가 잘못되었더라고 현재 실행하고 있는 pods는 계속해서 실행된다. 이미지가 정상이라면 새로운 버전의 이미지를 사용하는 pods들로 업데이트한다.
기본적으로 service 의 다운을 막기 위해서 pods replicaset 에서 하나씩 업그레이드 하고 이미 실행중인 전의 애플리케이션을 종료한다.