StorageClass & PVC

StorageClass

Commands

To list the StorageClass:

kubectl get storageclass

To describe a StorageClass:

kubectl describe storageclass <storageclass-name>

To delete a StorageClass:

kubectl delete storageclass <storageclass-name>

PVC (PersistentVolumeClaim)

Commands

To apply and run a PVC configuration:

kubectl apply -f pvc.yaml

To list the PVCs:

kubectl get pvc

Example

pvc.yaml
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: myapp-pvc
spec:
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 10Gi

How to use in Deployment:

deployment.yaml
...
spec:
  template:
    ...
    spec:
      containers:
        - name: myapp-container
          image: nginx:1.25
          ports:
            - containerPort: 80
          volumeMounts:
            - mountPath: /etc/pvc
              name: myapp-volume

      volumes:
        - name: myapp-volume   # Could be any arbitratry name
          persistentVolumeClaim:
            claimName: myapp-pvc   # Specific name of the pvc

Last updated