# Copyright 2021 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     https:#www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

apiVersion: apps/v1
kind: Deployment
metadata:
  name: rule-evaluator
  labels:
    app.kubernetes.io/name: rule-evaluator
spec:
  replicas: 1
  selector:
    matchLabels:
      app.kubernetes.io/name: rule-evaluator
  template:
    metadata:
      labels:
        app.kubernetes.io/name: rule-evaluator
    spec:
      containers:
      - name: evaluator
        image: gke.gcr.io/prometheus-engine/rule-evaluator:v0.1.1-gke.0
        args:
        - "--config.file=/etc/config/config.yaml"
        - "--web.listen-address=:9092"
        ports:
        - name: r-eval-metrics
          containerPort: 9092
        livenessProbe:
          httpGet:
            path: /-/healthy
            port: r-eval-metrics
        readinessProbe:
          httpGet:
            path: /-/ready
            port: r-eval-metrics
          # Readiness attempts a query round-trip so we need a more generous timeout.
          timeoutSeconds: 5
        resources:
          limits:
            memory: 1G
          requests:
            cpu: 100m
            memory: 200M
        volumeMounts:
        - mountPath: /etc/config
          name: config
          readOnly: true
        - mountPath: /etc/rules
          name: rules
          readOnly: true
      - name: config-reloader
        args:
        - --config-file=/etc/config/config.yaml
        - --watched-dir=/etc/rules
        - --reload-url=http://localhost:9092/-/reload
        - --listen-address=:9093
        image: gke.gcr.io/prometheus-engine/config-reloader:v0.1.1-gke.0
        name: config-reloader
        ports:
        - containerPort: 9093
          name: cfg-rel-metrics
          protocol: TCP
        resources:
          limits:
            memory: 64M
          requests:
            cpu: 5m
            memory: 16M
        volumeMounts:
        - mountPath: /etc/config
          name: config
          readOnly: true
        - mountPath: /etc/rules
          name: rules
          readOnly: true
      volumes:
      - name: config
        configMap:
          name: rule-evaluator
      - name: rules
        configMap:
          name: rules