Persistent Volume
kube-prometheus๋ ์ด๊ธฐ์ ์ค์นํ๋ฉด ๋ฐ์ดํฐ๋ฅผ emptyDir์ ์ ์ฅํฉ๋๋ค. ์ด๋ Prometheus๊ฐ ์ฌ์์๋๋ฉด ๋ฐ์ดํฐ๊ฐ ์ญ์ ๋๋ ๊ฒ์ ์๋ฏธํฉ๋๋ค. ์ด๋ฅผ ๋ฐฉ์งํ๊ธฐ ์ํด persistent volume์ ์ฌ์ฉํ ์ ์์ต๋๋ค.
๊ธฐ๋ณธ์ ์ผ๋ก 1์ผ์น์ ๋ฐ์ดํฐ๋ฅผ ๋ณด๊ดํฉ๋๋ค.
retention ์ค์
https://github.com/prometheus-operator/kube-prometheus/blob/main/examples/prometheus-pvc.jsonnet ๋ฅผ ์ฐธ๊ณ ํ์์ต๋๋ค.

์ค์ ์ ์ถ๊ฐํฉ๋๋ค.
์ด๋ ๊ฒ ๋๋ฉด 30์ผ์ ๋ฐ์ดํฐ๋ฅผ ๋ก์ปฌ ํธ์คํธ์ ์ ์ฅ์ ํฉ๋๋ค.
๋ฐ์ดํฐ๊ฐ ๋ง์์ ธ์ ๋ ธ๋์ ์คํ์ด์ค๊ฐ ์์ผ๋ฉด ๋ฌธ์ ๊ฐ ์๊ธธ์ ์์ต๋๋ค.
์ด์ ์ด๊ฑธ nfs์ pv์ ์ ์ฅํด๋ด ๋๋ค.
pv์ฌ์ฉ
๊ธฐ๋ณธ์ ์ผ๋ก kube-prometheus๊ฐ pvc๋ ์์ฑ์ ํฉ๋๋ค. ์ด๊ฑธ pvc์ ๋ถ์ผ๋๋ label์ ์ด์ฉํฉ๋๋ค
์ผ๋จ pv๊ฐ 2๊ฐ๊ฐ ์์ด์ผํฉ๋๋ค. ๊ผญ storageclass๋ ์ฌ์ฉํ์ฌ์ผ ํฉ๋๋ค.
apiVersion: v1
kind: PersistentVolume
metadata:
name: pv-prom-01
labels:
app: prometheus
spec:
capacity:
storage: 50Gi
accessModes:
- ReadWriteMany
storageClassName: 'nfs'
persistentVolumeReclaimPolicy: Retain
nfs:
server: filer1
path: /vol/sharedvol/prom-c4-01
readOnly: false
mountOptions:
- nfsvers=3
---
apiVersion: v1
kind: PersistentVolume
metadata:
name: pv-prom-02
labels:
app: prometheus
spec:
capacity:
storage: 50Gi
accessModes:
- ReadWriteMany
storageClassName: 'nfs'
persistentVolumeReclaimPolicy: Retain
nfs:
server: filer1
path: /vol/sharedvol/prom-c4-02
readOnly: false
mountOptions:
- nfsvers=3
2๊ฐ์ pv๋ฅผ ์์ฑํ์์ต๋๋ค.
์ด์ cluster.jsonnet์ ์์ ํฉ๋๋ค.

์ด๋ ๊ฒ ํ๋ฉด pvc๋ฅผ ์์ฑํ๊ณ pv๋ฅผ ์ฌ์ฉํ๊ฒ ๋ฉ๋๋ค.
pod1๊ณผ pod2๊ฐ pvc๋ฅผ ์ฐ๊ฒฐํด์ ์ฌ์ฉํ๋๊ฒ์ ์๊ฒ ๋ฉ๋๋ค.
prometheus deployment replication์ด 2๊ฐ ์ด์์์ผ๋ฉด ์ถ๊ฐ๋ก pv๋ฅผ ๋ง๋ค์ด์ฃผ์ด์ผํฉ๋๋ค.
selector: { matchLabels
์ ์ฌ์ฉํจ์ผ๋ก ๊ผญ label์ ์ค์ ํด์ผํฉ๋๋ค.
Last updated
Was this helpful?