如何在kops部署的集群中创建st1 StorageClass及对应PVC?
Got it, let's walk through creating an st1 StorageClass and the corresponding PVC for your kops-deployed Kubernetes cluster. st1 is AWS's throughput-optimized HDD, perfect for workloads like big data processing, log aggregation, or data warehouses that rely on high sequential throughput. Here's how to do it step by step:
First, make a YAML file (let's call it st1-storageclass.yaml) with the following content. This defines a StorageClass that provisions st1-type EBS volumes:
apiVersion: storage.k8s.io/v1 kind: StorageClass metadata: name: st1-sc provisioner: kubernetes.io/aws-ebs parameters: type: st1 fsType: ext4 # XFS is also a valid option if you prefer it reclaimPolicy: Delete # Switch to Retain if you want to keep the EBS volume after PVC deletion volumeBindingMode: WaitForFirstConsumer # Delays volume creation until a pod uses the PVC, ensuring AZ alignment with the pod
Quick breakdown of key fields:
provisioner: Must match your existing StorageClasses (kubernetes.io/aws-ebs) since we're using AWS EBS volumesparameters.type: Set tost1to specify the target EBS volume typereclaimPolicy:Deleteautomatically cleans up the EBS volume when the PVC is deleted; useRetainif you need to preserve volume data long-termvolumeBindingMode:WaitForFirstConsumeravoids cross-AZ volume issues by creating the volume in the same AZ as the pod that will use it
Apply the file with this command:
kubectl apply -f st1-storageclass.yaml
Verify the StorageClass was created successfully:
kubectl get storageclass
You should see st1-sc listed alongside your existing default and gp2 classes.
Next, create a PersistentVolumeClaim (PVC) that requests storage from the st1-sc class. Make a file named st1-pvc.yaml with this content:
apiVersion: v1 kind: PersistentVolumeClaim metadata: name: st1-pvc namespace: default # Update this to your target namespace if needed spec: storageClassName: st1-sc accessModes: - ReadWriteOnce # EBS volumes only support single-node read/write access resources: requests: storage: 500Gi # Critical: st1 volumes require a minimum of 500GB—smaller requests will fail!
Important reminder: st1 EBS volumes have a hard minimum size of 500GB. If you request less than this, the PVC will never bind to a provisioned volume.
Apply the PVC with:
kubectl apply -f st1-pvc.yaml
Check the status of your PVC with:
kubectl get persistentvolumeclaim st1-pvc
Once the status shows Bound, Kubernetes has successfully provisioned an st1 EBS volume and linked it to your PVC. You can now reference this PVC in your pod definitions to attach the volume to workloads.
内容的提问来源于stack exchange,提问作者Xiang Zhang

