<p>I am trying to run a go-ethereum node on AWS EKS, for that i have used statefulsets with below configuration.
<a href="https://i.stack.imgur.com/RxyOt.png" rel="nofollow noreferrer">statefulset.yaml file</a></p>
<p>Running<code>kubectl apply -f statefulset.yaml</code> creates 2 pods out of which 1 is running and 1 is in CrashLoopBackOff state.
<a href="https://i.stack.imgur.com/PS6ez.png" rel="nofollow noreferrer">Pods status</a>
After checking the logs for second pod the error I am getting is <code>Fatal: Failed to create the protocol stack: datadir already used by another process</code>.
<a href="https://i.stack.imgur.com/J4rqa.png" rel="nofollow noreferrer">Error logs i am getting</a></p>
<p>The problem is mainly due to the pods using the same directory to write(geth data) on the persistant volume(i.e the pods are writing to '/data'). If I use a subpath expression  and mount the pod's directory to a sub-directory with pod name(for eg: '/data/geth-0') it works fine.
<a href="https://i.stack.imgur.com/AxXQA.png" rel="nofollow noreferrer">statefulset.yaml with volume mounting to a sub directory with podname
</a>
But my requirement is that all the three pod's data is written at '/data' directory.
Below is my volume config file.
<a href="https://i.stack.imgur.com/fGegz.png" rel="nofollow noreferrer">volume configuration</a></p>

<p>You need to dynamically provision the access point for each of your stateful pod. First create an EFS storage class that support dynamic provision:</p>
<pre><code>kind: StorageClass
apiVersion: storage.k8s.io/v1
metadata:
  name: efs-dyn-sc
provisioner: efs.csi.aws.com
reclaimPolicy: Retain
parameters:
  provisioningMode: efs-ap
  directoryPerms: &quot;700&quot;
  fileSystemId: &lt;get the ID from the EFS console&gt;
</code></pre>
<p>Update your spec to support claim template:</p>
<pre><code>apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: geth
...
spec:
  ...
  template:
  ...
  spec:
    containers:
    - name: geth
      ...
      volumeMounts:
      - name: geth
        mountPath: /data
      ...
  volumeClaimTemplates:
  - metadata:
      name: geth
    spec:
      accessModes:
      - ReadWriteOnce
      storageClassName: efs-dyn-sc
      resources:
        requests:
          storage: 5Gi
</code></pre>
<p>All pods now write to their own /data.</p>
