pv.yaml
kind: PersistentVolume
apiVersion: v1
metadata:
name: hostpath
labels:
type: local
spec:
storageClassName: manual
capacity:
storage: 1Gi
accessModes:
- ReadWriteOnce
hostPath:
path: "/tmp/devopsschool"Code language: JavaScript (javascript)
$ kubectl create -f pv.yaml
$ kubectl get pv
pvc.yaml
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: pvchostpath
spec:
storageClassName: manual
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 1Gi
$ kubectl create -f pvc.yaml
$ kubectl get pvc
pod.yaml
kind: Pod
apiVersion: v1
metadata:
name: task-pv-pod
spec:
containers:
- name: task-pv-container
image: scmgalaxy/nginx-devopsschoolv1
ports:
- containerPort: 80
name: "http-server"
volumeMounts:
- mountPath: "/usr/share/nginx/html"
name: task-pv-storage
volumes:
- name: task-pv-storage
persistentVolumeClaim:
claimName: pvchostpath
Code language: JavaScript (javascript)
$ kubectl create -f pod.yaml $ kubectl get pods -o wide $ kubectl exec task-pv-pod -- ls /usr/share/nginx/html $ kubectl exec task-pv-pod -- touch /usr/share/nginx/html/index.html $ kubectl delete pod task-pv-pod $ kubectl create -f pod.yaml $ kubectl exec task-pv-pod -- ls /usr/share/nginx/htmlCode language: JavaScript (javascript)
I’m Rajesh Kumar, a DevOps, SRE, DevSecOps, Cloud, and Platform Engineering expert passionate about sharing practical knowledge, real-world experiences, and industry best practices. I have worked at Cotocus and regularly write about technology, travel, investing, health, product reviews, and digital marketing through my various platforms.
I publish technical articles at DevOps School, travel stories at Holiday Landmark, stock market insights at Stocks Mantra, health and fitness guidance at My Medic Plus, product reviews at TrueReviewNow, and SEO and digital marketing strategies at Wizbrand.
Find Trusted Cardiac Hospitals
Compare heart hospitals by city and services — all in one place.
Explore Hospitals