apiVersion: apps/v1
kind: Deployment
metadata:
  name: controller-manager
  labels:
    control-plane: watermarkpodautoscaler-controller-manager
spec:
  selector:
    matchLabels:
      control-plane: watermarkpodautoscaler-controller-manager
  replicas: 1
  template:
    metadata:
      annotations:
        ad.datadoghq.com/watermarkpodautoscaler.check_names: '["openmetrics"]'
        ad.datadoghq.com/watermarkpodautoscaler.init_configs: '[{}]'
        ad.datadoghq.com/watermarkpodautoscaler.instances: '[{"prometheus_url": "http://%%host%%:8383/metrics","namespace":"watermarkpodautoscaler","metrics": ["wpa","wpa_controller*"]}]'
        # sample configuration for label joins (see DD_LABELS_AS_TAGS)
        # ad.datadoghq.com/watermarkpodautoscaler.instances: '[{"prometheus_url": "http://%%host%%:8383/metrics","namespace":"watermarkpodautoscaler","metrics": ["wpa","wpa_controller*"],"label_joins": {"wpa_controller_labels_info": {"label_to_match":"wpa_name","labels_to_get": ["label1","label2"]}}}]'
      labels:
        control-plane: watermarkpodautoscaler-controller-manager
    spec:
      serviceAccountName: watermarkpodautoscaler-controller-manager
      containers:
      - name: watermarkpodautoscaler
        args:
        - --enable-leader-election
        image: hugohafner/watermarkpodautoscaler:v0.4.3
        imagePullPolicy: IfNotPresent
        resources:
          limits:
            cpu: 100m
            memory: 500Mi
          requests:
            cpu: 100m
            memory: 100Mi
        ports:
          - name: metrics
            containerPort: 8383
            protocol: TCP
        livenessProbe:
          httpGet:
            path: /healthz/
            port: 9440
          periodSeconds: 10
        env:
          # Watch every ns. Comment if you want to watch all namespaces
          - name: WATCH_NAMESPACE
            valueFrom:
              fieldRef:
                fieldPath: metadata.namespace
          - name: POD_NAME
            valueFrom:
              fieldRef:
                fieldPath: metadata.name
          # Additional labels to include as tags (requires label joins configuration for prometheus check)
          # - name: DD_LABELS_AS_TAGS
          #   value: "label1 label2"
      terminationGracePeriodSeconds: 10
