apiVersion: v1
kind: PersistentVolume
metadata:
  name: nexus-pv
spec:
  storageClassName: ""
  capacity:
    storage: 1Gi
  accessModes:
    - ReadWriteMany
  persistentVolumeReclaimPolicy: Retain
  mountOptions:
    - hard
    - nfsvers=4.1
  nfs:
    server: 192.168.40.100
    path: /mnt/nfs_share/nexus
    readOnly: false
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: nexus-pvc
spec:
  storageClassName: ""
  volumeName: nexus-pv
  accessModes:
    - ReadWriteMany
  volumeMode: Filesystem
  resources:
    requests:
      storage: 1Gi
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: nexus
  labels:
    app: nexus
spec:
  replicas: 1
  selector:
    matchLabels:
      app: nexus
  template:
    metadata:
      labels:
        app: nexus
    spec:
      containers:
      - name: nexus
        image: sonatype/nexus3
        ports:
        - containerPort: 8081
          name: web
        - containerPort: 8443
          name: websecure
        - containerPort: 8444
          name: docker
#        volumeMounts:
#        - mountPath: /nexus-data
#          name: nexus
#          subPath: data-dir
#        - mountPath: /opt/sonatype/nexus/etc
#          name: nexus
#          subPath: app-dir
        env:
        - name: INSTALL4J_ADD_VM_PARAMS
          value: "-XX:ActiveProcessorCount=4"
        - name: Djava.util.prefs.userRoot
          value: "/opt/sonatype/sonatype-work/nexus3/javaprefs"
#      volumes:
#      - name: nexus
#        persistentVolumeClaim:
#          claimName: nexus-pvc
---
apiVersion: v1
kind: Service
metadata:
  name: nexus
spec:
  ports:
  - name: http
    targetPort: 8081
    port: 8081
  - name: https
    targetPort: 8443
    port: 8443
  - name: nexus
    targetPort: 8444
    port: 8444
  selector:
    app: nexus
  type: ClusterIP
