<p>I have installed on K3S raspberry pi cluster nexus with the following setups for kubernetes learning purposes. First I created a StatefulSet:</p>
<pre><code>apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: nexus
  namespace: dev-ops
spec:
  serviceName: &quot;nexus&quot;
  replicas: 1
  selector:
    matchLabels:
      app: nexus-server
  template:
      metadata:
        labels:
          app: nexus-server
      spec:
        containers:
        - name: nexus
          image: klo2k/nexus3:latest
          env:
          - name: MAX_HEAP
            value: &quot;800m&quot;
          - name: MIN_HEAP
            value: &quot;300m&quot;
          resources:
            limits:
              memory: &quot;4Gi&quot;
              cpu: &quot;1000m&quot;
            requests:
              memory: &quot;2Gi&quot;
              cpu: &quot;500m&quot;
          ports:
            - containerPort: 8081
          volumeMounts:
            - name: nexusstorage
              mountPath: /sonatype-work
        volumes:
            - name: nexusstorage
              persistentVolumeClaim:
                claimName: nexusstorage
</code></pre>
<p>Storage class</p>
<pre><code>apiVersion: storage.k8s.io/v1   
kind: StorageClass   
metadata:   
  name: nexusstorage 
provisioner: driver.longhorn.io
allowVolumeExpansion: true
reclaimPolicy: Delete
volumeBindingMode: Immediate
parameters:
  numberOfReplicas: &quot;3&quot;
  staleReplicaTimeout: &quot;30&quot;
  fsType: &quot;ext4&quot;
  diskSelector: &quot;ssd&quot;
  nodeSelector: &quot;ssd&quot;
</code></pre>
<p>pvc</p>
<pre><code>apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: nexusstorage
  namespace: dev-ops
spec:
  accessModes:
    - ReadWriteOnce
  storageClassName: nexusstorage
  resources:
    requests:
      storage: 50Gi
</code></pre>
<p>Service</p>
<pre><code>apiVersion: v1
kind: Service
metadata:
  name: nexus-server
  namespace: dev-ops
  annotations:
      prometheus.io/scrape: 'true'
      prometheus.io/path:   /
      prometheus.io/port:   '8081'
spec:
  selector: 
    app: nexus-server
  type: LoadBalancer
  ports:
    - port: 8081
      targetPort: 8081
      nodePort: 32000
</code></pre>
<p>this setup will spin up nexus, but if I restart the pod the data will not persist and I have to create all the setups and users from scratch.</p>
<p>What I'm missing in this case?</p>
<p><strong>UPDATE</strong></p>
<p>I got it working, nexus needs on mount permissions on directory. The working <code> StatefulSet</code> looks as it follow</p>
<pre><code>apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: nexus
  namespace: dev-ops
spec:
  serviceName: &quot;nexus&quot;
  replicas: 1
  selector:
    matchLabels:
      app: nexus-server
  template:
      metadata:
        labels:
          app: nexus-server
      spec:
        securityContext:
          runAsUser: 200
          runAsGroup: 200
          fsGroup: 200
        containers:
        - name: nexus
          image: klo2k/nexus3:latest
          env:
          - name: MAX_HEAP
            value: &quot;800m&quot;
          - name: MIN_HEAP
            value: &quot;300m&quot;
          resources:
            limits:
              memory: &quot;4Gi&quot;
              cpu: &quot;1000m&quot;
            requests:
              memory: &quot;2Gi&quot;
              cpu: &quot;500m&quot;
          ports:
            - containerPort: 8081
          volumeMounts:
            - name: nexus-storage
              mountPath: /nexus-data
        volumes:
            - name: nexus-storage
              persistentVolumeClaim:
                claimName: nexus-storage
</code></pre>
<p>important snippet to get it working</p>
<pre><code> securityContext:
          runAsUser: 200
          runAsGroup: 200
          fsGroup: 200
</code></pre>

deroccha
<p>I'm not familiar with that image, although <a href="https://hub.docker.com/r/klo2k/nexus3" rel="nofollow noreferrer">checking dockerhub</a>, they mention using a Dockerfile similar to that of Sonatype. Then, I would change the mountpoint for your volume, to /nexus-data</p>
<p>This is the default path storing data (<a href="https://github.com/sonatype/docker-nexus3/blob/main/Dockerfile#L46" rel="nofollow noreferrer">they set this env var</a>, then declare a VOLUME). Which we can confirm, <a href="https://github.com/klo2k/nexus3-docker/blob/master/Dockerfile#L79" rel="nofollow noreferrer">looking at the repository</a> that most likely produced your arm-capable image</p>
<p>And following up on your last comment, let's try to also mount it in /opt/sonatype/sonatype-work/nexus3...</p>
<p>In your statefulset, change volumeMounts, to this:</p>
<pre><code>      volumeMounts:
        - name: nexusstorage
          mountPath: /nexus-data
        - name: nexusstorage
          mountPath: /opt/sonatype/sonatype-work/nexus3
    volumes:
      - name: nexusstorage
        persistentVolumeClaim:
          claimName: nexusstorage
</code></pre>
<p><a href="https://github.com/klo2k/nexus3-docker/blob/master/Dockerfile#L38-L42" rel="nofollow noreferrer">Although the second volumeMount entry should not be necessary</a>, as far as I understand. Maybe something's wrong with your storage provider?</p>
<p>Are you sure your PVC is write-able? Reverting back to your initial configuration, enter your pod (<code>kubectl exec -it</code>) and try to write a file at the root of your PVC.</p>
