In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
Kubernetes's pod itself is stateless, and its life cycle is usually short. Whenever an exception occurs, Kubernetes automatically creates a new Pod to replace it.
The data generated by the container will automatically disappear with the demise of Pod.
In order to realize the storage and management of data in Pod, Kubernetes introduces two API resources: Persistent Volume (persistent volume, hereinafter referred to as PV) and Persistent Volume Claim (persistent volume application, hereinafter referred to as PVC).
PV is a network storage implementation in Kubernetes cluster. Like Node, it is also a resource that belongs to the cluster.
PV is similar to Volume in Docker, but has a life cycle independent of Pod.
Use kubectl get pv to view the list:
PVC is a request from the user, similar to Pod. Pod consumes Node's resources, and PVC consumes PV's resources.
Pod can apply for specific resources (CPU and memory); PVC can apply for specific sizes and access modes, for example, it can load a read-write instance or multiple read-only instances (that is, the values RWO, ROX, etc., of the Access Mode column returned by kubectl get pvc in the figure above) without being aware of the specific storage implementation behind these instances.
Let's take a look at a specific PVC instance named nginx-pvc:
Kind: PersistentVolumeClaim apiVersion: v1 metadata: name: nginx-pvc spec: storageClassName: default accessModes:-ReadOnlyMany resources: requests: storage: 1Gi
Use the command kubectl create-f pvc.yaml to create the persistent volume claim defined by the yaml file:
Then define a pod and consume the persistent volume claim named nginx-pvc:
Use kubectl describe pvc nginx-pvc to view the generated persistent volume corresponding to this persistent volume claim:
Now I use the command kubectl cp train.jpg nginx-storage-pod:/usr/share/nginx/html to copy the two files, train.jpg and index.html, to the pod internal file path / usr/share/nginx/html:
Now switch to nginx-storage-pod pod and find these two files in the / usr/share/nginx/html directory:
Next I define another pod, which also applies to the PVC of nginx-pvc:
After creating the pod, then kubectl exec-ti another ash goes into the pod interior / usr/share/nginx/html and also discovers index.html and train.jpg.
This example shows that persistent volume claim can be used to share persistent data among multiple pod.
For more original Jerry articles, please follow the official account "Wang Zixi":
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.