# elastic-local-pv.yamlapiVersion:v1kind:PersistentVolumemetadata:name:elastic-local-pv1spec:capacity:storage:900GiaccessModes:-ReadWriteOncepersistentVolumeReclaimPolicy:RetainstorageClassName:elastic-local-storagelocal:path:/data1nodeAffinity:required:nodeSelectorTerms:-matchExpressions:-key:kubernetes.io/hostnameoperator:Invalues:-node3# <- 이 부분은 각자 PC의 호스트네임을 사용하면 된다
node3 PC에는 /data1에 932기가의 파티션이 mount되어 있다
$ df-Th
Filesystem Type Size Used Avail Use% Mounted on
...
/dev/sdb1 xfs 932G 33M 932G 1% /data1
...
Apply & Describe Persistent Volume
$ kubectl apply -f persistent-volume.yaml
persistentvolume/elastic-local-pv created
$ kubectl get pv
kubectl get pv
NAME CAPACITY ACCESS MODES RECLAIM POLICY STATUS CLAIM STORAGECLASS REASON AGE
elastic-local-pv1 900Gi RWO Retain Available elastic-local-storage 179m
$ kubectl describe pv elastic-local-pv1
Name: elastic-local-pv1
Labels: <none>
Annotations: Finalizers: [kubernetes.io/pv-protection]
StorageClass: elastic-local-storage
Status: Available
Claim:
Reclaim Policy: Retain
Access Modes: RWO
VolumeMode: Filesystem
Capacity: 900Gi
Node Affinity:
Required Terms:
Term 0: kubernetes.io/hostname in[node3]
Message:
Source:
Type: LocalVolume (a persistent volume backed by local storage on a node)
Path: /data1
Events: <none>
6. Persistent Volume Claim 구성
이번 Elasticsearch에서는 volumeClaimTemplates을 이용하여 Persistent Volume Claim을 자동으로 생성
volumeClaimTemplates이 부분이 Persistent Volume Claim과 거의 동일하기 때문에 살펴본다
일반적으로 데이터 베이스 Cluster를 구성할 때, PVC를 직접 사용하는 경우는 많지 않음
Persistent Volume Claim은 Pod이 Persistent Volume을 요청하기 위해 필요
이 Claim을 통해 Pod에게 가장 적절한 Persistent Volume을 할당 받는다
storageClassName은 위 StroageClass 이름 사용
accessModes는 pv와 동일하게 설정
resources.requests.storage는 필요한 용량 서술
StorageClass에서 volumeBindingMode가 WaitForFirstConsumer이기 때문에 Pending 상태
$ kubectl apply -f persistent-volume-claim.yaml
persistentvolumeclaim/elastic-local-pvc created
$ kubectl get pvc
NAME STATUS VOLUME CAPACITY ACCESS MODES STORAGECLASS AGE
elastic-local-pvc Pending elastic-local-storage 6s
[root@control1 elastic]# kubectl describe pvc
Name: elastic-local-pvc
Namespace: default
StorageClass: elastic-local-storage
Status: Pending
Volume:
Labels: <none>
Annotations: <none>
Finalizers: [kubernetes.io/pvc-protection]
Capacity:
Access Modes:
VolumeMode: Filesystem
Used By: <none>
Events:
Type Reason Age From Message
-------------------------
Normal WaitForFirstConsumer 7s (x2 over 21s) persistentvolume-controller waiting for first consumer to be created before binding
7. Statefulset
아직 Statefulset은 철학이나 설계를 확실하게 파악하지는 못 함..
Deployment와 같은 레벨로 보임
Statefulset을 실행하면, Replica의 수에 맞춰 Stateful한 Pod를 구동