โ Kubernetes Persistent Volume Claim & Storage Class
Udemy Labs - Certified Kubernetes Administrator with Practice Tests
Storage : Practice Test Persistent Volume Class & Storage Class
"๋ฐ์ดํฐ ๋ณด์กด์ ์ํด์!"
์ดํ๋ฆฌ์ผ์ด์
์ pod๋ก ์คํ์ํฌ ์, ๋ฐ์ดํฐ ๊ด๋ฆฌํด์ผํ๋ ๊ฒฝ์ฐ๊ฐ ๋ฐ์ํ๋ฉฐ,
๋ณผ๋ฅจ์ ํตํด ์ํ๋ ์คํ ๋ฆฌ์ง๋ฅผ ์ฝ๊ฒ ์ง์ ํ ์ ์๋๋ก ํด์ผํจ
Persistent Volume Claim
์ธ๋ถ ์คํ ๋ฆฌ์ง <-> PV <-> PVC <-> ํ๋
๊ทธ๋์ ๊ทธ ๋ ์ฌ์ด์ ์๋ช
์ฃผ๊ธฐ๊ฐ ์๋ค๋๋ฐ..?
Storage Class
storage class๋ฅผ "์ฌ์ฉํ๋ ์ด์ !"
PV์ ๋ํ ๋ฆฌ์์ค ํ ๋น ๋ฌธ์ ์ ํด๊ฒฐ
PV ๋ ํญ์ ๊ตฌ์ฑ๋์ด์์ด์ผํ์ง๋ง, pod๊ฐ ๋ช ๊ฐ ์์ฑ๋๊ณ ํ๋์ง๋ ์์ ์์
-> ๊ทธ๋ผ, ์์์ ๋๋ํ๊ฒ ํญ์ ํ ๋นํ๊ณ ์์ด์ผํ๋ ์ํฉ์ด ๋ฐ์
๋์ ์ธ ๊ตฌ์กฐ๋ฅผ ์ํ ์ ์ฉ
๋ณผ๋ฅจ์ ๋ํ ์์(์ฌ์ด์ฆ, ssd, disk, type)๋ง ์ ์ํ๊ณ , ์์ฒญ์์ ์ด ์๊ฑด์ ๋ง๋ pv๋ฅผ ํ ๋น
์ด์์ ์ฑ
์ ๋ฐ๋ Storage class ๋ง ์ ์๋ง ํ๋ฉด, ๊ทธ์ ๋ง๋ pv๋ฅผ ๋ฐ๋ก ์์ฑ์ด ๊ฐ๋ฅ
1) Persistent Volume yaml ์์ฑ
capacity, hostpath ๋ถ๋ถ ํท๊ฐ๋ฆผ
apiVersion: v1
kind: PersistentVolume
metadata:
name: pv-log
spec:
persistentVolumeReclaimPolicy: Retain
accessModes:
- ReadWriteMany
capacity:
storage: 100Mi
hostPath:
path: /pv/log
hostpath ์ฌ์ฉํ์ฌ volume ์์ฑํจ
emptyDir : ํ๋ ์์ ๋ณผ๋ฅจ ์์ฑ
ํ๋๊ฐ ์คํ๋๋ ํธ์คํธ์ ๋์คํฌ๋ฅผ ์์๋ก ์ปจํ
์ด๋์ ๋ณผ๋ฅจ์ผ๋ก ํ ๋นํด์ ์ฌ์ฉ
ํ๋๊ฐ ์ฌ๋ผ์ง๋ฉด ํ ๋นํด์ ์ฌ์ฉํ๋ ๋ณผ๋ฅจ์ ๋ฐ์ดํฐ ์ค์ข
hostPath : node ์ path ์ฌ์ฉํ์ฌ ๋ณผ๋ฅจ ์์ฑ
ํ๋๊ฐ ์คํ๋ ํธ๊ทธํธ์ ํ์ผ์ด๋ ๋๋ ํ ๋ฆฌ๋ฅผ ํ๋์ ๋ง์ดํธ
ํ๋ ์ฌ์์์, ํธ์คํธ์ ๋ฐ์ดํฐ ๋จ์์์
NFS
NFS ์๋ฒ๋ฅผ ์ด์ฉํด์ ํ๋์ ๋ง์ดํธ (์ธ๋ถ ์คํ ๋ฆฌ์ง ๋ณผ๋ฅจ ์ค์ )
2) Persistent Volume Claim ์์ฑ
pv์ ๋์ผํ๊ฒ ์์ฑ ๋จ (๊ทธ๋ ๊ฒ ์ง...๊ฐ์ yaml ํ์ผ์ธ๋ฐ...)
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: claim-log-1
spec:
accessModes:
- ReadWriteMany
resources:
requests:
storage: 100Mi
3) Storage Class
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
name: delayed-volume-sc
provisioner: kubernetes.io/no-provisioner
volumeBindingMode: WaitForFirstConsumer
$ kubectl exec [pod name] -- cat /log/app.log
์ฐธ๊ณ
[pv] https://kubernetes.io/ko/docs/concepts/storage/persistent-volumes/
[sc] https://kubernetes.io/ko/docs/concepts/storage/storage-classes/
[sc]https://m.blog.naver.com/freepsw/222005161870
https://tech.ktcloud.com/82
https://imjeongwoo.tistory.com/134
https://brunch.co.kr/@topasvga/1711