Mounting /etc/default directory problem with SOLR image

6/28/2021

I'm deploying a basic "solr:8.9.0" image to local Kubernetes env.

If I'm trying to mount pod's "/var/solr" directory, it works well. I can see the files inside /var/solr in the mounted directory.

spec:
  containers:
  - image: solr:8.6.0
    imagePullPolicy: IfNotPresent
    name: solr
    ports:
        - name: solrport
          containerPort: 8983
    volumeMounts:
    - mountPath: /var/solr/
      name: solr-volume
  volumes:
  - name: solr-volume
    persistentVolumeClaim:
      claimName: solr-pvc

But somehow I can't mount "/etc/default/" directory. That doesn't work. I knew there are files inside that directory but they are disappearing.

Any idea why?

Thanks!

-- yatta
kubernetes

1 Answer

6/28/2021

this is because of how volumeMounts work. A standard volumeMount mounts the volume in the suplied directory overwriting everything that is inside that directory.

You want to specify a subpath for the data you actually want to mount. By doing this the original contents of the directory won't get overridden.

see here for more information regarding the usage of subpaths.

-- meaningqo
Source: StackOverflow