Edit on GitHub pvc
Create pvc
cat <<EOF | kubectl apply -f -
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: host-path-pvc
namespace: skobba
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 2Gi
EOF
Use in Pod
cat <<EOF | kubectl apply -f -
apiVersion: v1
kind: Pod
metadata:
name: pod-with-volume
spec:
containers:
- name: container
image: nginx:stable-alpine
volumeMounts:
- name: my-vol
mountPath: /my-vol
ports:
- containerPort: 80
volumes:
- name: my-vol
persistentVolumeClaim:
claimName: host-path-pvc
EOF
Check
kubectl get pod,pv,pvc