Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Example Analysis of Storage volumes PV and PVC in Kubernetes

2025-04-02 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly shows you the "sample analysis of storage volumes PV and PVC in Kubernetes", which is easy to understand and well-organized. I hope it can help you solve your doubts. Let me lead you to study and learn the article "sample analysis of storage volumes PV and PVC in Kubernetes".

One: architecture diagram

Two: description

1. Single-node Volume is the simplest ordinary Volume, which is similar to Docker's storage volume and uses the local directory of the K8S node where Pod is located. There are two specific types, one is emptyDir, which is an anonymous empty directory, which is created by Kubernetes when creating Pod and deleted when Pod is deleted. The other is hostPath, which differs from emptyDir in that it exists independently of Pod and is specified by the user. This type of storage volumes bound to nodes will lose data after Pod is migrated to other nodes, so they can only be used to store temporary data or to share data between containers in the same Pod.

two。 There is a static binding relationship between the normal Volume and the Pod that uses it. In the file that defines the Pod, the Volume it uses is also defined. Volume is an accessory to Pod, and we cannot create a separate Volume because it is not a separate K8S resource object.

3.Persistent Volume for short PV is a K8S resource object, we can create a separate PV. It does not have a direct relationship with Pod, but through Persistent Volume Claim, referred to as PVC to achieve dynamic binding. PVC is specified in the Pod definition, and then PVC will automatically bind the appropriate PV to Pod for use according to the requirements of Pod.

An example of 4.PV definition

Click (here) to collapse or open

ApiVersion: v1

Kind: PersistentVolume

Metadata:

Name: pv0003

Spec:

Capacity:

Storage: 5Gi

AccessModes:

-ReadWriteOnce

PersistentVolumeReclaimPolicy: Recycle

StorageClassName: slow

Nfs:

Path: / tmp

Server: 172.17.0.2

An example of 5.PVC definition

Click (here) to collapse or open

Kind: PersistentVolumeClaim

ApiVersion: v1

Metadata:

Name: myclaim

Spec:

AccessModes:

-ReadWriteOnce

Resources:

Requests:

Storage: 8Gi

StorageClassName: slow

Selector:

MatchLabels:

Release: "stable"

MatchExpressions:

-{key: environment, operator: In, values: [dev]}

The above is all the content of the article "sample Analysis of PV and PVC Storage volumes in Kubernetes". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

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.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report