apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: github-actions-exporter
spec:
  serviceName: github-actions-exporter
  replicas: 1
  updateStrategy:
    type: RollingUpdate
  selector:
    matchLabels:
      app: github-actions-exporter
  template:
    metadata:
      annotations:
        prometheus.io/scrape: "true"
        prometheus.io/schema: "http"
        prometheus.io/port: "9090"
        prometheus.io/path: "/metrics"
      labels:
        app: github-actions-exporter
    spec:
      serviceAccountName: github-actions-exporter
      securityContext:
        sysctls:
          # https://github.com/kubernetes/kubernetes/pull/54896
          #- name: net.core.somaxconn
          #  value: "65535"
          - name: net.ipv4.ip_local_port_range
            value: "10000 65535"
      affinity:
        podAntiAffinity:
          preferredDuringSchedulingIgnoredDuringExecution:
            - podAffinityTerm:
                labelSelector:
                  matchExpressions:
                    - key: app
                      operator: In
                      values:
                        - github-actions-exporter
                topologyKey: kubernetes.io/hostname
              weight: 100
      containers:
        - name: github-actions-exporter
          image: ghcr.io/kaidotdev/github-actions-exporter:v0.1.1
          imagePullPolicy: Always
          args:
            - server
            - --api-address=0.0.0.0:8000
            - --monitor-address=0.0.0.0:9090
            - --enable-tracing
            - --repository=kaidotdev/github-actions-exporter
            - --token=dummy
          env:
            - name: GOGC
              value: "100"
          ports:
            - containerPort: 8000
            - containerPort: 9090
          readinessProbe:
            httpGet:
              path: /health
              port: 8000
              scheme: HTTP
            initialDelaySeconds: 10
            periodSeconds: 1
            successThreshold: 3
            failureThreshold: 1
            timeoutSeconds: 1
