Automatic pv
Course: Kubernetes Part 2 - chapter 23
Ref - https://docs.vultr.com/how-to-provision-persistent-volume-claims-on-vultr-kubernetes-engine
- Create a persistent volume claim with storageClassName set to
vultr-block-storage-hdd
apiVersion: v1kind: PersistentVolumeClaimmetadata: name: csi-pvcspec: accessModes: - ReadWriteOnce resources: requests: storage: 40Gi storageClassName: vultr-block-storage-hdd- Apply the pod manifest
apiVersion: v1kind: Podmetadata: name: mongo-podspec: containers: - name: mongo image: mongo:4.4 command: ["mongod", "--bind_ip_all"] ports: - containerPort: 27017 volumeMounts: - name: mongo-storage mountPath: /data/db volumes: - name: mongo-storage persistentVolumeClaim: claimName: csi-pvc- Explore the resources created
kubectl get pvkubectl get pvckubectl get pods- Put some data in mongodb
kubectl exec -it mongo-pod -- mongouse mydbdb.mycollection.insert({ name: "Test", value: "This is a test" })exit- Delete and restart the pod
kubectl delete pod mongo-podkubectl apply -f mongo.yml- Check if the data persists
kubectl exec -it mongo-pod -- mongouse mydbdb.mycollection.find()