In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)05/31 Report--
This article mainly explains "how to verify PV and PVC in kubernetes". The content in the article is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "how to verify PV and PVC in kubernetes".
Storage and usage storage are separated by PV and PVC in K8s
Pv is storage space, which is classified by StorageClass
Pvc is a storage volume declaration that represents a user's request to use storage, including space size, specific access mode, etc.
PVC can be used as a kind of data volume and hung to a container or container group.
There are static and dynamic ways to provide PV for PVC
Static: artificially created a series of PV that contain the actual stored specific information and are visible to cluster users
Dynamic: when the appropriate StorageClass is configured and the PVC is associated with the StorageClass, the k8s cluster can dynamically create the PV for the application
When the user creates a PVC,k8s, it immediately matches a PV for it and binds the two together. The binding relationship between PVC and PV is an one-to-one mapping.
Without a suitable PV,PVC, you will stay in the unbound state until a suitable PV is available.
Here, the NFS service is used to provide web page storage to nginx, verifying PV and PVC
The environment is that the nfs server is installed on the k8s 1.20.1 master node, and the nfs client is installed on other node nodes
1. Install nfs on ubuntu 18.04
Server side:
Apt install nfs-kernel-server
Create a shared directory
Mkdir-p / mnt/nfs
Vi / etc/exports
/ mnt/nfs * (rw,sync,no_root_squash)
Restart the service
Systemctl rpcbind restart
Systemctl nfs-server status
Confirm that the NFS server starts successfully:
Rpcinfo-p
Check whether the NFS server mounts the directory / mnt/nfs/ that we want to share
Exportfs
Showmount-e localhost # display output list
Client side:
Apt install nfs-common
Mount-t nfs-o vers=4.1 192.168.33.10:/mnt/nfs / data
View the server shared directory
Showmount-e 192.168.33.10
The client queries the mount situation
Df-h
Rpcinfo-p 192.168.33.10
View NFS version
Server-side use: nfsstat-s
Client uses: nfsstat-c
Second, configure and verify PV and PVC on K8s
Configuration file
Vi pv-lb-nginx.yaml
ApiVersion: apps/v1kind: Deploymentmetadata: name: nginx-webspec: selector: matchLabels: run: nginx-web replicas: 1 template: metadata: labels: run: nginx-webspec: containers:-name: nginx-web image: nginx ports:-containerPort: 80 volumeMounts:-mountPath: / etc/nginx/conf.d # nginx container Set directory name: configfile # custom name 1-mountPath: / usr/share/nginx/html # web page directory in the nginx container name: webroot # custom name 2 volumes:-name: configfile # must be consistent with the above custom name 1 configMap: name: nginx-config # specify the name of configmap-name: webroot # and above Face Custom name 2 consistent persistentVolumeClaim: claimName: nfs-pvc # specifies the name of the pvc-apiVersion: v1kind: Servicemetadata: name: nginx-web labels: run: nginx-webspec: type: LoadBalancer ports:-port: 80 targetPort: 80 protocol: TCP name: http selector: run: nginx-web--- # statement pv details Settings apiVersion: v1kind: PersistentVolumemetadata: name: nfs-pvspec: capacity: Storage: 1Gi volumeMode: Filesystem accessModes:-ReadWriteMany persistentVolumeReclaimPolicy: Retain nfs: server: 192.168.33.10 path: "/ mnt/nfs"-- # declare pv requirements apiVersion: v1kind: PersistentVolumeClaimmetadata: name: nfs-pvcspec: accessModes:-ReadWriteMany resources: requests: storage: 1Giluto-# declare configmap for nginx configuration apiVersion: v1kind: ConfigMapmetadata: name: nginx-configdata: nginx.conf: |-server {listen 80 Listen [:]: 80; server_name localhost; location / {root / usr/share/nginx/html; index index.html index.htm;} error_page 500 502 503 504 / 50x.html; location = / 50x.html {root / usr/share/nginx/html;}}
Kubect apply-f pv-lb-nginx.yaml
Check the deployment status:
Kubectl get svc
Kubectl get pods
Kubectl get pv
Kubectl get pvc
If something goes wrong, kubectl describe will check its events.
Verify, open the browser to visit nginx, and see the content of your configured web page.
Thank you for your reading, the above is the content of "how to verify PV and PVC in kubernetes". After the study of this article, I believe you have a deeper understanding of how to verify PV and PVC in kubernetes. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!
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.