apiVersion: v1
kind: ConfigMap
metadata:
  name: workflow-controller-configmap
data:

  # Limit the maximum number of incomplete workflows in a namespace.
  # Intended for cluster installs that are multi-tenancy environments, to prevent too many workflows in one
  # namespace impacting others.
  # >= v3.2
  namespaceParallelism: "10"

  workflowDefaults: |
    metadata:
      labels:
        env: dev
        project: dc6
    spec:
      securityContext:
        runAsNonRoot: true
        runAsUser: 8737  #; Work as non-root user.
      parallelism: 300
      activeDeadlineSeconds: 28800  #; Workflows must finish in 8 hours.
      ttlStrategy:
        secondsAfterCompletion: 604800   #; Workflows delete after 7 days.
      podGC:
        strategy: OnPodCompletion
      serviceAccountName: workflows-default
      tolerations:
      - key: dedicated
        operator: "Equal"
        value: "worker"
        effect: "NoSchedule"
      affinity:
        nodeAffinity:
          requiredDuringSchedulingIgnoredDuringExecution:
            nodeSelectorTerms:
            - matchExpressions:
                - key: iam.gke.io/gke-metadata-server-enabled
                  operator: In
                  values:
                    - "true"

  containerRuntimeExecutor: emissary
  containerRuntimeExecutors: |
    - name: k8sapi
      selector:
        matchLabels:
          workflows.argoproj.io/container-runtime-executor: k8sapi
    - name: emissary
      selector:
        matchLabels:
          workflows.argoproj.io/container-runtime-executor: emissary

  executor: |
    resources:
      requests:
        cpu: 100m
        memory: 64Mi
      limits:
        cpu: 500m
        memory: 1Gi

  artifactRepository: |
    archiveLogs: true
    gcs:
      bucket: scratch-170cd6ec
      keyFormat: "{{workflow.uid}}/{{pod.name}}"

  persistence: |
    connectionPool:
      maxIdleConns: 100
      maxOpenConns: 0
      connMaxLifetime: 5s # 0 means connections don't have a max lifetime
    #  if true node status is only saved to the persistence DB to avoid the 1MB limit in etcd
    nodeStatusOffLoad: true
    # save completed workloads to the workflow archive
    archive: true
    # the number of days to keep archived workflows (the default is forever)
    archiveTTL: 180d
    # skip database migration if needed.
    # skipMigration: true

    # LabelSelector determines the workflow that matches with the matchlabels or matchrequirements, will be archived.
    # https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/
    #archiveLabelSelector:
    #  matchLabels:
    #    workflows.argoproj.io/archive-strategy: "always"

    # Optional name of the cluster I'm running in. This must be unique for your cluster.
    clusterName: tsukuyomi
    postgresql:
      host: 10.132.1.3
      port: 5432
      database: postgres
      tableName: argo_workflows
      # the database secrets must be in the same namespace of the controller
      userNameSecret:
        name: argo-postgres-config
        key: username
      passwordSecret:
        name: argo-postgres-config
        key: password
      ssl: true
      # sslMode must be one of: disable, require, verify-ca, verify-full
      # you can find more information about those ssl options here: https://godoc.org/github.com/lib/pq
      sslMode: require

  sso: |
    issuer: https://accounts.google.com
    sessionExpiry: 10h
    clientId:
      name: sso-client
      key: client-id
    clientSecret:
      name: sso-client
      key: client-secret
    redirectUrl: https://argo.cildc6.org/oauth2/callback
    scopes:
     - email
    # RBAC Config. >= v2.12
    rbac:
      enabled: false

  links: |
    - name: GCP Workflow Logs
      scope: workflow
      url: https://console.cloud.google.com/logs/query;query=resource.type%3D%22k8s_container%22%0Aresource.labels.project_id%3D%22downscalecmip6%22%0Aresource.labels.namespace_name%3D%22${metadata.namespace}%22%0Alabels.%22k8s-pod%2Fworkflows_argoproj_io%2Fworkflow%22%3D%22${metadata.name}%22;timeRange=${status.startedAt}%2F${status.finishedAt}?project=downscalecmip6
    - name: GCP Pod Logs
      scope: pod
      url: https://console.cloud.google.com/logs/query;query=resource.type%3D%22k8s_container%22%0Aresource.labels.project_id%3D%22downscalecmip6%22%0Aresource.labels.namespace_name%3D%22${metadata.namespace}%22%0Aresource.labels.pod_name%3D%22${metadata.name}%22;timeRange=${status.startedAt}%2F${status.finishedAt}?project=downscalecmip6
    - name: GCP Pod Logs
      scope: pod-logs
      url: https://console.cloud.google.com/logs/query;query=resource.type%3D%22k8s_container%22%0Aresource.labels.project_id%3D%22downscalecmip6%22%0Aresource.labels.namespace_name%3D%22${metadata.namespace}%22%0Aresource.labels.pod_name%3D%22${metadata.name}%22;timeRange=${status.startedAt}%2F${status.finishedAt}?project=downscalecmip6
