apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    app.kubernetes.io/name: argocd-bot
  name: argocd-bot
spec:
  selector:
    matchLabels:
      app.kubernetes.io/name: argocd-bot
  template:
    metadata:
      labels:
        app.kubernetes.io/name: argocd-bot
    spec:
      containers:
      - name: argocd-bot
        command: [npm, start]
        image: marcb1/argocd-bot:latest
        env:
        - name: NODE_TLS_REJECT_UNAUTHORIZED
          value: "0"
        - name: LOG_LEVEL
          value: "info"
        - name: PORT
          value: "8080"
        - name: APP_ID
          valueFrom:
            secretKeyRef:
              name: argocd-bot-secret
              key: APP_ID
        # if using github.com, this is not needed
        - name: GHE_HOST
          valueFrom:
            secretKeyRef:
              name: argocd-bot-secret
              key: GHE_HOST
        - name: GITHUB_REPO
          valueFrom:
            secretKeyRef:
              name: argocd-bot-secret
              key: GITHUB_REPO
        - name: GITHUB_TOKEN
          valueFrom:
            secretKeyRef:
              name: argocd-bot-secret
              key: GITHUB_TOKEN
        - name: WEBHOOK_SECRET
          valueFrom:
            secretKeyRef:
              name: argocd-bot-secret
              key: WEBHOOK_SECRET
        - name: PRIVATE_KEY_PATH
          value: "/data/key.pem"
        - name: ARGOCD_SERVER
          valueFrom:
            secretKeyRef:
              name: argocd-bot-secret
              key: ARGOCD_SERVER
        - name: ARGOCD_AUTH_TOKEN
          valueFrom:
            secretKeyRef:
              name: argocd-bot-secret
              key: ARGOCD_AUTH_TOKEN
        volumeMounts:
        - name: app-private-key
          mountPath: "/data"
          readOnly: true
        imagePullPolicy: Always
        ports:
        - containerPort: 8080
        readinessProbe:
          tcpSocket:
            port: 8080
          initialDelaySeconds: 5
          periodSeconds: 1
      volumes:
      - name: app-private-key
        secret:
          secretName: argocd-bot-secret
