From a5b87094110994e8d7f921801866c2e761d15a94 Mon Sep 17 00:00:00 2001 From: Brad Stein Date: Sat, 5 Dec 2026 10:02:39 -0600 Subject: [PATCH] ci: reserve build-node scheduling for eligible pods --- .../core/ci-capacity/kustomization.yaml | 1 + .../core/ci-capacity/reservations.yaml | 173 ++++++++++++++++++ infrastructure/core/ci-capacity/webhooks.yaml | 6 +- .../core/node-prefer-noschedule-cronjob.yaml | 5 + 4 files changed, 182 insertions(+), 3 deletions(-) create mode 100644 infrastructure/core/ci-capacity/reservations.yaml diff --git a/infrastructure/core/ci-capacity/kustomization.yaml b/infrastructure/core/ci-capacity/kustomization.yaml index 08fd9fb6..53c1ab98 100644 --- a/infrastructure/core/ci-capacity/kustomization.yaml +++ b/infrastructure/core/ci-capacity/kustomization.yaml @@ -6,6 +6,7 @@ resources: - certificates.yaml - admission-service.yaml - webhooks.yaml + - reservations.yaml configMapGenerator: - name: ci-placement-code files: diff --git a/infrastructure/core/ci-capacity/reservations.yaml b/infrastructure/core/ci-capacity/reservations.yaml new file mode 100644 index 00000000..97aa8083 --- /dev/null +++ b/infrastructure/core/ci-capacity/reservations.yaml @@ -0,0 +1,173 @@ +# infrastructure/core/ci-capacity/reservations.yaml +# Direct binding lets the reservation coexist with tenants already running here. +apiVersion: apps/v1 +kind: Deployment +metadata: + name: ci-reservation-arm64 +spec: + replicas: 1 + selector: + matchLabels: + app: ci-reservation-arm64 + strategy: + rollingUpdate: + maxSurge: 1 + maxUnavailable: 0 + template: + metadata: + labels: + app: ci-reservation-arm64 + atlas.bstein.dev/ci-arm64-eligible: 'true' + spec: + automountServiceAccountToken: false + nodeName: titan-07 + affinity: + podAntiAffinity: + requiredDuringSchedulingIgnoredDuringExecution: + - namespaceSelector: + matchExpressions: + - key: kubernetes.io/metadata.name + operator: NotIn + values: + - jenkins + - kube-system + labelSelector: + matchExpressions: + - key: atlas.bstein.dev/ci-arm64-eligible + operator: NotIn + values: + - 'true' + topologyKey: kubernetes.io/hostname + - namespaces: + - jenkins + labelSelector: + matchExpressions: + - key: atlas.bstein.dev/ci-arm64-eligible + operator: NotIn + values: + - 'true' + - key: kubernetes.jenkins.io/controller + operator: NotIn + values: + - http___jenkins_jenkins_svc_cluster_local_8080x + topologyKey: kubernetes.io/hostname + - namespaces: + - kube-system + labelSelector: + matchExpressions: + - key: atlas.bstein.dev/ci-arm64-eligible + operator: NotIn + values: + - 'true' + - key: k8s-app + operator: NotIn + values: + - kube-dns + topologyKey: kubernetes.io/hostname + securityContext: + runAsNonRoot: true + runAsUser: 65532 + seccompProfile: + type: RuntimeDefault + containers: + - name: reservation + image: registry.k8s.io/pause@sha256:ee6521f290b2168b6e0935a181d4cff9be1ac3f505666ef0e3c98fae8199917a + resources: + requests: + cpu: 1m + memory: 4Mi + limits: + cpu: 1m + memory: 4Mi + securityContext: + allowPrivilegeEscalation: false + readOnlyRootFilesystem: true + capabilities: + drop: + - ALL +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: ci-reservation-amd64 +spec: + replicas: 1 + selector: + matchLabels: + app: ci-reservation-amd64 + strategy: + rollingUpdate: + maxSurge: 1 + maxUnavailable: 0 + template: + metadata: + labels: + app: ci-reservation-amd64 + atlas.bstein.dev/ci-amd64-eligible: 'true' + spec: + automountServiceAccountToken: false + nodeName: titan-22 + affinity: + podAntiAffinity: + requiredDuringSchedulingIgnoredDuringExecution: + - namespaceSelector: + matchExpressions: + - key: kubernetes.io/metadata.name + operator: NotIn + values: + - jenkins + - kube-system + labelSelector: + matchExpressions: + - key: atlas.bstein.dev/ci-amd64-eligible + operator: NotIn + values: + - 'true' + topologyKey: kubernetes.io/hostname + - namespaces: + - jenkins + labelSelector: + matchExpressions: + - key: atlas.bstein.dev/ci-amd64-eligible + operator: NotIn + values: + - 'true' + - key: kubernetes.jenkins.io/controller + operator: NotIn + values: + - http___jenkins_jenkins_svc_cluster_local_8080x + topologyKey: kubernetes.io/hostname + - namespaces: + - kube-system + labelSelector: + matchExpressions: + - key: atlas.bstein.dev/ci-amd64-eligible + operator: NotIn + values: + - 'true' + - key: k8s-app + operator: NotIn + values: + - kube-dns + topologyKey: kubernetes.io/hostname + securityContext: + runAsNonRoot: true + runAsUser: 65532 + seccompProfile: + type: RuntimeDefault + containers: + - name: reservation + image: registry.k8s.io/pause@sha256:ee6521f290b2168b6e0935a181d4cff9be1ac3f505666ef0e3c98fae8199917a + resources: + requests: + cpu: 1m + memory: 4Mi + limits: + cpu: 1m + memory: 4Mi + securityContext: + allowPrivilegeEscalation: false + readOnlyRootFilesystem: true + capabilities: + drop: + - ALL diff --git a/infrastructure/core/ci-capacity/webhooks.yaml b/infrastructure/core/ci-capacity/webhooks.yaml index 36669899..46935c93 100644 --- a/infrastructure/core/ci-capacity/webhooks.yaml +++ b/infrastructure/core/ci-capacity/webhooks.yaml @@ -11,7 +11,7 @@ webhooks: - v1 sideEffects: None timeoutSeconds: 3 - failurePolicy: Ignore + failurePolicy: Fail clientConfig: service: namespace: kube-system @@ -44,7 +44,7 @@ webhooks: - v1 sideEffects: None timeoutSeconds: 3 - failurePolicy: Ignore + failurePolicy: Fail clientConfig: service: namespace: kube-system @@ -76,7 +76,7 @@ webhooks: - v1 sideEffects: None timeoutSeconds: 3 - failurePolicy: Ignore + failurePolicy: Fail clientConfig: service: namespace: kube-system diff --git a/infrastructure/core/node-prefer-noschedule-cronjob.yaml b/infrastructure/core/node-prefer-noschedule-cronjob.yaml index 621c06a6..8149370f 100644 --- a/infrastructure/core/node-prefer-noschedule-cronjob.yaml +++ b/infrastructure/core/node-prefer-noschedule-cronjob.yaml @@ -61,6 +61,11 @@ spec: clear_worker titan-18 rpi4 clear_worker titan-22 amd64 + # Required inter-pod anti-affinity enforces the reservation. A soft + # taint lets node DaemonSets reach Pod admission on replacement. + k taint node titan-07 atlas.bstein.dev/ci-reserved=arm64:PreferNoSchedule --overwrite=true + k taint node titan-22 atlas.bstein.dev/ci-reserved=amd64:PreferNoSchedule --overwrite=true + if k get node titan-22 >/dev/null 2>&1; then k label node titan-22 \ atlas.bstein.dev/general-compute=last-resort \