apiVersion: apps/v1
kind: StatefulSet
metadata:
  labels:
    app.kubernetes.io/component: rule-evaluation-engine
    app.kubernetes.io/instance: observatorium-xyz
    app.kubernetes.io/name: thanos-rule
    app.kubernetes.io/part-of: observatorium
    app.kubernetes.io/version: v0.20.1
  name: observatorium-xyz-thanos-rule
  namespace: observatorium
spec:
  replicas: 1
  selector:
    matchLabels:
      app.kubernetes.io/component: rule-evaluation-engine
      app.kubernetes.io/instance: observatorium-xyz
      app.kubernetes.io/name: thanos-rule
      app.kubernetes.io/part-of: observatorium
  serviceName: observatorium-xyz-thanos-rule
  template:
    metadata:
      labels:
        app.kubernetes.io/component: rule-evaluation-engine
        app.kubernetes.io/instance: observatorium-xyz
        app.kubernetes.io/name: thanos-rule
        app.kubernetes.io/part-of: observatorium
        app.kubernetes.io/version: v0.20.1
    spec:
      containers:
      - args:
        - rule
        - --log.level=info
        - --log.format=logfmt
        - --grpc-address=0.0.0.0:10901
        - --http-address=0.0.0.0:10902
        - --objstore.config=$(OBJSTORE_CONFIG)
        - --data-dir=/var/thanos/rule
        - --label=rule_replica="$(NAME)"
        - --alert.label-drop=rule_replica
        - --tsdb.retention=48h
        - --tsdb.block-duration=2h
        - --query=dnssrv+_http._tcp.observatorium-xyz-thanos-query.observatorium.svc.cluster.local
        env:
        - name: NAME
          valueFrom:
            fieldRef:
              fieldPath: metadata.name
        - name: OBJSTORE_CONFIG
          valueFrom:
            secretKeyRef:
              key: thanos.yaml
              name: thanos-objectstorage
        - name: HOST_IP_ADDRESS
          valueFrom:
            fieldRef:
              fieldPath: status.hostIP
        image: quay.io/thanos/thanos:v0.20.1
        livenessProbe:
          failureThreshold: 24
          httpGet:
            path: /-/healthy
            port: 10902
            scheme: HTTP
          periodSeconds: 5
        name: thanos-rule
        ports:
        - containerPort: 10901
          name: grpc
        - containerPort: 10902
          name: http
        readinessProbe:
          failureThreshold: 18
          httpGet:
            path: /-/ready
            port: 10902
            scheme: HTTP
          initialDelaySeconds: 10
          periodSeconds: 5
        resources: {}
        terminationMessagePolicy: FallbackToLogsOnError
        volumeMounts:
        - mountPath: /var/thanos/rule
          name: data
          readOnly: false
      securityContext:
        fsGroup: 65534
        runAsUser: 65534
      serviceAccountName: observatorium-xyz-thanos-rule
      volumes: []
  volumeClaimTemplates:
  - metadata:
      labels:
        app.kubernetes.io/component: rule-evaluation-engine
        app.kubernetes.io/instance: observatorium-xyz
        app.kubernetes.io/name: thanos-rule
        app.kubernetes.io/part-of: observatorium
      name: data
    spec:
      accessModes:
      - ReadWriteOnce
      resources:
        requests:
          storage: 50Gi
