apiVersion: helm.toolkit.fluxcd.io/v2beta2
kind: HelmRelease
metadata:
  name: hetzner-runner
  namespace: gitlab-runner
spec:
  serviceAccountName: flux-reconciler
  timeout: 15m
  releaseName: hetzner-runner
  chart:
    spec:
      chart: gitlab-runner
      sourceRef:
        kind: HelmRepository
        name: gitlab-runner
        namespace: gitlab-runner
      version: 0.62.1
  interval: 5m
  install:
    remediation:
      retries: -1
  upgrade:
    remediation:
      retries: -1
  postRenderers:
    - kustomize:
        patchesStrategicMerge:
          - kind: Deployment
            apiVersion: apps/v1
            metadata:
              name: hetzner-runner-gitlab-runner
              namespace: gitlab-runner
            spec:
              strategy:
                type: Recreate
  valuesFrom:
    - kind: ConfigMap
      name: gitlab-runner-base-values
      valuesKey: values.yaml
    - kind: Secret
      name: hetzner-runner-base-values
      valuesKey: values.yaml
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: hetzner-runner
spec:
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 1Gi
---
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
  name: allow-from-monitoring-hetzner-runner
spec:
  policyTypes:
  - Ingress
  ingress:
  - from:
    - namespaceSelector:
        matchLabels:
          monitoring.shivering-isles.com/network-access-required: "true"
      podSelector:
        matchLabels:
          app.kubernetes.io/name: prometheus
  podSelector:
    matchLabels:
      app: hetzner-runner-gitlab-runner
      release: hetzner-runner
