apiVersion: apps/v1
kind: Deployment
metadata:
  name: nexus
spec:
  replicas: 1
  selector:
    matchLabels:
      app: nexus
  template:
    metadata:
      labels:
        app: nexus
    spec:
      initContainers:
      - name: set-mount-permission
        image: busybox
        command: ['sh', '-c', 'chown -R 200:200 /nexus-data']
        volumeMounts:
        - name: nexus
          mountPath: /nexus-data
      containers:
      - name: nexus
        image: sonatype/nexus3
        ports:
        - containerPort: 8081
          name: http
        - containerPort: 5000
          name: docker
        volumeMounts:
        - name: nexus
          mountPath: /nexus-data
      volumes:
      - name: nexus
        persistentVolumeClaim:
          claimName: nexus