Introduction
Local volumes do not currently support dynamic provisioning, however, a StorageClass should still be created to delay volume binding until Pod scheduling. This is specified by the WaitForFirstConsumer volume binding mode.
1 Create a local directory
2 Create a PV
3 Create a PVC
4 Create your application
5 Test
1 Create a local directory
Please login to your node server and create a local directory.
mkdir -p /root/local_pv/testapp
2 Create a PV
Please login to your master server to create a PV yaml file.
mkdir -p /root/test
cd /root/test
vi apptest_pv.yaml
Create PV via command
kubectl create -f apptest_pv.yaml
3 Create a PVC
Create a PVC yaml file via command
vi apptest_pvc.yaml
Create PVC via command
kubectl create -f apptest_pvc.yaml
4 Create your application
Create an application deployment yaml file via command
vi apptest_deployment.yaml
Create application via command
kubectl create -f apptest_deployment.yaml
5 Test
Enter the application container and create a test file in the persistent directory.
Log in to the node where the application is located to check whether the file in the local directory is created.
Restart the application container to test whether the file is effectively persisted.
Article ID: 2220, Created: June 14, 2023 at 9:31 PM, Modified: June 14, 2023 at 10:42 PM