Know how to configure applications with persistent storage
Context: CKA certification command examples.
Know how to configure applications with persistent storage
Configuring applications with persistent storage is an essential aspect of managing containerized applications. In the context of the Certified Kubernetes Administrator (CKA) certification, you may encounter tasks related to persistent storage. Here are some command examples that can help you configure applications with persistent storage in Kubernetes:
- Create a PersistentVolume (PV):
apiVersion: v1kind: PersistentVolumemetadata:name: my-pvspec:capacity:storage: 1GiaccessModes: - ReadWriteOnce persistentVolumeReclaimPolicy: RetainstorageClassName: slowhostPath: path: /data/my-pvExplanation: This YAML manifest creates a PersistentVolume named "my-pv" with a storage capacity of 1GB. It uses the hostPath volume plugin to store data on the host's file system.
- Create a PersistentVolumeClaim (PVC):
apiVersion: v1kind: PersistentVolumeClaimmetadata: name: my-pvcspec:accessModes: - ReadWriteOnceresources:requests:storage: 1GistorageClassName: slowExplanation: This YAML manifest creates a PersistentVolumeClaim named "my-pvc" requesting 1GB of storage with access mode ReadWriteOnce. It references the "slow" storageClassName, which matches the storageClassName used in the PV.
- Mount the PVC in a Pod:
apiVersion: v1kind: Podmetadata:name: my-podspec:containers:- name: my-containerimage: my-imagevolumeMounts:- name: my-volumemountPath: /datavolumes:- name: my-volumepersistentVolumeClaim:claimName: my-pvcExplanation: This YAML manifest creates a Pod named "my-pod" with a container named "my-container". It mounts the PVC "my-pvc" to the path "/data" inside the container.
These examples cover the basic steps for configuring applications with persistent storage in Kubernetes. Remember to adjust the YAML manifests according to your specific requirements, such as storage class, access modes, and storage capacity.
