apiVersion: apps/v1
kind: Deployment
metadata:
  name: o11y-agent-control-server
  labels:
    app: o11y-agent-control-server
spec:
  replicas: 1
  selector:
    matchLabels:
      app: o11y-agent-control-server
  template:
    metadata:
      labels:
        app: o11y-agent-control-server
    spec:
      securityContext:
        fsGroup: 65532
      serviceAccountName: dedicated-regional-server-manager
      containers:
      - name: agent-control-server
        image: cp9.local/dedicated-o11y-agent-control-server:placeholder
        args:
          - "--root-config=/etc/root-configs/config.yaml"
          - "--agent-config-templates-dir=/templates"
        volumeMounts:
          - name: root-config
            mountPath: /etc/root-configs
          - name: templates-dedicated-k8s
            mountPath: /templates/dedicated/k8s
          - name: templates-dedicated-k8s-jobs
            mountPath: /templates/dedicated/k8s/jobs
          - name: templates-dedicated-tidbcluster
            mountPath: /templates/dedicated/tidbcluster
          - name: dedicated-api-kubeconfig
            mountPath: /var/run/cp9/dedicated-api
            readOnly: true
        env:
          - name: CONCURRENT_RECONCILES
            value: "1"
          - name: KUBECONFIG
            value: /var/run/cp9/dedicated-api/o11y-agent-control-server.kubeconfig
          - name: AWS_REGION
            value: us-west-2
          - name: AWS_DEFAULT_REGION
            value: us-west-2
          - name: O11Y_AUTH0_CLIENT_ID
            valueFrom:
              secretKeyRef:
                name: o11y-auth0-client
                key: Auth0ClientID
          - name: O11Y_AUTH0_CLIENT_SECRET
            valueFrom:
              secretKeyRef:
                name: o11y-auth0-client
                key: Auth0ClientSecret
        readinessProbe:
          httpGet:
            path: /readyz
            port: 8081
          initialDelaySeconds: 5
          periodSeconds: 5
        livenessProbe:
          httpGet:
            path: /healthz
            port: 8081
          initialDelaySeconds: 15
          periodSeconds: 10
        resources:
          requests:
            cpu: 100m
            memory: 100Mi
          limits:
            cpu: 500m
            memory: 500Mi
      volumes:
        - name: root-config
          configMap:
            name: o11y-agent-control-server-root-config
        - name: templates-dedicated-k8s
          configMap:
            name: templates-dedicated-k8s
        - name: templates-dedicated-k8s-jobs
          configMap:
            name: templates-dedicated-k8s-jobs
        - name: templates-dedicated-tidbcluster
          configMap:
            name: templates-dedicated-tidbcluster
        - name: dedicated-api-kubeconfig
          secret:
            secretName: dedicated-api-kubeconfigs
            defaultMode: 0400
            items:
              - key: o11y-agent-control-server.kubeconfig
                path: o11y-agent-control-server.kubeconfig
