apiVersion: v1
data:
  default: |
    archiveLogs: true
    s3:
      bucket: test-infra
      endpoint: minio.pingcap.net:9000
      insecure: true
      keyFormat: "{{workflow.creationTimestamp.Y}}-{{workflow.creationTimestamp.m}}-{{workflow.creationTimestamp.d}}/{{workflow.name}}/{{pod.name}}"
      accessKeySecret:
        name: minio-cred
        key: accesskey
      secretKeySecret:
        name: minio-cred
        key: secretkey
kind: ConfigMap
metadata:
  name: artifact-repositories
  namespace: testground
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
  name: tps-binding
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: ClusterRole
  name: argo-server-cluster-role
subjects:
  - kind: ServiceAccount
    name: tps
    namespace: test-infra
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: tps
  namespace: test-infra
spec:
  replicas: 1
  selector:
    matchLabels:
      name: tps
  template:
    metadata:
      labels:
        name: tps
      annotations:
        app.kubernetes.io/managed-by: test-infra
    spec:
      containers:
      - command:
        - /apps/tps
        - --store=root:@tcp(tps-tidb.test-infra:4000)/tps
        - --tcms=http://tcms.test-infra
        - --tcms-api-access-token=$(TCMS_API_ACCESS_TOKEN)
        - --poll-interval=10s
        - --sync-interval=20s
        - --argo-configs
        - >
          [
            {
              "url": "http://rms.pingcap.net:31714",
              "serviceAccount": "tipocket-runner",
              "artifactRepoRef": {
                "configMap": "artifact-repositories",
                "key": "default"
              },
              "namespace": "testground",
              "setupImage": "hub.pingcap.net/qa/plansetup"
            },
            {
              "url": "http://rms-staging.pingcap.net:31714",
              "serviceAccount": "tipocket-runner",
              "artifactRepoRef": {
                "configMap": "artifact-repositories",
                "key": "default"
              },
              "namespace": "testground",
              "setupImage": "hub.pingcap.net/qa/plansetup"
            },
            {
              "url": "http://aws-argo.pingcap.net:80",
              "namespace": "testground",
              "setupImage": "docker.io/lijie0123/plansetup"
            }
          ]
        - --rms-argo-mapping
        - >
          {
              "http://rms-staging.pingcap.net:30007": "http://rms-staging.pingcap.net:31714",
              "http://rms.pingcap.net:30007": "http://rms.pingcap.net:31714",
              "http://rms-aws.pingcap.net:30007": "http://aws-argo.pingcap.net:80",
              "":"http://rms.pingcap.net:31714",
              "http://rms-apiserver-service.test-infra":"http://rms.pingcap.net:31714"
          }
        image: hub.pingcap.net/qa/tps:d273c5ae
        imagePullPolicy: Always
        name: tps
        env:
          - name: TCMS_API_ACCESS_TOKEN
            valueFrom:
              secretKeyRef:
                name: tcms-api-access-token
                key: accessToken
      serviceAccountName: tps
---
apiVersion: v1
kind: ServiceAccount
metadata:
  name: tps
  namespace: test-infra
