← Back to Pull requests

feat(chart): add webhook PDB and anti-affinity for replicas > 1 #32

Closed
unknown closed this pull request without merging on Sep 28, 2026 04:21 UTC
View on GitHub
unknown unknown commented on Sep 26, 2026 14:06 UTC
Author

What type of PR is this?
Enhancement (chart only, no Go code change).

What this PR does / why we need it:
The admission webhook shipped as a single replica with no PodDisruptionBudget, so it is briefly absent during a node drain or a chart upgrade, and with the default failurePolicy: Ignore a pod requesting GPU sharing in that window is admitted without libvgpu injection, i.e. without vGPU memory isolation. KAI's admission webhook has had a PDB since v0.16.0 and hardcodes failurePolicy: Fail, and HAMi's scheduler got one in HAMi PR #2773.

  • New chart/kai-resource-isolator/templates/webhook-pdb.yaml: a policy/v1 PodDisruptionBudget gated on gt (int .Values.webhook.replicaCount) 1, reusing the Deployment's app.kubernetes.io/component: kai-webhook plus selectorLabels selector. minAvailable comes from values, maxUnavailable takes precedence when the key is present (hasKey), the same shape as charts/hami/templates/scheduler/pdb.yaml.

  • webhook.podDisruptionBudget: {minAvailable: 1} in values, maxUnavailable left commented so minAvailable applies unless an operator opts in.

  • A preferredDuringSchedulingIgnoredDuringExecution pod anti-affinity (weight 100, topologyKey: kubernetes.io/hostname, component label kai-webhook) on the webhook Deployment, gated on the same replicaCount > 1 condition, matching HAMi PR #1934.

  • A values comment on webhook.replicaCount explaining that production should run at least 2 replicas with webhook.podDisruptionBudget, and why both render only when replicaCount > 1.
  • Nothing else changes: no new selector or timeout knobs, no leader election, no probe changes, no NOTES.txt or README.md changes, no renames of the Deployment, Service or MutatingWebhookConfiguration.

    Which issue(s) this PR fixes:
    Fixes #28

    Special notes for your reviewer:
    The failurePolicy default stays Ignore with no values comment: Ignore is fail-open, admitting GPU-share pods without libvgpu injection while the webhook is unreachable, and recommending Fail for production, which KAI hardcodes on its pod mutating and validating webhooks (pkg/operator/operands/admission/resources.go @v0.18.0), is a separate change with its own discussion.

    Gating on replicaCount > 1 is required, not stylistic: with a single replica a PodDisruptionBudget would block all voluntary node drains, which is why the HAMi scheduler PDB is gated on replicas > 1 too (HAMi adds a leaderElect condition, with no equivalent here). The anti-affinity is preferred, never required: HAMi's first attempt with required deadlocked rolling updates on single-node clusters (HAMi issue #1933, fixed by HAMi PR #1934) and would break helm upgrade here.

    Object names are unchanged on purpose: the MutatingWebhookConfiguration kai-resource-isolator-mutating and the Deployment and Service (kai-resource-isolator-webhook for the release name KAI uses) are referenced by KAI's hack/hami/deploy_isolator.sh and the KAI e2e. The new PDB reuses the kai-resource-isolator.webhook.fullname helper, so it takes the Deployment's name without colliding, being a different kind. This branch also merges cleanly with the gpuShareResources removal branch in either order (verified in a throwaway clone; an earlier revision's 4-line failurePolicy comment in values.yaml was the only conflict).

    Precedents: KAI PR #1490 (admission PDB, released in KAI v0.16.0, values admission.podDisruptionBudget, created only when replicas > 1), HAMi PR #2773, HAMi PR #1934.

    Verified on a single-node kind v0.32 cluster on macOS arm64 (Kubernetes v1.36.1, helm v4.2.3, KUBECONFIG=/tmp/kri-pr04.kubeconfig, no GPU hardware, GPU-less kind reproduction): helm lint and go test ./... pass all 5 packages; the default helm template emits 0 PodDisruptionBudget and 0 podAntiAffinity and its diff against the same render from main is empty, so the default install is byte-identical; --set webhook.replicaCount=2 renders the PDB with minAvailable: 1 plus the anti-affinity, and webhook.podDisruptionBudget.maxUnavailable=1 renders maxUnavailable: 1 as the only difference; and on kind helm install isolator --set image.tag=v1.1.0 --set webhook.replicaCount=2 --wait completed the certgen hook jobs, the Deployment shows 2/2, the PDB shows MIN AVAILABLE 1 / ALLOWED DISRUPTIONS 1, and the live pod spec carries the anti-affinity.

    kubectl drain kri-pr04-control-plane --ignore-daemonsets --delete-emptydir-data --timeout=45s on the single node made the cordoned Deployment create a second, unschedulable replica, so the PDB reported currentHealthy 1 / desiredHealthy 1 / disruptionsAllowed 0 and refused every eviction of the running replica with Cannot evict pod as it would violate the pod's disruption budget until the timeout; no webhook pod was evicted (only two coredns pods) and after uncordon the Deployment returned to 2/2, so nothing wedged. Both replicas land on the one node, so cross-node spread of the anti-affinity could not be exercised. The kind cluster and temporary kubeconfig were deleted afterwards and ~/.kube/config was never touched.

    Does this PR introduce a user-facing change?:
    Yes, but only when webhook.replicaCount > 1: a PodDisruptionBudget and a preferred pod anti-affinity are then created for the webhook. At the default replicaCount: 1 the rendered output is byte-identical to main, so single-replica installs and upgrades are unaffected. No default value changed.

    AI Disclosure:
    AI assistance was used to review repository context and help draft this change and its description. All changes were manually reviewed, verified locally, and submitted by the author.

    Diff: 650 lines (+487 / -163) across 8 files Reviewer: archlitchi Review duration: 2295m
    All Vouch review confidence checks passed
    Residual risk 0.21 = Change Risk (0.52) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.52 · 650 lines diff across 8 files
    0.52
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    60%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.388
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #32"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 52% (MEDIUM) · Higher = larger blast radius
    52%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 60.5% · Lower = rushed or shallow review
    60.5%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 20.5% · Safe to merge
    20.5%