๐Ÿ“€์ฟ ๋ฒ„๋„คํ‹ฐ์Šค ๋ณผ๋ฅจ[PV, PVC - ์Šคํ† ๋ฆฌ์ง€ ํด๋ž˜์Šค, ๋™์  ํ”„๋กœ๋น„์ €๋‹]

๊น€์„ฑ์ธยท2023๋…„ 10์›” 18์ผ
0

[DevOps] ๐ŸณDocker & Kubernetes

๋ชฉ๋ก ๋ณด๊ธฐ
33/62

https://kubernetes.io/docs/concepts/storage/storage-classes/

Stroage Classes

  • ์Šคํ† ๋ฆฌ์ง€ ํด๋ž˜์Šค๋Š” ๊ด€๋ฆฌ์ž๊ฐ€ ์ œ๊ณตํ•˜๋Š” ์Šคํ† ๋ฆฌ์ง€์˜ "ํด๋ž˜์Šค"๋ฅผ ์„ค๋ช…ํ•  ์ˆ˜ ์žˆ๋Š” ๋ฐฉ๋ฒ•์„ ์ œ๊ณตํ•ฉ๋‹ˆ๋‹ค.
  • ๋‹ค๋ฅธ ํด๋ž˜์Šค๋Š” ์„œ๋น„์Šค ํ’ˆ์งˆ ์ˆ˜์ค€, ๋ฐฑ์—… ์ •์ฑ… ๋˜๋Š” ํด๋Ÿฌ์Šคํ„ฐ ๊ด€๋ฆฌ์ž๊ฐ€ ๊ฒฐ์ •ํ•œ ์ž„์˜์˜ ์ •์ฑ…์— ๋งคํ•‘๋  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
  • Kubernetes ์ž์ฒด๋Š” ํด๋ž˜์Šค๊ฐ€ ๋ฌด์—‡์„ ๋‚˜ํƒ€๋‚ด๋Š”์ง€์— ๋Œ€ํ•ด ์ด๊ฒฌ์ด ์—†์Šต๋‹ˆ๋‹ค. ๋‹ค๋ฅธ ์Šคํ† ๋ฆฌ์ง€ ์‹œ์Šคํ…œ์—์„œ๋Š” ์ด ๊ฐœ๋…์„ "ํ”„๋กœํŒŒ์ผ"์ด๋ผ๊ณ  ๋ถ€๋ฅด๊ธฐ๋„ ํ•ฉ๋‹ˆ๋‹ค

์‚ฌ์šฉํ•  ๋””์Šคํฌ์™€ PV๋ฅผ ์ž๋™์œผ๋กœ ์ƒ์„ฑํ•ด์คŒ

Resource

๊ฐ ์Šคํ† ๋ฆฌ์ง€ ํด๋ž˜์Šค๋Š” provisioner, parameters, reclaimPolicy ํ•„๋“œ๋ฅผ ๊ฐ€์ง„๋‹ค.

  • ํด๋ž˜์Šค์— ์†ํ•œ PersistentVolume์ด ๋™์  ํ”„๋กœ๋น„์ €๋‹์— ํ•„์š”ํ•  ๋•Œ ์‚ฌ์šฉ
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
  name: standard
provisioner: kubernetes.io/aws-ebs  # ํ”„๋กœ๋น„์ €๋‹์— ์‚ฌ์šฉํ•  ํ”Œ๋Ÿฌ๊ทธ์ธ
parameters: #๋งค๊ฐœ๋ณ€์ˆ˜
  type: gp2
reclaimPolicy: Retain
allowVolumeExpansion: true
mountOptions:
  - debug
volumeBindingMode: Immediate

PVC ํŒŒ์ผ์•ˆ์— spec.storageClassName์— ์ž‘์„ฑํ•˜์—ฌ ์—ฐ๊ฒฐ

pv์˜ storageClassName ํ•„๋“œ

pv์— storageClassName ํ•„๋“œ๋ฅผ ์ž‘์„ฑํ•˜๋ฉด ํ•ด๋‹น ์„ค์ •์ด ์žˆ๋Š” pvc๋ž‘๋งŒ ์—ฐ๊ฒฐ๋˜๊ณ ,
์„ค์ •ํ•˜์ง€ ์•Š์œผ๋ฉด .spec.storageClassName ํ•„๋“œ ์„ค์ •์ด ์—†๋Š” pvc๋ž‘๋งŒ ์—ฐ๊ฒฐ๋จ


GEC storageClass

apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
  name: slow
provisioner: kubernetes.io/gce-pd
parameters:
  type: pd-ssd
  fstype: ext4
  replication-type: none

rook-ceph

ํผ๋ธ”๋ฆญ ํด๋ผ์šฐ๋“œ๊ฐ€ ์•„๋‹Œ ํ”„๋ผ์ด๋น— ํด๋ผ์šฐ๋“œ์—์„œ๋„ ์Šคํ† ๋ฆฌ์ง€ ํด๋ž˜์Šค๋ฅผ ๊ตฌ์„ฑํ•  ์ˆ˜ ์žˆ๋Š” ๋„๊ตฌ

  • ํŒŒ์ผ ์Šคํ† ๋ฆฌ์ง€๋ฅผ ๊ฐ€์ƒํ™”์‹œํ‚ค๋Š” ํด๋Ÿฌ์Šคํ„ฐ๋ฅผ ๊ตฌ์„ฑ๊ฐ€๋Šฅํ•œ ์†Œํ”„ํŠธ์›จ์–ด
    http://rook.io/
  1. ์›Œ์ปค ๋…ธ๋“œ์— ์ƒˆ๋กœ์šด ๋นˆ ๋””์Šคํฌ๋ฅผ ์ถ”๊ฐ€ํ•ด์„œ 3๊ฐœ ๋งŒ๋“ฌ
  2. lsblk๋ฅผ ํ†ตํ•ด ๋””์Šคํฌ ํ™•์ธ
  3. rook-ceph ์„ค์น˜
git clone --single-branch --branch release-1.7
https://github.com/rook/rook.git
cd rook/cluster/examples/kubernetes/ceph
kubectl create -f crds.yaml -f common.yaml -f operator.yaml
kubectl create -f cluster.yaml
  1. tool ๋ฐ•์Šค, ceph csi ์„ค์น˜
kubectl create -f toolbox.yaml # cep์ƒํ™ฉ ๋ชจ๋‹ˆํ„ฐ๋ง ํˆด ์ปจํ…Œ์ด๋„ˆ
kubectl create -f csi/rbd/storageclass.yaml #Container Storage Interface
  1. tool๋ฐ•์Šค ์ปจํ…Œ์ด๋„ˆ ํ™•์ธ
    kubectl -n rook-ceph exec -it $(kubectl -n rook-ceph get pod -l "app=rook-ceph-tools" -o jsonpath='{.items[0].metadata.name}') - bash
ceph status
ceph osd pool status

profile
๊ฐœ๋ฐœ์ž๊ฐ€ ๊ฟˆ์ธ 25์‚ด ๋Œ€ํ•™์ƒ์ž…๋‹ˆ๋‹ค.

0๊ฐœ์˜ ๋Œ“๊ธ€