title: Kubernetes share storage between replicas
body: <p>We have Kubernetes running on our own servers. For Persistent Storage we have a NFS server. This works great.</p>
  <p>Now we want to deploy an application with multiple replicas that should have shared storage between them, but the storage should not be persistent. When the pods are deleted, the data should be gone as well.</p>
  <p>I was hoping I could achieve it with the following</p>
  <pre class="lang-yaml prettyprint-override"><code>apiVersion: apps/v1
  kind: Deployment
  metadata:
    labels:
      app: nginx
    name: nginx
    namespace: default
  spec:
    replicas: 3
    selector:
      matchLabels:
        app: nginx
    strategy:
      rollingUpdate:
        maxSurge: 25%
        maxUnavailable: 25%
      type: RollingUpdate
    template:
      metadata:
        labels:
          app: nginx
      spec:
        volumes:
        - name: shared-data
          emptyDir: {}
  
        containers:
          image: nginx:latest
          imagePullPolicy: IfNotPresent
          name: nginx
          volumeMounts:
          - name: shared-data
            mountPath: /shared-data
          resources:
            limits:
              memory: 500Mi
  </code></pre>
  <p>All replicas have /shared-data, but when 1 replica stores data in that folder, the other replica's cannot see the file, so it is not shared.</p>
  <p>What are my options?</p>