<p>Hi I am trying to mount a directory from pod where couchdb is running . directory is <code>/opt/couchdb/data</code>  and for mounting in kubernetes I am using this config for deployment .</p>

<pre><code>apiVersion: v1
kind: Service
metadata:
  name: couchdb0-peer0org1
spec:
  ports:
  - port: 5984
    targetPort: 5984
  type: NodePort
  selector:
    app: couchdb0-peer0org1

---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: couchdb0-peer0org1
spec:
  selector:
    matchLabels:
      app: couchdb0-peer0org1
  strategy:
    type: Recreate
  template:
    metadata:
      labels:
        app: couchdb0-peer0org1
    spec:

      containers:
      - image: hyperledger/fabric-couchdb
        imagePullPolicy: IfNotPresent
        name: couchdb0
        env:
        - name: COUCHDB_USER
          value: admin
        - name: COUCHDB_PASSWORD
          value: admin
        ports:
        - containerPort: 5984
          name: couchdb0
        volumeMounts:
        - name: datacouchdbpeer0org1
          mountPath: /opt/couchdb/data
          subPath: couchdb0

      volumes:
      - name: datacouchdbpeer0org1
        persistentVolumeClaim:
          claimName: worker1-incoming-volumeclaim
</code></pre>

<p>so by applying this deployments . I always gets result for the pods .</p>

<pre><code>couchdb0-peer0org1-b89b984cf-7gjfq    0/1     CrashLoopBackOff   1          9s
couchdb0-peer0org2-86f558f6bb-jzrwf   0/1     CrashLoopBackOff   1          9s
</code></pre>

<p>But now the strange thing if I changed mounted directory from <code>/opt/couchdb/data</code> to <code>/var/lib/couchdb</code> then it works fine . But the issue is that I have to store the data for couchdb database in statefull manner . </p>

<p><strong>Edit your /etc/exports with following content</strong></p>

<pre><code>"path/exported/directory *(rw,sync,no_subtree_check,no_root_squash)"
</code></pre>

<p>and then restart NFS server:</p>

<pre><code>sudo /etc/init.d/nfs-kernel-server restart*
</code></pre>

<p><em>no_root_squash is used, remote root users are able to change any file on the shared file. This a quick solution but have some security concerns</em></p>
