apiVersion: apps/v1
kind: StatefulSet
metadata:
  labels:
    app.kubernetes.io/name: thanos-ruler
  name: thanos-ruler
  namespace: observatorium
spec:
  replicas: 2
  selector:
    matchLabels:
      app.kubernetes.io/name: thanos-ruler
  serviceName: thanos-ruler
  template:
    metadata:
      labels:
        app.kubernetes.io/name: thanos-ruler
    spec:
      containers:
      - args:
        - rule
        - --grpc-address=0.0.0.0:10901
        - --http-address=0.0.0.0:10902
        - --objstore.config=$(OBJSTORE_CONFIG)
        - --data-dir=/var/thanos/ruler
        - --label=ruler_replica="$(NAME)"
        - --alert.label-drop="ruler_replica"
        - --query=dnssrv+_http._tcp.thanos-querier.observatorium.svc.cluster.local
        env:
        - name: NAME
          valueFrom:
            fieldRef:
              fieldPath: metadata.name
        - name: OBJSTORE_CONFIG
          valueFrom:
            secretKeyRef:
              key: thanos.yaml
              name: thanos-objectstorage
        image: quay.io/thanos/thanos:v0.9.0
        livenessProbe:
          failureThreshold: 4
          httpGet:
            path: /-/healthy
            port: 10902
            scheme: HTTP
          periodSeconds: 30
        name: thanos-ruler
        ports:
        - containerPort: 10901
          name: grpc
        - containerPort: 10902
          name: http
        readinessProbe:
          httpGet:
            path: /-/ready
            port: 10902
            scheme: HTTP
          initialDelaySeconds: 10
          periodSeconds: 30
        resources:
          limits:
            cpu: "1"
            memory: 1Gi
          requests:
            cpu: 100m
            memory: 256Mi
        volumeMounts:
        - mountPath: /var/thanos/ruler
          name: thanos-ruler-data
          readOnly: false
      volumes:
      - emptyDir: {}
        name: thanos-ruler-data
