No such file or directory after declared the volumeMounts

10/9/2018

I really dont understand this issue. In my pod.yaml i set the persistentVolumeClaim . i copied on my lastapplication declaration with PVC & PV. i've checked that the files are in the right place ! on my Deployment file i've just set the port and the spec for the containers.

apiVersion: v1
kind: Pod
metadata:
  name: ds-mg-cas-pod
  namespace: ds-svc
spec:
  containers:
  - name: karaf
    image: docker-all.xxxx.net/library/ds-mg-cas:latest
    env:
    - name: JAVA_APP_CONFIGS
      value: "/apps/ds-cas-webapp/context"
    - name: JAVA_EXTRA_PARAMS
      value: "-Djava.security.auth.login.config=./config/jaas.config -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=6402"

    volumeMounts:
    - name: ds-cas-config
      mountPath: "/apps/ds-cas-webapp/context"
  volumes:
    - name: ds-cas-config
      persistentVolumeClaim:
        claimName: ds-cas-pvc

the PersistentVolume & PersistenteVolumeClaim

kind: PersistentVolume
apiVersion: v1
metadata:
  name: ds-cas-pv
  namespace: ds-svc
  labels:
    type: local
spec:
  storageClassName: generic
  capacity:
    storage: 5Mi
  accessModes:
    - ReadWriteOnce
  hostPath:
    path: "/apps/ds-cas-webapp/context"
---
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
  name: ds-cas-pvc
  namespace: ds-svc
spec:
  storageClassName: generic
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 2Mi

The error i get when i run the pod

    java.io.FileNotFoundException: ./config/truststore.jks (No such file or directory)

I run the same image manually with docker. i didn't had an error. My question is where i can made a mistake because i really dont see :( i set everything

  • the mountpoints
  • the ports
  • the variable

the docker command that i used to run the container :

docker run --name ds-mg-cas-manually
-e JAVA_APP=/apps/ds-cas-webapp/cas.war
-e JAVA_APP_CONFIGS=/apps/ds-cas-webapp/context
-e  JAVA_EXTRA_PARAMS="-Djava.security.auth.login.config=./config/jaas.config -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=6402"
-p 8443:8443 
-p 6402:640 
-d 
-v /apps/ds-cas-webapp/context:/apps/ds-cas-webapp/context 
docker-all.attanea.net/library/ds-mg-cas  
/bin/sh -c
-- morla
google-kubernetes-engine
kubernetes

1 Answer

10/9/2018

Your PersistentVolumeClaim is probably bound to the wrong PersistentVolume.

PersistentVolumes exist cluster-wide, only PersistentVolumeClaims are attached to a namespace:

$ kubectl api-resources
NAME                     SHORTNAMES   APIGROUP   NAMESPACED   KIND
persistentvolumeclaims   pvc                     true         PersistentVolumeClaim
persistentvolumes        pv                      false        PersistentVolume
-- Florian Breisch
Source: StackOverflow