From d87718bdcb2501c9b3fb5ba18ad75eaaa2204c26 Mon Sep 17 00:00:00 2001 From: unkin-agent Date: Sat, 28 Nov 2026 14:10:51 +1100 Subject: [PATCH] Route iuclabs runner package installs through artifactapi - add an artifactapi component setting pip, uv, go, npm, yarn and corepack registry env on every runner - build a combined public + internal CA bundle in an init container and point SSL_CERT_FILE/REQUESTS_CA_BUNDLE at it - allow every runner egress to traefik-internal on 443, replacing the dind and build copies --- .../artifactapi/init-containers-list.yaml | 4 ++ .../components/artifactapi/kustomization.yaml | 33 ++++++++++++++ .../components/artifactapi/networkpolicy.yaml | 25 +++++++++++ .../artifactapi/scaleset-patch.yaml | 45 +++++++++++++++++++ .../iuclabs-build/networkpolicy.yaml | 5 +-- .../iuclabs-dind/networkpolicy.yaml | 11 ----- apps/base/iuclabs-runners/kustomization.yaml | 1 + 7 files changed, 109 insertions(+), 15 deletions(-) create mode 100644 apps/base/iuclabs-runners/components/artifactapi/init-containers-list.yaml create mode 100644 apps/base/iuclabs-runners/components/artifactapi/kustomization.yaml create mode 100644 apps/base/iuclabs-runners/components/artifactapi/networkpolicy.yaml create mode 100644 apps/base/iuclabs-runners/components/artifactapi/scaleset-patch.yaml diff --git a/apps/base/iuclabs-runners/components/artifactapi/init-containers-list.yaml b/apps/base/iuclabs-runners/components/artifactapi/init-containers-list.yaml new file mode 100644 index 0000000..e84eed4 --- /dev/null +++ b/apps/base/iuclabs-runners/components/artifactapi/init-containers-list.yaml @@ -0,0 +1,4 @@ +--- +- op: add + path: /spec/template/spec/initContainers + value: [] diff --git a/apps/base/iuclabs-runners/components/artifactapi/kustomization.yaml b/apps/base/iuclabs-runners/components/artifactapi/kustomization.yaml new file mode 100644 index 0000000..31e17f2 --- /dev/null +++ b/apps/base/iuclabs-runners/components/artifactapi/kustomization.yaml @@ -0,0 +1,33 @@ +--- +apiVersion: kustomize.config.k8s.io/v1alpha1 +kind: Component + +resources: + - networkpolicy.yaml + +generatorOptions: + disableNameSuffixHash: true + +configMapGenerator: + - name: runner-artifactapi + namespace: iuclabs-runners + literals: + - PIP_INDEX_URL=https://artifactapi.k8s.syd1.au.unkin.net/api/v1/remote/pypi/simple + - UV_DEFAULT_INDEX=https://artifactapi.k8s.syd1.au.unkin.net/api/v1/remote/pypi/simple + - GOPROXY=https://artifactapi.k8s.syd1.au.unkin.net/api/v1/virtual/go,direct + - npm_config_registry=https://artifactapi.k8s.syd1.au.unkin.net/api/v1/remote/npmjs/ + - YARN_NPM_REGISTRY_SERVER=https://artifactapi.k8s.syd1.au.unkin.net/api/v1/remote/npmjs + - COREPACK_NPM_REGISTRY=https://artifactapi.k8s.syd1.au.unkin.net/api/v1/remote/npmjs + - SSL_CERT_FILE=/etc/ssl/combined/ca-certificates.crt + - REQUESTS_CA_BUNDLE=/etc/ssl/combined/ca-certificates.crt + +patches: + - path: init-containers-list.yaml + target: + group: actions.github.com + kind: AutoscalingRunnerSet + name: iuclabs-(k8s|infra|release) + - path: scaleset-patch.yaml + target: + group: actions.github.com + kind: AutoscalingRunnerSet diff --git a/apps/base/iuclabs-runners/components/artifactapi/networkpolicy.yaml b/apps/base/iuclabs-runners/components/artifactapi/networkpolicy.yaml new file mode 100644 index 0000000..d30eea2 --- /dev/null +++ b/apps/base/iuclabs-runners/components/artifactapi/networkpolicy.yaml @@ -0,0 +1,25 @@ +--- +apiVersion: networking.k8s.io/v1 +kind: NetworkPolicy +metadata: + name: egress-artifactapi + namespace: iuclabs-runners +spec: + podSelector: + matchExpressions: + - key: runners.unkin.net/scale-set + operator: Exists + policyTypes: + - Egress + egress: + # artifactapi via traefik-internal; kube-proxy DNATs its LB IP to these pods + - to: + - namespaceSelector: + matchLabels: + kubernetes.io/metadata.name: traefik-system + podSelector: + matchLabels: + app.kubernetes.io/instance: traefik-internal-traefik-system + ports: + - protocol: TCP + port: 443 diff --git a/apps/base/iuclabs-runners/components/artifactapi/scaleset-patch.yaml b/apps/base/iuclabs-runners/components/artifactapi/scaleset-patch.yaml new file mode 100644 index 0000000..13b7783 --- /dev/null +++ b/apps/base/iuclabs-runners/components/artifactapi/scaleset-patch.yaml @@ -0,0 +1,45 @@ +--- +# public roots + internal CA in one bundle, so SSL_CERT_FILE keeps github.com trusted +- op: add + path: /spec/template/spec/initContainers/- + value: + name: combine-certs + image: ghcr.io/actions/actions-runner:2.338.2 + command: + - sh + - -c + - cat /etc/ssl/certs/ca-certificates.crt /etc/vault-ca/ca.crt > /etc/ssl/combined/ca-certificates.crt + securityContext: + allowPrivilegeEscalation: false + capabilities: + drop: + - ALL + resources: + requests: + cpu: 50m + memory: 32Mi + limits: + cpu: 200m + memory: 64Mi + volumeMounts: + - name: vault-ca-cert + mountPath: /etc/vault-ca + readOnly: true + - name: combined-certs + mountPath: /etc/ssl/combined +- op: add + path: /spec/template/spec/containers/0/envFrom + value: + - configMapRef: + name: runner-artifactapi +- op: add + path: /spec/template/spec/containers/0/volumeMounts/- + value: + name: combined-certs + mountPath: /etc/ssl/combined + readOnly: true +- op: add + path: /spec/template/spec/volumes/- + value: + name: combined-certs + emptyDir: {} diff --git a/apps/base/iuclabs-runners/components/iuclabs-build/networkpolicy.yaml b/apps/base/iuclabs-runners/components/iuclabs-build/networkpolicy.yaml index 9dd1115..0609c4e 100644 --- a/apps/base/iuclabs-runners/components/iuclabs-build/networkpolicy.yaml +++ b/apps/base/iuclabs-runners/components/iuclabs-build/networkpolicy.yaml @@ -43,7 +43,7 @@ spec: ports: - protocol: TCP port: 8200 - # artifactapi via traefik-internal; kube-proxy DNATs its LB IP to these pods + # container-base fetches the internal CA RPM over http from artifactapi before TLS trust exists - to: - namespaceSelector: matchLabels: @@ -52,8 +52,5 @@ spec: matchLabels: app.kubernetes.io/instance: traefik-internal-traefik-system ports: - - protocol: TCP - port: 443 - # container-base fetches the internal CA RPM over http from artifactapi before TLS trust exists - protocol: TCP port: 80 diff --git a/apps/base/iuclabs-runners/components/iuclabs-dind/networkpolicy.yaml b/apps/base/iuclabs-runners/components/iuclabs-dind/networkpolicy.yaml index aa18df3..0e2ad38 100644 --- a/apps/base/iuclabs-runners/components/iuclabs-dind/networkpolicy.yaml +++ b/apps/base/iuclabs-runners/components/iuclabs-dind/networkpolicy.yaml @@ -43,14 +43,3 @@ spec: ports: - protocol: TCP port: 8200 - # artifactapi via traefik-internal; kube-proxy DNATs its LB IP to these pods - - to: - - namespaceSelector: - matchLabels: - kubernetes.io/metadata.name: traefik-system - podSelector: - matchLabels: - app.kubernetes.io/instance: traefik-internal-traefik-system - ports: - - protocol: TCP - port: 443 diff --git a/apps/base/iuclabs-runners/kustomization.yaml b/apps/base/iuclabs-runners/kustomization.yaml index 8c1a992..8deeb2b 100644 --- a/apps/base/iuclabs-runners/kustomization.yaml +++ b/apps/base/iuclabs-runners/kustomization.yaml @@ -15,6 +15,7 @@ components: - components/iuclabs-release - components/iuclabs-dind - components/iuclabs-build + - components/artifactapi generatorOptions: disableNameSuffixHash: true