diff --git a/apps/base/forgejo/kustomization.yaml b/apps/base/forgejo/kustomization.yaml index 5f575b3..307bfaf 100644 --- a/apps/base/forgejo/kustomization.yaml +++ b/apps/base/forgejo/kustomization.yaml @@ -7,3 +7,6 @@ resources: - cluster.yaml - deployment.yaml - service.yaml + - runner-configmap.yaml + - runner-arm64.yaml + - runner-amd64.yaml diff --git a/apps/base/forgejo/runner-amd64.yaml b/apps/base/forgejo/runner-amd64.yaml new file mode 100644 index 0000000..54813f6 --- /dev/null +++ b/apps/base/forgejo/runner-amd64.yaml @@ -0,0 +1,147 @@ +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + name: forgejo-runner-amd64 + namespace: forgejo +spec: + accessModes: + - ReadWriteOnce + storageClassName: local-path + resources: + requests: + storage: 20Gi +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: forgejo-runner-amd64 + namespace: forgejo + labels: + app: forgejo-runner + arch: amd64 +spec: + replicas: 1 + selector: + matchLabels: + app: forgejo-runner + arch: amd64 + strategy: + type: Recreate + template: + metadata: + labels: + app: forgejo-runner + arch: amd64 + spec: + nodeSelector: + kubernetes.io/hostname: siriussec + securityContext: + fsGroup: 0 + initContainers: + - name: register + image: code.forgejo.org/forgejo/runner:5.0.1 + imagePullPolicy: IfNotPresent + command: + - sh + - -c + - | + set -e + if [ -s /data/runner.ini ]; then + echo already-registered + exit 0 + fi + forgejo-runner register --no-interactive \ + --instance https://forgejo.siriusdevops.com \ + --token "$RUNNER_TOKEN" \ + --name siriussec-amd64 \ + --labels 'docker-amd64:docker://node:20-bullseye,amd64:docker://node:20-bullseye' \ + --config /config/config.toml + env: + - name: RUNNER_TOKEN + valueFrom: + secretKeyRef: + name: forgejo-runner-amd64-token + key: token + volumeMounts: + - name: config-toml + mountPath: /config/config.toml + subPath: amd64.toml + - name: data + mountPath: /data + containers: + - name: dind + image: docker:27-dind + imagePullPolicy: IfNotPresent + command: + - sh + - -c + - | + dockerd --host=unix:///var/run/docker.sock --tls=false --mtu=1420 & + pid=$! + i=0 + while [ "$i" -lt 30 ]; do + if [ -S /var/run/docker.sock ]; then + chmod 666 /var/run/docker.sock + break + fi + i=$((i+1)) + sleep 1 + done + wait "$pid" + securityContext: + privileged: true + volumeMounts: + - name: dind-run + mountPath: /var/run + - name: data + mountPath: /var/lib/docker + subPath: docker + resources: + requests: + cpu: 200m + memory: 512Mi + limits: + memory: 4Gi + - name: runner + image: code.forgejo.org/forgejo/runner:5.0.1 + imagePullPolicy: IfNotPresent + command: + - sh + - -c + - | + set -e + i=0 + while [ "$i" -lt 60 ]; do + if [ -S /var/run/docker.sock ]; then + break + fi + i=$((i+1)) + sleep 2 + done + exec forgejo-runner --config /config/config.toml daemon + env: + - name: DOCKER_HOST + value: unix:///var/run/docker.sock + volumeMounts: + - name: config-toml + mountPath: /config/config.toml + subPath: amd64.toml + - name: data + mountPath: /data + - name: dind-run + mountPath: /var/run + resources: + requests: + cpu: 50m + memory: 128Mi + limits: + memory: 512Mi + volumes: + - name: config-toml + configMap: + name: forgejo-runner-config + - name: data + persistentVolumeClaim: + claimName: forgejo-runner-amd64 + - name: dind-run + emptyDir: {} diff --git a/apps/base/forgejo/runner-arm64.yaml b/apps/base/forgejo/runner-arm64.yaml new file mode 100644 index 0000000..f3012c9 --- /dev/null +++ b/apps/base/forgejo/runner-arm64.yaml @@ -0,0 +1,99 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: forgejo-runner-arm64 + namespace: forgejo + labels: + app: forgejo-runner + arch: arm64 +spec: + replicas: 1 + selector: + matchLabels: + app: forgejo-runner + arch: arm64 + strategy: + type: Recreate + template: + metadata: + labels: + app: forgejo-runner + arch: arm64 + spec: + nodeSelector: + kubernetes.io/hostname: rpi + tolerations: + - key: dedicated + operator: Equal + value: network + effect: PreferNoSchedule + securityContext: + supplementalGroups: [984] + containers: + - name: runner + image: code.forgejo.org/forgejo/runner:5.0.1 + imagePullPolicy: IfNotPresent + command: + - forgejo-runner + - --config + - /config/config.toml + - daemon + env: + - name: DOCKER_HOST + value: unix:///var/run/docker.sock + securityContext: + privileged: true + runAsUser: 0 + runAsGroup: 0 + volumeMounts: + - name: docker-sock + mountPath: /var/run/docker.sock + - name: docker-static + mountPath: /usr/bin/docker + readOnly: true + - name: cli-plugins + mountPath: /usr/local/lib/docker/cli-plugins + readOnly: true + - name: config-toml + mountPath: /config/config.toml + subPath: arm64.toml + - name: runner-ini + mountPath: /config/runner.ini + - name: cache + mountPath: /opt/siriusdevops/runner/cache + - name: siriusdevops + mountPath: /opt/siriusdevops + resources: + requests: + cpu: 50m + memory: 128Mi + limits: + memory: 512Mi + volumes: + - name: docker-sock + hostPath: + path: /var/run/docker.sock + type: Socket + - name: docker-static + hostPath: + path: /usr/local/bin/docker-static + type: File + - name: cli-plugins + hostPath: + path: /opt/siriusdevops/runner/cli-plugins + type: DirectoryOrCreate + - name: config-toml + configMap: + name: forgejo-runner-config + - name: runner-ini + hostPath: + path: /opt/siriusdevops/runner/config/runner.ini + type: File + - name: cache + hostPath: + path: /opt/siriusdevops/runner/cache + type: DirectoryOrCreate + - name: siriusdevops + hostPath: + path: /opt/siriusdevops + type: Directory diff --git a/apps/base/forgejo/runner-configmap.yaml b/apps/base/forgejo/runner-configmap.yaml new file mode 100644 index 0000000..f8cfa31 --- /dev/null +++ b/apps/base/forgejo/runner-configmap.yaml @@ -0,0 +1,52 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: forgejo-runner-config + namespace: forgejo +data: + arm64.toml: | + log: + level: info + runner: + file: /config/runner.ini + # capacity 1: ci.yml builds every job's Rust target into ONE shared named + # volume (onionwire-target-ci, mounted at /target). Two jobs writing that + # volume concurrently clobber each other's freshly-linked test binaries, + # which then fail with "could not execute process ... (never executed) + # Permission denied (os error 13)". capacity 1 is the enforced serializer + # because Forgejo's `concurrency.group` was observed NOT serializing two + # runs of the same group on this runner (446 + 447 overlapped). + capacity: 1 + timeout: 1h + cache: /opt/siriusdevops/runner/cache + cache: + enabled: true + dir: /opt/siriusdevops/runner/cache + container: + privileged: true + # No docker_host here: setting it makes the runner inject the host socket + # bind into the job container itself, which collides with the explicit + # -v /var/run/docker.sock in options ("Duplicate mount point"). + options: -v /usr/local/bin/docker-static:/usr/bin/docker:ro -v /opt/siriusdevops/runner/cli-plugins:/usr/local/lib/docker/cli-plugins:ro -v /var/run/docker.sock:/var/run/docker.sock + valid_volumes: + - "**" + amd64.toml: | + log: + level: info + runner: + file: /data/runner.ini + # capacity 1: the dind daemon on this runner holds the release/CI build + # containers and images. Two concurrent x86_64 builds on it made the + # *second* build's egress fail (apt looping on "Ign:" for Debian + # InRelease) while a single build on the same daemon succeeded. + capacity: 1 + timeout: 1h + cache: /data/cache + cache: + enabled: true + dir: /data/cache + container: + privileged: true + docker_host: "unix:///var/run/docker.sock" + valid_volumes: + - "**" diff --git a/infrastructure/networking/cilium/values.yaml b/infrastructure/networking/cilium/values.yaml index 51ece41..5ca43e9 100644 --- a/infrastructure/networking/cilium/values.yaml +++ b/infrastructure/networking/cilium/values.yaml @@ -4,13 +4,17 @@ k8sServicePort: "6443" l7Proxy: true +socketLB: + enabled: true + hostNamespaceOnly: false + gatewayAPI: enabled: true hostNetwork: enabled: true nodes: matchLabels: - dedicated: network + gateway: "true" envoy: enabled: true @@ -26,5 +30,7 @@ ipam: clusterPoolIPv4PodCIDRList: - 10.244.0.0/16 -routingMode: tunnel -tunnelProtocol: vxlan +routingMode: native +autoDirectNodeRoutes: true +ipv4NativeRoutingCIDR: 10.244.0.0/16 +enableIPv4Masquerade: true