Kubernetes Storage Issues
Pv: A piece of storage in a network store in a cluster, which is an entity resource that is independent of the computing resources, usually we define a networked storage, then draw a network disk from it and mount it on the virtual machine PV belongs to networked storage, Does not belong to any node, but can be accessed on each node    PV is not defined on the pod, but is independent of the PVC outside the pod: a pod wants to apply for a certain condition PV, need to define it Life cycle of volume and claim Available 1. The manager of a static cluster generates a lot of PV, they take control of some of the details of the storage and store it to the cluster users, which exist in the K8s API and can be used to consume 2. Dynamic when no static PV is available, the manager needs to create a user-friendly PVC, and the cluster will dynamically provide a Volu Me to PVC, this offer is based on Storageclass: This PVC must request a CALSS and the manager must create and configure this class for use, and if there is no declaration, there will be no dynamic resources available Binding if a PVC set a certain storage and access modes, and there is a corresponding PV, then the dynamic provision of resources. A control loop on master is always looking for a monitor PVC and then finds a PV to match. If a matching volume is not present, the PVC remains unbound, and the PVC is generally bound to the available matching volume. If the cluster provides a 50g PV, then the request 100g PVC will not match, unless the cluster adds a 100g pv is using the pod using claim as volume, the cluster checks claim to find the binding volume, Then provide volume to pod. Volumes provides a variety of multiple access modes, users need to declare the desired mode when they need to use volume for the pod once the user has claim, and claim is bound, then the bundled PV belongs to the user. Users of the volume module contained in the pod in the PVC, dispatch pods and use the declaration of pv is released when a user has run out of their volume, can be removed through the API PVC, for resource recycling. When the PVC has been removed, the associated volume is released state, but it cannot be used by another PVC. Since the data produced by the previous PVC is still in volume, it must beis processed. Re-declare that when volume is released from its PVC, PV's Recaim rules tell the cluster what to do with volume. For now, volume can be either retained or recycled or deleted. Deletion will delete the k8s PV, and the associated storage (aws,gce,azure, cinder volume) will also be deleted. Dynamically provided volume are usually removed currently supported PV types
- Gcepersistentdisk
- Awselasticblockstore
- Azurefile
- Azuredisk
- FC (Fibre Channel)
- Nfs
- ISCSI
- RBD (Ceph Block Device)
- Cephfs
- Cinder (OpenStack block storage)
- Glusterfs
- Vspherevolume
- Hostpath (single node testing only–local storage was not supported on any and would not work in a multi-node cluster)
Pv
apiVersion: v1 kind: PersistentVolume metadata: name: pv0003 annotations: volume.beta.kubernetes.io/storage-class: "slow" spec: capacity: storage: 5Gi accessModes: - ReadWriteOnce persistentVolumeReclaimPolicy: Recycle nfs: path: /tmp server: 172.17.0.2
Capacity: Storage Properties Access modes: Different virtual resources have different storage capabilities and different access mode
The Access modes is:
- Readwriteonce–the volume can is mounted as read-write by a single node
- Readonlymany–the volume can be mounted read-only by many nodes
- Readwritemany–the volume can be mounted as read-write by many nodes
In the CLI, the access modes is abbreviated to:
- Rwo-readwriteonce
- Rox-readonlymany
- Rwx-readwriteman
CLASS:PV's annotation class Volume.beta.kubernetes.io/storage-class is associated with the name Storageclass. The PV class is associated with the PVC class .
Reclaim Policy:
- Retain–manual Reclamation
- Recycle–basic Scrub ("rm-rf/thevolume/*")
- delete–associated storage asset such as AWS EBS, GCE PD, Azure Disk, or OpenStack Cinder volume is deleted
Currently, only NFS and Hostpath support recycling. AWS EBS, GCE PD, Azure Disk, and Cinder volumes support deletion.
several stages in which volume is located:
- Available–a free resource, that's not yet bound to a claim
- Bound–the volume is Bound to a claim
- Released–the claim have been deleted, but the resource are not yet reclaimed by the cluster
- Failed–the volume have Failed its automatic reclamation
PVC: Typically includes spec and status
kind: PersistentVolumeClaimapiVersion: v1metadata: name: myclaim annotations: volume.beta.kubernetes.io/storage-class: "slow"spec: accessModes: - ReadWriteOnce resources: requests: storage: 8Gi selector: matchLabels: release: "stable" matchExpressions: - {key: environment, operator: In, values: [dev]}
Access ModesResources: The requested resource size SELETOR:PVC usually contains a label selector to pick the appropriate volume. These volume can only be used when the volume label and label Seletor correspond. CALSS volume claimpod can be stored with volume by claim. Claim must exist in the same namespace as the pod. The cluster finds claim from the pod's namespace and then correlates with PV. Then the volume can be mounted on the pod.
kind: PodapiVersion: v1metadata: name: mypodspec: containers: - name: myfrontend image: dockerfile/nginx volumeMounts: - mountPath: "/var/www/html" name: mypd volumes: - name: mypd persistentVolumeClaim: claimName: myclaim
Kubernetes Study Notes 4