- Overview
- Introduction to PV and PVC
- Introduction to AWS Storage
- Introduction to Azure Storage
- Introduction to IBM Storage
Overview
This section introduces how to use storage through PV (PersistentVolume) and PVC (PersistentVolumeClaim).
Introduction to PV and PVC
PersistentVolume (PV) is cluster storage that has been provisioned by an administrator or dynamically provisioned using a Storage Class.
PersistentVolumeClaim (PVC) is a user's request for storage and uses a PV as a resource.
Types of Storage
Block Storage
Access Mode: "ReadWriteOne" supported
Storage cannot be shared
File Storage
Access Mode: "ReadWriteMany" supported
If multiple pods are created, storage can be shared
persistentVolume Reclaim Policy
delete: When the PVC is deleted, the actual storage defined in the PV is also deleted
retain: Even if the PVC is deleted, the actual storage defined in the PV is not deleted
Example of PVC Creation
If the Storage Class is "ebs-gp3-retain"
apiVersion: v1 kind: PersistentVolumeClaim metadata: ... name: <pv_name> namespace: <namespace_name> ... spec: accessModes: - ReadWriteOnce resources: requests: storage: 20Gi storageClassName: ebs-gp3-retain volumeMode: Filesystem volumeName: pvc-12345678-1234-1234-1234567890ab |
If the Storage Class is "efs-zcp-retain"
apiVersion: v1 kind: PersistentVolumeClaim metadata: ... name: <pv_name> namespace: <namespace_name> ... spec: accessModes: - ReadWriteMany resources: requests: storage: 20Gi storageClassName: efs-zcp-retain volumeMode: Filesystem volumeName: pvc-12345678-1234-1234-1234567890ab |
Mount the created PVC to a Deployment
apiVersion: apps/v1 kind: Deployment metadata: name: <deployment_name> labels: app: <deployment_label> spec: selector: matchLabels: app: <app_name> template: metadata: labels: app: <app_name> spec: containers: - image: <image_name> name: <container_name> volumeMounts: - name: <volume_name> mountPath: /<file_path> volumes: - name: <volume_name> persistentVolumeClaim: claimName: <pvc_name> |
Mount the created PVC to a StatefulSet
apiVersion: apps/v1 kind: StatefulSet metadata: name: <deployment_name> spec: serviceName: <app_name> replicas: <replica_count> podManagementPolicy: "Parallel" selector: matchLabels: app: <app_name> template: metadata: labels: app: <app_name> spec: affinity: podAntiAffinity: preferredDuringSchedulingIgnoredDuringExecution: - weight: 100 podAffinityTerm: labelSelector: matchExpressions: - key: app operator: In values: - nginx topologyKey: failure-domain.beta.kubernetes.io/zone containers: - image: <image_name> name: <container_name> volumeMounts: - name: <volume_name> mountPath: /<file_path> volumes: - name: <volume_name> persistentVolumeClaim: claimName: <pvc_name> |
Introduction to AWS Storage
Types of Storage Classes in AWS Cloud
Storage Class Name | Description |
---|---|
gp2 (default) | Composed of General Purpose SSDs, it offers 99.8%–99.9% durability (annual failure rate of 0.1%–0.2%). The maximum throughput per volume is 250MiB/s. The mode delays binding and provisioning of PersistentVolume until a Pod using the PersistentVolumeClaim is created. The reclaim policy is "delete", so the EBS (Elastic Block Store) is deleted when the PV is deleted. |
ebs-gp3 | Same specs as gp2, but the maximum throughput per volume is 1,000MiB/s. |
ebs-gp3-retain | Based on ebs-gp3 but with a reclaim policy of "retain", so the EBS is not deleted when the PV is deleted. |
efs-{PROJECT_NAME} | Regional storage class designed for frequently accessed files, providing continuous availability even if one or more Availability Zones in the AWS region become unavailable. The reclaim policy is "delete", so the EFS (Elastic File System) is deleted when the PV is deleted. |
efs-{PROJECT_NAME}-retain | Based on efs-[project name] but with a reclaim policy of "retain", so the EFS is not deleted when the PV is deleted. |
The throughput limit of gp2
ranges from 128MiB/s to 250MiB/s depending on the volume size. Volumes less than or equal to 170GiB provide a maximum throughput of 128MiB/s. Volumes larger than 170GiB and smaller than 334GiB can provide up to 250MiB/s throughput when burst credits are available. Volumes larger than 334GiB provide 250MiB/s throughput regardless of burst credits. gp2
volumes created before December 3, 2018, and not modified since creation, may not reach maximum performance unless the volume is modified.
How to create EFS for project use
1. Install EFS provisioner
Install the EFS Provisioner using Helm.
FILE_SYSTEM_ID
: FileSystem ID created from Create EFSREGION
: Region. e.g., ap-northeast-2PROJECT_NAME
: Project name. e.g., zcp
helm install stable/efs-provisioner \ --name zcp-efs-provisioner \ --namespace kube-system \ --set efsProvisioner.efsFileSystemId={FILE_SYSTEM_ID} \ --set efsProvisioner.awsRegion={REGION} \ --set efsProvisioner.path=/zcp \ --set efsProvisioner.provisionerName=cloudzcp.io/aws-efs \ --set efsProvisioner.storageClass.name=efs-{PROJECT_NAME} |
2. Create retain storage class
kubectl patch sc efs-zcp -p'{"metadata":{"name":"efs-{PROJECT_NAME}-retain"},"reclaimPolicy": "Retain"}' --dry-run -o yaml | kubectl create -f - |
3. Check the created StorageClass
kubectl get sc NAME PROVISIONER RECLAIMPOLICY VOLUMEBINDINGMODE ALLOWVOLUMEEXPANSION AGE ebs-gp3 ebs.csi.aws.com Delete WaitForFirstConsumer true 162m ebs-gp3-retain ebs.csi.aws.com Retain WaitForFirstConsumer true 162m efs-zcp cloudzcp.io/aws-efs Delete Immediate false 3h10m efs-zcp-retain cloudzcp.io/aws-efs Retain Immediate false 3h7m gp2 (default) kubernetes.io/aws-ebs Delete WaitForFirstConsumer false 6h28m |
Reference Pages
https://docs.aws.amazon.com/eks/latest/userguide/storage-classes.html
https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ebs-volume-types.html?icmpid=docs_ec2_console
https://docs.aws.amazon.com/efs/latest/ug/storage-classes.html
https://aws.amazon.com/efs/when-to-choose-efs/?nc1=h_ls
https://aws.amazon.com/ko/premiumsupport/knowledge-center/eks-persistent-storage/
Introduction to Azure Storage
Types of Azure Storage Classes
Storage Class Name | Description |
---|---|
default | Creates a Managed Disk using Azure StandardSSD storage. The Reclaim Policy is set to |
managed-premium | Creates a Managed Disk using Azure Premium storage. The Reclaim Policy is set to |
managed-premium-retain | Same as managed-premium, but the Reclaim Policy is set to |
azurefile | Creates an Azure File Share using Azure Standard storage. The Reclaim Policy is set to |
azurefile-premium | Creates an Azure File Share using Azure Premium storage. The Reclaim Policy is set to |
azurefile-premium-retain | Same as azurefile-premium, but the Reclaim Policy is set to |
Reference Page
https://docs.microsoft.com/en-us/azure/aks/concepts-storage#storage-classes
Introduction to IBM Storage
Types of IBM Storage Classes
bronze ~ gold: Select storage size with fixed IOPS
custom: Select both storage size and matching IOPS
bronze | silver | gold | custom | |
---|---|---|---|---|
iopsPerGB | 2 | 4 | 10 | |
sizeRange | [20–12000]Gi | [20–12000]Gi | [20–4000]Gi | |
sizeIOPSRange | [20–39]Gi: [100–1000] |
Types of Storage Billing
monthly: Storage usage is billed monthly
Billed per month, so you have to pay for the entire month even if deleted mid-way regardless of remaining days
Cost-effective for long-term usage
hourly: Storage usage is billed hourly
Billed per hour, so you have to pay for the whole hour even if deleted mid-way regardless of remaining minutes
More expensive than monthly, but recommended for temporary testing due to hourly granularity