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?