Currently i try to implement PersistentVolume in my yaml file . I read a lot of documentation on internet and i dont understand why when i go to the dashboard pod i've this message
persistentvolumeclaim "karaf-conf" not found
pod.yaml
apiVersion: v1
kind: Pod
metadata:
name: karafpod
spec:
containers:
- name: karaf
image: xxx/karaf:ids-1.1.0
volumeMounts:
- name: karaf-conf-storage
mountPath: "/apps/karaf/etc"
volumes:
- name: karaf-conf-storage
persistentVolumeClaim:
claimName: karaf-conf-claim
PersistentVolumeClaimKaraf.yml
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: karaf-conf-claim
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 10Mi
PersistentVolume.yaml
kind: PersistentVolume
apiVersion: v1
metadata:
name: karaf-conf
labels:
type: local
spec:
capacity:
storage: 100Mi
accessModes:
- ReadWriteOnce
hostPath:
path: "/apps/karaf/etc"
You will find below the result of the command kubectl get pv
NAME CAPACITY ACCESS MODES RECLAIM POLICY STATUS CLAIM STORAGECLASS REASON AGE
karaf-conf 100Mi RWO Retain Terminating default/karaf-conf-claim 17h
karaf-conf-persistentvolume 100Mi RWO Retain Released default/karaf-conf 1h
kubectl get pvc
NAME STATUS VOLUME CAPACITY ACCESS MODES STORAGECLASS AGE
karaf-conf-claim Terminating karaf-conf 10Mi RWO manual 17h
My suggestion is recreating pv
and pvc
, and you ensure you are running the pod on the node host that configured the hostPath
.
pv/karaf-conf is in terminating status, try to delete it and recreate it using type: DirectoryOrCreate
.
kind: PersistentVolume
apiVersion: v1
metadata:
name: karaf-conf
labels:
type: local
spec:
capacity:
storage: 100Mi
accessModes:
- ReadWriteOnce
hostPath:
path: "/apps/karaf/etc"
type: DirectoryOrCreate