kubectl get po kubia-1 -o yaml로 보게되면 아래와 같이 별도 PVC가 생성된 걸 볼 수 있다.
volumes:
- name: data
persistentVolumeClaim:
claimName: data-kubia-1
kubectl get pvc
NAME STATUS VOLUME CAPACITY ACCESS MODES STORAGECLASS AGE
data-kubia-0 Bound pvc-75ab5343-2026-4c6b-9671-671ccd107b92 1Gi RWO standard-rwo 6m58s
data-kubia-1 Bound pvc-b9079d28-9a6b-4585-9bbe-f341a90e4ef5 1Gi RWO standard-rwo 6m34s
파드 가지고 놀기
proxy를 활용해 서버와 통신하기 kubectl proxy
kmg48801@cloudshell:~ (kubers-368504)$ curl localhost:8001/api/v1/namespaces/default/pods/kubia-0/proxy/
You've hit kubia-0
Data stored on this pod: No data posted yet
kmg48801@cloudshell:~ (kubers-368504)$ curl localhost:8001/api/v1/namespaces/default/pods/kubia-0/proxy/
You've hit kubia-0
Data stored on this pod: No data posted yet
kmg48801@cloudshell:~ (kubers-368504)$
kmg48801@cloudshell:~ (kubers-368504)$
kmg48801@cloudshell:~ (kubers-368504)$ curl -X POST -d "Hey There! This greeting was submitted to kubia-0." localhost:8001/api/v1/namespaces/default/pods/kubia-0/proxy/
Data stored on pod kubia-0
kmg48801@cloudshell:~ (kubers-368504)$ curl -X POST -d "Hey There! This greeting was submitted to kubia-0." localhost:8001/api/v1/namespaces/default/pods/kubia-0/proxy/
Data stored on pod kubia-0
kmg48801@cloudshell:~ (kubers-368504)$ curl localhost:8001/api/v1/namespaces/default/pods/kubia-0/proxy/
You've hit kubia-0
Data stored on this pod: Hey There! This greeting was submitted to kubia-0.
kmg48801@cloudshell:~ (kubers-368504)$ curl localhost:8001/api/v1/namespaces/default/pods/kubia-1/proxy/
You've hit kubia-1
Data stored on this pod: No data posted yet
kmg48801@cloudshell:~ (kubers-368504)$ kubectl delete po kubia-0
pod "kubia-0" deleted
kmg48801@cloudshell:~ (kubers-368504)$ curl localhost:8001/api/v1/namespaces/default/pods/kubia-1/proxy/
You've hit kubia-1
Data stored on this pod: No data posted yet
kmg48801@cloudshell:~ (kubers-368504)$ curl localhost:8001/api/v1/namespaces/default/pods/kubia-0/proxy/
You've hit kubia-0
Data stored on this pod: Hey There! This greeting was submitted to kubia-0.
kmg48801@cloudshell:~ (kubers-368504)$
kubia-0 파드를 삭제하고 다시 curl 명령을 날려도 데이터가 저장되어있음을 확인할 수 있다.
헤드리스 서비스의 DNS SRC 레코드 조회
kmg48801@cloudshell:~ (kubers-368504)$ kubectl run -it srvlookup --image=tutum/dnsutils --rm --restart=Never -- dig SRC kubia.default.svc.cluster.local
Warning: Autopilot set default resource requests for Pod default/srvlookup, as resource requests were not specified. See http://g.co/gke/autopilot-defaults.
; <<>> DiG 9.9.5-3ubuntu0.2-Ubuntu <<>> SRC kubia.default.svc.cluster.local
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NXDOMAIN, id: 27895
;; flags: qr rd ra; QUERY: 1, ANSWER: 0, AUTHORITY: 1, ADDITIONAL: 1
;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
;; QUESTION SECTION:
;SRC. IN A
;; AUTHORITY SECTION:
. 30 IN SOA a.root-servers.net. nstld.verisign-grs.com. 2023011400 1800 900 604800 86400
;; Query time: 95 msec
;; SERVER: 10.1.0.10#53(10.1.0.10)
;; WHEN: Sat Jan 14 09:02:55 UTC 2023
;; MSG SIZE rcvd: 107
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 35932
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 3, AUTHORITY: 0, ADDITIONAL: 1
;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
;; QUESTION SECTION:
;kubia.default.svc.cluster.local. IN A
;; ANSWER SECTION:
kubia.default.svc.cluster.local. 30 IN A 10.0.128.90
kubia.default.svc.cluster.local. 30 IN A 10.0.128.91
kubia.default.svc.cluster.local. 30 IN A 10.0.128.92
;; Query time: 3 msec
;; SERVER: 10.1.0.10#53(10.1.0.10)
;; WHEN: Sat Jan 14 09:02:55 UTC 2023
;; MSG SIZE rcvd: 201
pod "srvlookup" deleted
kmg48801@cloudshell:~ (kubers-368504)$curl -X POST -d "The sun is shining" localhost:8001/api/v1/namespaces/default/services/kubia-public/proxy//
Data stored on pod kubia-0
kmg48801@cloudshell:~ (kubers-368504)$ curl -X POST -d "The sun is shining" localhost:8001/api/v1/namespaces/default/services/kubia-public/proxy/
Data stored on pod kubia-1
kmg48801@cloudshell:~ (kubers-368504)$ curl -X POST -d "The sun is shining" localhost:8001/api/v1/namespaces/default/services/kubia-public/proxy/
Data stored on pod kubia-1
kmg48801@cloudshell:~ (kubers-368504)$ curl -X POST -d "The sun is shining" localhost:8001/api/v1/namespaces/default/services/kubia-public/proxy/
Data stored on pod kubia-2
kmg48801@cloudshell:~ (kubers-368504)$ curl -X POST -d "The sun is shining" localhost:8001/api/v1/namespaces/default/services/kubia-public/proxy/
Data stored on pod kubia-2
kmg48801@cloudshell:~ (kubers-368504)$ curl -X POST -d "The sun is shining" localhost:8001/api/v1/namespaces/default/services/kubia-public/proxy/
Data stored on pod kubia-1
kmg48801@cloudshell:~ (kubers-368504)$ curl -X POST -d "The weather is sweet" localhost:8001/api/v1/namespaces/default/services/kubia-public/proxy/
Data stored on pod kubia-1
kmg48801@cloudshell:~ (kubers-368504)$ curl localhost:8001/api/v1/namespaces/default/services/kubia-public/proxy/
You've hit kubia-1
Data stored in the cluster:
- kubia-1.kubia.default.svc.cluster.local: The weather is sweet
- kubia-0.kubia.default.svc.cluster.local: The sun is shining
- kubia-2.kubia.default.svc.cluster.local: The sun is shining
GCP 퍼시스턴트 볼륨 생성 명령어
gcloud compute disks create --size=10GB --zone=asia-northeast3-c pv-a
gcloud compute disks create --size=10GB --zone=asia-northeast3-c pv-b
gcloud compute disks create --size=10GB --zone=asia-northeast3-c pv-c
gcloud compute disks list
세 개의 퍼시스턴트 볼륨 생성 yaml
거버닝 서비스 생성 yaml
스테이트풀셋 생성 yaml
스테이트풀셋으로 파드 생성하면, 레플리카셋으로 생성하는 것과 다르게 동작한다.
생성된 스테이트풀 파드 살펴보기
아래는 중요 부분만 추출해 낸 것이고, 실제로는 더 많은 내용을 포함함
kubectl get po kubia-0 -o yaml
kubectl get po kubia-1 -o yaml
로 보게되면 아래와 같이 별도 PVC가 생성된 걸 볼 수 있다.파드 가지고 놀기
kubectl proxy
헤드리스 서비스의 DNS SRC 레코드 조회
스테이트풀 파드에 접근하기 위한 일반적인 서비스 생성 yaml