@@ -17,6 +17,7 @@ import {
17
17
import { PodCleaner } from "./podCleaner" ;
18
18
import { TaskMonitor } from "./taskMonitor" ;
19
19
import { UptimeHeartbeat } from "./uptimeHeartbeat" ;
20
+ import { assertExhaustive } from "@trigger.dev/core" ;
20
21
21
22
const RUNTIME_ENV = process . env . KUBERNETES_PORT ? "kubernetes" : "local" ;
22
23
const NODE_NAME = process . env . NODE_NAME || "local" ;
@@ -42,6 +43,9 @@ const PRE_PULL_DISABLED = process.env.PRE_PULL_DISABLED === "true";
42
43
const ADDITIONAL_PULL_SECRETS = process . env . ADDITIONAL_PULL_SECRETS ;
43
44
const PAUSE_IMAGE = process . env . PAUSE_IMAGE || "registry.k8s.io/pause:3.9" ;
44
45
const BUSYBOX_IMAGE = process . env . BUSYBOX_IMAGE || "registry.digitalocean.com/trigger/busybox" ;
46
+ const DEPLOYMENT_IMAGE_PREFIX = process . env . DEPLOYMENT_IMAGE_PREFIX ;
47
+ const RESTORE_IMAGE_PREFIX = process . env . RESTORE_IMAGE_PREFIX ;
48
+ const UTILITY_IMAGE_PREFIX = process . env . UTILITY_IMAGE_PREFIX ;
45
49
46
50
const logger = new SimpleLogger ( `[${ NODE_NAME } ]` ) ;
47
51
logger . log ( `running in ${ RUNTIME_ENV } mode` ) ;
@@ -107,7 +111,7 @@ class KubernetesTaskOperations implements TaskOperations {
107
111
containers : [
108
112
{
109
113
name : this . #getIndexContainerName( opts . shortCode ) ,
110
- image : opts . imageRef ,
114
+ image : getImageRef ( "deployment" , opts . imageRef ) ,
111
115
ports : [
112
116
{
113
117
containerPort : 8000 ,
@@ -174,7 +178,7 @@ class KubernetesTaskOperations implements TaskOperations {
174
178
containers : [
175
179
{
176
180
name : containerName ,
177
- image : opts . image ,
181
+ image : getImageRef ( "deployment" , opts . image ) ,
178
182
ports : [
179
183
{
180
184
containerPort : 8000 ,
@@ -235,12 +239,12 @@ class KubernetesTaskOperations implements TaskOperations {
235
239
initContainers : [
236
240
{
237
241
name : "pull-base-image" ,
238
- image : opts . imageRef ,
242
+ image : getImageRef ( "deployment" , opts . imageRef ) ,
239
243
command : [ "sleep" , "0" ] ,
240
244
} ,
241
245
{
242
246
name : "populate-taskinfo" ,
243
- image : BUSYBOX_IMAGE ,
247
+ image : getImageRef ( "utility" , BUSYBOX_IMAGE ) ,
244
248
imagePullPolicy : "IfNotPresent" ,
245
249
command : [ "/bin/sh" , "-c" ] ,
246
250
args : [ "printenv COORDINATOR_HOST | tee /etc/taskinfo/coordinator-host" ] ,
@@ -256,7 +260,7 @@ class KubernetesTaskOperations implements TaskOperations {
256
260
containers : [
257
261
{
258
262
name : this . #getRunContainerName( opts . runId ) ,
259
- image : opts . checkpointRef ,
263
+ image : getImageRef ( "restore" , opts . checkpointRef ) ,
260
264
ports : [
261
265
{
262
266
containerPort : 8000 ,
@@ -362,7 +366,7 @@ class KubernetesTaskOperations implements TaskOperations {
362
366
initContainers : [
363
367
{
364
368
name : "prepull" ,
365
- image : opts . imageRef ,
369
+ image : getImageRef ( "deployment" , opts . imageRef ) ,
366
370
command : [ "/usr/bin/true" ] ,
367
371
resources : {
368
372
limits : {
@@ -376,7 +380,7 @@ class KubernetesTaskOperations implements TaskOperations {
376
380
containers : [
377
381
{
378
382
name : "pause" ,
379
- image : PAUSE_IMAGE ,
383
+ image : getImageRef ( "utility" , PAUSE_IMAGE ) ,
380
384
resources : {
381
385
limits : {
382
386
cpu : "1m" ,
@@ -682,6 +686,26 @@ class KubernetesTaskOperations implements TaskOperations {
682
686
}
683
687
}
684
688
689
+ type ImageType = "deployment" | "restore" | "utility" ;
690
+
691
+ function getImagePrefix ( type : ImageType ) {
692
+ switch ( type ) {
693
+ case "deployment" :
694
+ return DEPLOYMENT_IMAGE_PREFIX ;
695
+ case "restore" :
696
+ return RESTORE_IMAGE_PREFIX ;
697
+ case "utility" :
698
+ return UTILITY_IMAGE_PREFIX ;
699
+ default :
700
+ assertExhaustive ( type ) ;
701
+ }
702
+ }
703
+
704
+ function getImageRef ( type : ImageType , ref : string ) {
705
+ const prefix = getImagePrefix ( type ) ;
706
+ return prefix ? `${ prefix } /${ ref } ` : ref ;
707
+ }
708
+
685
709
const provider = new ProviderShell ( {
686
710
tasks : new KubernetesTaskOperations ( {
687
711
namespace : KUBERNETES_NAMESPACE ,
0 commit comments