apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    control-plane: controller-manager
  name: controller-manager
spec:
  replicas: 1
  selector:
    matchLabels:
      control-plane: controller-manager
  template:
    metadata:
      labels:
        control-plane: controller-manager
    spec:
      containers:
      - args:
        - --secure-listen-address=0.0.0.0:8443
        - --upstream=http://127.0.0.1:8080/
        - --logtostderr=true
        - --v=10
        image: gcr.io/kubebuilder/kube-rbac-proxy:v0.8.0
        name: kube-rbac-proxy
        ports:
        - containerPort: 8443
          name: https
      - name: manager
        image: localhost/almond-test:latest
        imagePullPolicy: IfNotPresent
        command: ["/bin/bash"]
        args:
        - -c
        - |
          set -x
          cd /opt/almond-cloud/go
          /usr/local/go/bin/go test -timeout 0 -coverpkg ./... -v -covermode=count -coverprofile=/home/almond-cloud/coverage.out ./backend/... &
          wait $!
          while [ 1 ]; do sleep 100; done          
        env:
        - name: ENABLE_INTEGRATION
          value: "true"
        - name: INTEGRATION_ARGS
          value: "manager --namespace=default --health-probe-bind-address=:8081 --metrics-bind-address=127.0.0.1:8080 --leader-elect"
        livenessProbe:
          httpGet:
            path: /healthz
            port: 8081
          initialDelaySeconds: 15
          periodSeconds: 20
        readinessProbe:
          httpGet:
            path: /readyz
            port: 8081
          initialDelaySeconds: 5
          periodSeconds: 10
        resources:
          requests:
            cpu: 500m
            memory: 100Mi
        volumeMounts:
        - mountPath: /etc/almond-cloud/config.d/config.yaml
          name: almond-config
          readOnly: true
          subPath: config.yaml
        - mountPath: /etc/almond-cloud/manager-config
          name: manager-config
      securityContext:
        fsGroup: 995
      serviceAccountName: controller-manager
      terminationGracePeriodSeconds: 10
      volumes:
      - name: almond-config
        configMap:
          name: almond-config
      - name: manager-config
        configMap:
          name: manager-config
