add iuclabs-infra runner scale set for terraform repos
ci/woodpecker/pr/pre-commit Pipeline was successful
ci/woodpecker/pr/kubeconform Pipeline was successful

This commit is contained in:
2026-11-21 00:12:42 +11:00
parent a90cc37340
commit e12d0a0145
6 changed files with 205 additions and 4 deletions
@@ -0,0 +1,7 @@
---
apiVersion: kustomize.config.k8s.io/v1alpha1
kind: Component
resources:
- scaleset.yaml
- networkpolicy.yaml
@@ -0,0 +1,97 @@
---
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: egress-iuclabs-infra
namespace: iuclabs-runners
spec:
podSelector:
matchLabels:
runners.unkin.net/scale-set: iuclabs-infra
policyTypes:
- Egress
egress:
- to:
- ipBlock:
cidr: 0.0.0.0/0
except:
- 10.0.0.0/8
- 172.16.0.0/12
- 192.168.0.0/16
- 198.18.0.0/15
- 0.0.0.0/8
- 100.64.0.0/10
- 127.0.0.0/8
- 169.254.0.0/16
- 224.0.0.0/4
- 240.0.0.0/4
ports:
- protocol: TCP
port: 443
# vault.service.consul servers, from `dig vault.service.consul`
- to:
- ipBlock:
cidr: 198.18.25.78/32
- ipBlock:
cidr: 198.18.26.197/32
- ipBlock:
cidr: 198.18.27.116/32
- ipBlock:
cidr: 198.18.28.248/32
- ipBlock:
cidr: 198.18.29.92/32
ports:
- protocol: TCP
port: 8200
# consul.service.consul servers (terraform state backend, consul provider), from `dig consul.service.consul`
- to:
- ipBlock:
cidr: 198.18.25.109/32
- ipBlock:
cidr: 198.18.26.224/32
- ipBlock:
cidr: 198.18.27.165/32
- ipBlock:
cidr: 198.18.28.53/32
- ipBlock:
cidr: 198.18.29.198/32
ports:
- protocol: TCP
port: 443
# LB IPs are DNATed to these pods by kube-proxy: traefik-internal (artifactapi, identity, netbox),
# traefik-external (git.unkin.net), rke2-ingress-nginx (ci.k8s.syd1.au.unkin.net)
- to:
- namespaceSelector:
matchLabels:
kubernetes.io/metadata.name: traefik-system
podSelector:
matchLabels:
app.kubernetes.io/instance: traefik-internal-traefik-system
- namespaceSelector:
matchLabels:
kubernetes.io/metadata.name: traefik-system
podSelector:
matchLabels:
app.kubernetes.io/instance: traefik-external-traefik-system
- namespaceSelector:
matchLabels:
kubernetes.io/metadata.name: kube-system
podSelector:
matchLabels:
app.kubernetes.io/name: rke2-ingress-nginx
app.kubernetes.io/component: controller
ports:
- protocol: TCP
port: 443
# authentik-server ClusterIP (TF_VAR_authentik_url pins CI to one replica, goauthentik#954)
- to:
- namespaceSelector:
matchLabels:
kubernetes.io/metadata.name: authentik
podSelector:
matchLabels:
app.kubernetes.io/name: authentik
app.kubernetes.io/component: server
ports:
- protocol: TCP
port: 9000
@@ -0,0 +1,76 @@
---
apiVersion: actions.github.com/v1alpha1
kind: AutoscalingRunnerSet
metadata:
name: iuclabs-infra
namespace: iuclabs-runners
labels:
app.kubernetes.io/version: "0.15.1"
annotations:
actions.github.com/cleanup-manager-role-name: arc-manager
actions.github.com/cleanup-manager-role-binding: arc-manager
spec:
githubConfigUrl: https://github.com/IUCLabs
githubConfigSecret: github-app
runnerScaleSetName: iuclabs-infra
minRunners: 0
maxRunners: 2
template:
metadata:
labels:
runners.unkin.net/scale-set: iuclabs-infra
spec:
serviceAccountName: runner
automountServiceAccountToken: false
restartPolicy: Never
securityContext:
runAsNonRoot: true
runAsUser: 1001
runAsGroup: 1001
seccompProfile:
type: RuntimeDefault
topologySpreadConstraints:
- maxSkew: 1
topologyKey: kubernetes.io/hostname
whenUnsatisfiable: ScheduleAnyway
labelSelector:
matchLabels:
runners.unkin.net/scale-set: iuclabs-infra
containers:
- name: runner
image: ghcr.io/actions/actions-runner:2.338.2
command: ["/home/runner/run.sh"]
env:
- name: ACTIONS_RUNNER_HOOK_JOB_STARTED
value: /hooks/job-started.sh
- name: NODE_EXTRA_CA_CERTS
value: /etc/vault-ca/ca.crt
- name: RUNNER_MODE
value: infra
securityContext:
allowPrivilegeEscalation: false
capabilities:
drop:
- ALL
resources:
requests:
cpu: 1
memory: 512Mi
limits:
cpu: 2
memory: 2Gi
volumeMounts:
- name: hooks
mountPath: /hooks
readOnly: true
- name: vault-ca-cert
mountPath: /etc/vault-ca
readOnly: true
volumes:
- name: hooks
configMap:
name: runner-hooks
defaultMode: 0555
- name: vault-ca-cert
secret:
secretName: vault-ca-cert
+6
View File
@@ -13,6 +13,12 @@ jq -e 'type == "object"' "${GITHUB_EVENT_PATH}" >/dev/null 2>&1 || refuse "event
case "${RUNNER_MODE:-}" in
default) ;;
infra)
case "${GITHUB_REPOSITORY:-}" in
IUCLabs/terraform-git | IUCLabs/terraform-vault | IUCLabs/terraform-artifactapi | IUCLabs/terraform-authentik | IUCLabs/terraform-binarylane) ;;
*) refuse "infra runners only run IUCLabs terraform repos, got '${GITHUB_REPOSITORY:-}'" ;;
esac
;;
release)
[ "${event}" = push ] || refuse "release runners only run tag pushes"
ref=$(jq -r '.ref' "${GITHUB_EVENT_PATH}") || refuse "event payload unreadable"
@@ -11,6 +11,7 @@ resources:
components:
- components/iuclabs-k8s
- components/iuclabs-infra
- components/iuclabs-release
generatorOptions:
+18 -4
View File
@@ -5,16 +5,17 @@ hook=apps/base/iuclabs-runners/job-started.sh
fixtures=ci/fixtures/runner-hooks
fail=0
# check <want> <mode|unset> <event|-> <fixture|->
# check <want> <mode|unset> <event|-> <fixture|-> [repo]
check() {
local want=$1 mode=$2 event=$3 fixture=$4 got=0
local -a env=(-u GITHUB_EVENT_NAME -u GITHUB_EVENT_PATH -u RUNNER_MODE)
local want=$1 mode=$2 event=$3 fixture=$4 repo=${5:-} got=0
local -a env=(-u GITHUB_EVENT_NAME -u GITHUB_EVENT_PATH -u GITHUB_REPOSITORY -u RUNNER_MODE)
[ -z "$repo" ] || env+=("GITHUB_REPOSITORY=$repo")
[ "$mode" = unset ] || env+=("RUNNER_MODE=$mode")
[ "$event" = - ] || env+=("GITHUB_EVENT_NAME=$event")
[ "$fixture" = - ] || env+=("GITHUB_EVENT_PATH=$fixtures/$fixture")
env "${env[@]}" "$hook" >/dev/null 2>&1 || got=1
if [ "$got" -ne "$want" ]; then
echo "FAIL: mode=$mode $event $fixture exit=$got want=$want" >&2
echo "FAIL: mode=$mode $event $fixture $repo exit=$got want=$want" >&2
fail=1
fi
}
@@ -57,4 +58,17 @@ check 1 release - tag-push.json
check 1 release push -
check 1 release push invalid.txt
for r in terraform-git terraform-vault terraform-artifactapi terraform-authentik terraform-binarylane; do
check 0 infra push push.json "IUCLabs/$r"
check 0 infra pull_request pr-same-repo.json "IUCLabs/$r"
check 1 infra pull_request pr-fork-none.json "IUCLabs/$r"
check 1 infra issue_comment issue-comment.json "IUCLabs/$r"
done
for r in IUCLabs/app IUCLabs/terraform-netbox iuclabs/terraform-git evil/terraform-git IUCLabs/terraform-git-x "IUCLabs/terraform-git "; do
check 1 infra push push.json "$r"
done
check 1 infra push push.json
check 1 infra push - IUCLabs/terraform-vault
check 0 default push push.json IUCLabs/terraform-vault
exit "$fail"