apiVersion: apps/v1
kind: Deployment
metadata:
  name: nexus
  namespace: nexus
  labels:
    app: nexus
spec:
  replicas: 1
  selector:
    matchLabels:
      app: nexus
  template:
    metadata:
      labels:
        app: nexus
    spec:
      terminationGracePeriodSeconds: 30
      tolerations:
      - key: "memory"
        operator: "Equal"
        value: "high"
        effect: "NoSchedule"
      containers:
      - name: nexus
        image: sonatype/nexus3:latest
        resources:
          requests:
            memory: "2Gi"
            cpu: "500m"
          limits:
            memory: "4Gi"
            cpu: "1000m"
        ports:
        - containerPort: 8081
          name: web
        - containerPort: 8443
          name: websecure
        - containerPort: 5000
          name: docker
        env:
        - name: INSTALL4J_ADD_VM_PARAMS
          value: "-XX:ActiveProcessorCount=4"
        - name: NEXUS_DATASTORE_NEXUS_USERNAME
          value: "nexus"
        - name: NEXUS_DATASTORE_NEXUS_PASSWORD
          value: "nexus"
        - name: NEXUS_DATASTORE_NEXUS_JDBCURL
          value: "jdbc:postgresql://postgres16.postgres.svc.cluster.local:5432/nexus"
#        - name: NEXUS_DB_TYPE
#          value: postgresql
#        - name: NEXUS_DB_HOST
#          value: postgres16.postgres.svc.cluster.local
#        - name: NEXUS_DB_PORT
#          value: "5432"
#        - name: NEXUS_DB_NAME
#          value: nexus
#        - name: NEXUS_DB_USER
#          value: nexus
#        - name: NEXUS_DB_PASSWORD
#          value: nexus
        volumeMounts:
        - mountPath: /nexus-data
          name: nexus
          subPath: data-dir
        - name: java-prefs
          mountPath: /opt/sonatype/nexus/.java
      volumes:
      - name: nexus
        persistentVolumeClaim:
          claimName: nexus-pvc
      - name: java-prefs
        emptyDir: {}
---
apiVersion: v1
kind: Service
metadata:
  name: nexus
  namespace: nexus
spec:
  ports:
  - name: web
    targetPort: 8081
    port: 8081
  - name: websecure
    targetPort: 8443
    port: 8443
  - name: docker
    targetPort: 5000
    port: 5000
  selector:
    app: nexus
  type: ClusterIP
