From 4da17abe2422e30c4194fb43c4fd89a8f787a236 Mon Sep 17 00:00:00 2001 From: Vigneshraj Sekar Babu Date: Tue, 27 Oct 2026 15:52:29 -0700 Subject: [PATCH] fix(native-helm): mark deploy job pods safe-to-evict false --- .../kubernetes/__tests__/jobFactory.test.ts | 35 +++++++++++++++++++ src/server/lib/kubernetes/jobFactory.ts | 3 ++ 2 files changed, 38 insertions(+) create mode 100644 src/server/lib/kubernetes/__tests__/jobFactory.test.ts diff --git a/src/server/lib/kubernetes/__tests__/jobFactory.test.ts b/src/server/lib/kubernetes/__tests__/jobFactory.test.ts new file mode 100644 index 00000000..87ec0a70 --- /dev/null +++ b/src/server/lib/kubernetes/__tests__/jobFactory.test.ts @@ -0,0 +1,35 @@ +/** + * Copyright 2025 GoodRx, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { createHelmJob } from '../jobFactory'; + +describe('createHelmJob', () => { + it('marks the deploy pod as not safe to evict by the cluster autoscaler', () => { + const job = createHelmJob({ + name: 'helm-deploy-api', + namespace: 'preview-123', + serviceAccount: 'helm-runner', + serviceName: 'api', + buildUUID: 'build-123', + isStatic: false, + containers: [{ name: 'helm', image: 'alpine/helm:3.15.4' }], + }); + + expect(job.spec?.template.metadata?.annotations).toEqual({ + 'cluster-autoscaler.kubernetes.io/safe-to-evict': 'false', + }); + }); +}); diff --git a/src/server/lib/kubernetes/jobFactory.ts b/src/server/lib/kubernetes/jobFactory.ts index f7f124b0..4046d862 100644 --- a/src/server/lib/kubernetes/jobFactory.ts +++ b/src/server/lib/kubernetes/jobFactory.ts @@ -243,6 +243,9 @@ export function createHelmJob(config: HelmJobConfig): V1Job { timeout, ttl, labels, + podAnnotations: { + 'cluster-autoscaler.kubernetes.io/safe-to-evict': 'false', + }, initContainers, containers, volumes: config.volumes || [{ name: 'helm-workspace', emptyDir: {} }],