Create and use FlashArray PVCs
After installing Portworx CSI to work with your FlashArray, you need to create PVCs to make storage available to your application.
The process begins with creating a StorageClass, which acts as a reference for any PVCs you create.
Create a StorageClass
Create a StorageClass with storage type and performance settings specified. For FlashArray, the backend type is pure_block
. You can also configure parameters like IOPS
and bandwidth
.
If you need the mount path to have 777 permissions, set the parameters.allow_others
field to true
in your StorageClass. This setting ensures that all users have read, write, and execute access to the mount point. Use this setting carefully to avoid granting unintended access.
Example StorageClass specification:
- Without CSI topology
- With CSI topology
The following spec is created by default when you deploy Portworx CSI:
kind: StorageClass
apiVersion: storage.k8s.io/v1
metadata:
name: sc-portworx-fa-direct-access
provisioner: pxd.portworx.com
allowVolumeExpansion: true
-
Create a new StorageClass to add parameters such as
IOPS
andbandwidth
, as shown below:- The bandwidth limit must range between 1 MB/s and 512 GB/s.
- The IOPS limit must range between 100 and 100 million.
parameters:
backend: "pure_block"
max_iops: "1000"
max_bandwidth: "1G"
#allow_others: true # uncomment this line if you need the mount path to have 777 permissions.
-
If you have enabled CSI topology, ensure you specify the
volumeBindingMode: WaitForFirstConsumer
parameter along withallowedTopologies
. ThevolumeBindingMode: WaitForFirstConsumer
delays volume binding until the Kubernetes scheduler selects a suitable node that matches theallowedTopologies
labels.kind: StorageClass
apiVersion: storage.k8s.io/v1
metadata:
name: sc-portworx-fa-direct-access
provisioner: pxd.portworx.com
parameters:
backend: "pure_block"
max_bandwidth: "10G"
max_iops: "30000"
csi.storage.k8s.io/fstype: ext4
#allow_others: true # uncomment this line if you need the mount path to have 777 permissions.
volumeBindingMode: WaitForFirstConsumer
allowedTopologies:
- matchLabelExpressions:
- key: topology.portworx.io/rack
values:
- rack-0
- rack-1
- Apply this YAML to your cluster to create the StorageClass:
kubectl apply -f sc.yaml
storageclass.storage.k8s.io/sc-portworx-fa-direct-access created
Create a PVC
-
To create a PVC, define the specifications and reference the StorageClass you previously created by specifying its name in the
spec.storageClassName
field.Example PVC specification:
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: pure-claim-block
labels:
app: nginx
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 20Gi
storageClassName: sc-portworx-fa-direct-accessSave this YAML in a file pvc.yaml
-
Apply this YAML to your cluster:
kubectl apply -f pvc.yaml
persistentvolumeclaim/pure-claim-block created
Mount a PVC to a pod
After creating PVCs, the storage becomes available for your application. You can use the storage by mounting and attaching the PVC to the application pod.
-
Create a Pod and specify the PVC name in the
persistentVolumeClaim.claimName
field. Here is an example pod specification:kind: Pod
apiVersion: v1
metadata:
name: nginx-pod
labels:
app: nginx
spec:
volumes:
- name: pure-vol
persistentVolumeClaim:
claimName: pure-claim-block
containers:
- name: nginx
image: nginx
volumeMounts:
- name: pure-vol
mountPath: /data
ports:
- containerPort: 80 -
To control pod scheduling based on node labels, add the
nodeAffinity
field to the Pod specification. For example:spec:
affinity:
nodeAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
nodeSelectorTerms:
- matchExpressions:
- key: topology.portworx.io/zone
operator: In
values:
- zone-0
- key: topology.portworx.io/region
operator: In
values:
- region-0
Verify pod status
Once the pod configuration is applied, monitor the pod’s status with:
watch kubectl get pods
Wait for the STATUS
to show as Running
for a pod. Once the pod is running, you can verify that it is connected as a host for the volume.