Skip to content

Commit b946b9f

Browse files
authored
Add optional env var and label to disable image pre-pulls (#1667)
* add env var to disable pre-pulls * add label to disable pre-pulls on specific nodes
1 parent 99d3815 commit b946b9f

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

apps/kubernetes-provider/src/index.ts

+23
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ const UPTIME_MAX_PENDING_ERRORS = Number(process.env.UPTIME_MAX_PENDING_ERRORS |
3737
const POD_EPHEMERAL_STORAGE_SIZE_LIMIT = process.env.POD_EPHEMERAL_STORAGE_SIZE_LIMIT || "10Gi";
3838
const POD_EPHEMERAL_STORAGE_SIZE_REQUEST = process.env.POD_EPHEMERAL_STORAGE_SIZE_REQUEST || "2Gi";
3939

40+
const PRE_PULL_DISABLED = process.env.PRE_PULL_DISABLED === "true";
41+
4042
const logger = new SimpleLogger(`[${NODE_NAME}]`);
4143
logger.log(`running in ${RUNTIME_ENV} mode`);
4244

@@ -301,6 +303,11 @@ class KubernetesTaskOperations implements TaskOperations {
301303
}
302304

303305
async prePullDeployment(opts: TaskOperationsPrePullDeploymentOptions) {
306+
if (PRE_PULL_DISABLED) {
307+
logger.debug("Pre-pull is disabled, skipping.", { opts });
308+
return;
309+
}
310+
304311
const metaName = this.#getPrePullContainerName(opts.shortCode);
305312

306313
const metaLabels = {
@@ -332,6 +339,22 @@ class KubernetesTaskOperations implements TaskOperations {
332339
spec: {
333340
...this.#defaultPodSpec,
334341
restartPolicy: "Always",
342+
affinity: {
343+
nodeAffinity: {
344+
requiredDuringSchedulingIgnoredDuringExecution: {
345+
nodeSelectorTerms: [
346+
{
347+
matchExpressions: [
348+
{
349+
key: "trigger.dev/pre-pull-disabled",
350+
operator: "DoesNotExist",
351+
},
352+
],
353+
},
354+
],
355+
},
356+
},
357+
},
335358
initContainers: [
336359
{
337360
name: "prepull",

0 commit comments

Comments
 (0)