---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: sonarqube-deployment
  labels:
    app: sonarqube
  namespace: jenkins
spec:
  replicas: 1
  selector:
    matchLabels:
      app: sonarqube
  template:
    metadata:
      labels:
        app: sonarqube
    spec:
      securityContext:
        fsGroup: 999
        runAsUser: 999
      containers:
      - name: master
        image: "{{ registry }}sonarqube:7.9.1-community"
        ports:
        - containerPort: 9000
        # readinessProbe:
        #   httpGet:
        #     path: /
        #     port: 9000
        #   periodSeconds: 10
        #   timeoutSeconds: 5
        #   successThreshold: 2
        #   failureThreshold: 5
        # env:
        # - name: JENKINS_OPTS
        #   valueFrom:
        #     secretKeyRef:
        #       name: jenkins
        #       key: options
        # - name: JAVA_OPTS
        #   value: '-Xmx4000m'
        volumeMounts:
        - mountPath: /opt/sonarqube/conf
          name: sonarqube-conf
        - mountPath: /opt/sonarqube/data
          name: sonarqube-data
        - mountPath: /opt/sonarqube/logs
          name: sonarqube-logs
        # resources:
        #   limits:
        #     cpu: 2000m
        #     memory: 4500Mi
        #   requests:
        #     cpu: 1000m
        #     memory: 4000Mi
      imagePullSecrets:
      - name: regcred
      volumes:
      - name: sonarqube-conf
        persistentVolumeClaim:
          claimName: sonarqube-conf-pvc
      - name: sonarqube-data
        persistentVolumeClaim:
          claimName: sonarqube-data-pvc
      - name: sonarqube-logs
        persistentVolumeClaim:
          claimName: sonarqube-logs-pvc
