Overview of Storage persistence in K8s Cluster
Storage classification:
Direct connected storage, centralized shared storage, distributed storage
File storage, block storage, object storage
DAS,NAS,SAN
DAS belongs to direct-attached storage, which connects the storage device directly to the motherboard through SCSI interface or fibre Channel, and cannot realize data sharing.
NAS and SAN belong to centralized shared storage
NAS uses NFS and CIFS (formerly known as SMB, Microsoft) protocols
SAN is divided into FC SAN and IP SAN
IP SAN uses iSCSI technology
NFS implements sharing between linux, while smaba realizes file sharing between linux and windows based on CIFS protocol.
Ceph belongs to distributed sharing system.
The persistent storage supported in the k8s cluster mainly includes:
1. Node node storage
It is divided into random volume emptyDir and fixed volume hostPath
2. Centralized storage nfs
3. Distributed storage ceph
4. Special volumes configmap and secret
When creating a pod, the main storage types supported by the field volumes include:
$kubectl explain Pod.spec.volumes
Cephfs
Cinder
ConfigMap
EmptyDir
Glusterfs
HostPath
Iscsi
Nfs
PersistentVolumeClaim
Rbd
Secret
When creating a pod or controller, you can directly use some back-end storage (such as NFS) as its volumes
You can also use pvc as its back-end volumes,pvc and the nfs above is a level relationship.
When using pvc as its back-end volumes, the access order is pvc---pv--- back-end storage
Create a pod that uses a random volume emptyDir
ApiVersion: v1kind: Podmetadata: labels: run: nginx name: podxxspec: volumes:-name: vol1 emptyDir: {} # use node directory And random containers:-image: nginx name: nginx volumeMounts:-mountPath: / xx # directory mounted inside the container name: vol1-image: busybox name: busybox command: ['sh','-c','sleep 5000'] volumeMounts:-mountPath: / yy name: vol1
Create a pod that uses fixed volumes
ApiVersion: v1kind: Podmetadata: labels: run: nginx name: podxxspec: volumes:-name: vol1 hostPath: path: / aa # automatically create containers:-image: nginx name: nginx volumeMounts:-mountPath: / xx name: vol1-image: busybox name: busybox command: ['sh','-c','sleep 5000'] volumeMounts:-mountPath: / yy on the node where pod resides