- Created by Sansae, last modified on Mar 06, 2024
You are viewing an old version of this page. View the current version.
Compare with Current View Page History
« Previous Version 29 Next »
목차
Volumes 개요
- 컨테이너가 스토리지에 액세스 하고 공유하는 방법
- 각 컨테이너 파일 시스템의 볼륨을 마운트하여 생성
Volume 종류
https://subicura.com/k8s/guide/local-volume.html
Volume 종류 | Volume Type | OverView | 설명 |
---|---|---|---|
임시볼륨 | empty-dir | 파드가 시작될 때 빈 상태로 시작 루트디스크 또는 램에서 제공된다 컨테이너끼리 파일을 공유 Pod가 삭제되면 사라짐 | |
로컬볼륨 | hostpath local | host node에서 제공된다 Pod가 재배포되었을때 node가 달라질 수 있다 node와 파일을 공유하기 위해 사용 | |
네트워크 볼륨 | iSCSI NFS glusterFS ... | 네트워크 스토리지를 사용한다. | |
클라우드 네트워크 볼륨 | azureFile awsEBS gcePersistentDisk ... | https://kimjingo.tistory.com/153 | 클라우드스토리지를 사용한다. |
Persistent Volume(PV) / Persistent Volume Claim(PVC)
http://www.boanproject.com
타입 | 설명 |
---|---|
Static 프로비저닝 | |
Dynamic 프로비저닝 |
Storage Class
sansae@sansaeAir15m2 k8s-lab-workspace % k get sc NAME PROVISIONER RECLAIMPOLICY VOLUMEBINDINGMODE ALLOWVOLUMEEXPANSION AGE azurefile file.csi.azure.com Delete Immediate true 2d6h azurefile-csi file.csi.azure.com Delete Immediate true 2d6h azurefile-csi-premium file.csi.azure.com Delete Immediate true 2d6h azurefile-premium file.csi.azure.com Delete Immediate true 2d6h default (default) disk.csi.azure.com Delete WaitForFirstConsumer true 2d6h managed disk.csi.azure.com Delete WaitForFirstConsumer true 2d6h managed-csi disk.csi.azure.com Delete WaitForFirstConsumer true 2d6h managed-csi-premium disk.csi.azure.com Delete WaitForFirstConsumer true 2d6h managed-premium disk.csi.azure.com Delete WaitForFirstConsumer true 2d6h sansae@sansaeAir15m2 k8s-lab-workspace % k edit sc azurefile allowVolumeExpansion: true apiVersion: storage.k8s.io/v1 kind: StorageClass metadata: creationTimestamp: "2024-03-08T01:58:10Z" labels: addonmanager.kubernetes.io/mode: EnsureExists kubernetes.io/cluster-service: "true" name: azurefile resourceVersion: "352" uid: eb098551-1947-41af-9430-3ae37b28c7b8 mountOptions: - mfsymlinks - actimeo=30 - nosharesock parameters: skuName: Standard_LRS provisioner: file.csi.azure.com reclaimPolicy: Delete volumeBindingMode: Immediate
Persistent Volume Claim(PVC) Manifest (Dynamic)
https://dev-k8sref-io.web.app/docs/config-and-storage/persistentvolumeclaim-v1/
apiVersion: v1
kind: PersistentVolumeClaim
metadata (ObjectMeta)
spec (PersistentVolumeClaimSpec)
- accessModes
- selector
- resources
- volumeName
- storageClassName
status (PersistentVolumeClaimStatus)
apiVersion: v1 kind: PersistentVolumeClaim metadata: name: foo-pvc spec: storageClassName: azurefile # 빈 문자열은 명시적으로 설정해야 하며 그렇지 않으면 기본 스토리지클래스가 설정됨 accessModes: [ "ReadWriteOnce" ] resources: requests: storage: 1Gi
Persistent Volume Claim 실습
sansae@sansaeAir15m2 k8s-lab-workspace % k get pv No resources found sansae@sansaeAir15m2 k8s-lab-workspace % k get pvc No resources found in default namespace. sansae@sansaeAir15m2 k8s-lab-workspace % k apply -f pvc.yaml persistentvolumeclaim/foo-pvc created sansae@sansaeAir15m2 k8s-lab-workspace % k get pvc NAME STATUS VOLUME CAPACITY ACCESS MODES STORAGECLASS AGE foo-pvc Bound pvc-735e1382-f1e1-40f3-8378-25e72ebda4b0 1Gi RWO azurefile 3s sansae@sansaeAir15m2 k8s-lab-workspace % k get pv NAME CAPACITY ACCESS MODES RECLAIM POLICY STATUS CLAIM STORAGECLASS REASON AGE pvc-735e1382-f1e1-40f3-8378-25e72ebda4b0 1Gi RWO Delete Bound default/foo-pvc azurefile 5s sansae@sansaeAir15m2 k8s-lab-workspace %
apiVersion: apps/v1 kind: StatefulSet metadata: name: web spec: selector: matchLabels: app: nginx serviceName: "nginx" replicas: 3 # 기본값은 1 minReadySeconds: 10 # 기본값은 0 template: metadata: labels: app: nginx spec: terminationGracePeriodSeconds: 10 containers: - name: nginx image: nginx:1.15.12 ports: - containerPort: 80 name: web volumeMounts: - name: www mountPath: /usr/share/nginx/html volumeClaimTemplates: - metadata: name: www spec: accessModes: [ "ReadWriteOnce" ] storageClassName: azurefile resources: requests: storage: 1Gi
sansae@sansaeAir15m2 k8s-lab-workspace % k apply -f statefulset.yaml service/nginx-stps created statefulset.apps/web created sansae@sansaeAir15m2 k8s-lab-workspace % k get pvc NAME STATUS VOLUME CAPACITY ACCESS MODES STORAGECLASS AGE www-web-0 Bound pvc-d7a6b825-edeb-4f06-813f-eef6abe19398 1Gi RWO azurefile 52s www-web-1 Bound pvc-a2ebaeef-ae82-47bc-8988-6bb6ca0a9067 1Gi RWO azurefile 32s www-web-2 Bound pvc-e17e5080-4403-4131-9d2b-f143431681df 1Gi RWO azurefile 12s sansae@sansaeAir15m2 k8s-lab-workspace % k get pv NAME CAPACITY ACCESS MODES RECLAIM POLICY STATUS CLAIM STORAGECLASS REASON AGE pvc-a2ebaeef-ae82-47bc-8988-6bb6ca0a9067 1Gi RWO Delete Bound default/www-web-1 azurefile 55s pvc-d7a6b825-edeb-4f06-813f-eef6abe19398 1Gi RWO Delete Bound default/www-web-0 azurefile 74s pvc-e17e5080-4403-4131-9d2b-f143431681df 1Gi RWO Delete Bound default/www-web-2 azurefile 34s
- No labels