apiVersion: apps/v1
kind: Deployment
metadata:
  name: controller
  namespace: system
spec:
  selector:
    matchLabels:
      app.kubernetes.io/name: meows
      app.kubernetes.io/component: controller
  replicas: 1
  template:
    metadata:
      labels:
        app.kubernetes.io/name: meows
        app.kubernetes.io/component: controller
    spec:
      securityContext:
        runAsNonRoot: true
      containers:
      - args:
        - "--organization-name=your-organization-name"
        - "--repository-names=repoA,repoB"
        - "--app-id=$(GITHUB_APP_ID)"
        - "--app-installation-id=$(GITHUB_APP_INSTALLATION_ID)"
        - "--app-private-key-path=/etc/github/app.pem"
        image: quay.io/cybozu/meows-controller:latest
        name: controller
        env:
          - name: "GITHUB_APP_ID"
            valueFrom:
              secretKeyRef:
                name: github-app-secret
                key: app-id
          - name: "GITHUB_APP_INSTALLATION_ID"
            valueFrom:
              secretKeyRef:
                name: github-app-secret
                key: app-installation-id
        securityContext:
          allowPrivilegeEscalation: false
        ports:
        - containerPort: 8080
          name: metrics
          protocol: TCP
        - containerPort: 8081
          name: health
          protocol: TCP
        - containerPort: 9443
          name: webhook-server
          protocol: TCP
        livenessProbe:
          httpGet:
            path: /healthz
            port: health
          initialDelaySeconds: 15
          periodSeconds: 20
        readinessProbe:
          httpGet:
            path: /readyz
            port: health
          initialDelaySeconds: 5
          periodSeconds: 10
        resources:
          requests:
            cpu: 100m
            memory: 20Mi
        volumeMounts:
          - name: github-app
            mountPath: "/etc/github"
            readOnly: true
          - name: cert
            mountPath: /tmp/k8s-webhook-server/serving-certs
            readOnly: true
      terminationGracePeriodSeconds: 10
      volumes:
        - name: github-app
          secret:
            secretName: github-app-secret
            items:
              - key: app-private-key
                path: app.pem
        - name: cert
          secret:
            defaultMode: 420
            secretName: webhook-server-cert
      serviceAccountName: controller
