@@ -25,6 +25,7 @@ public KubernetesRawScriptPodCreator(
25
25
IKubernetesPodService podService ,
26
26
IKubernetesPodMonitor podMonitor ,
27
27
IKubernetesSecretService secretService ,
28
+ IKubernetesCustomResourceService customResourceService ,
28
29
IKubernetesPodContainerResolver containerResolver ,
29
30
IApplicationInstanceSelector appInstanceSelector ,
30
31
ISystemLog log ,
@@ -33,31 +34,40 @@ public KubernetesRawScriptPodCreator(
33
34
KubernetesPhysicalFileSystem kubernetesPhysicalFileSystem ,
34
35
IScriptPodLogEncryptionKeyProvider scriptPodLogEncryptionKeyProvider ,
35
36
ScriptIsolationMutex scriptIsolationMutex )
36
- : base ( podService , podMonitor , secretService , containerResolver , appInstanceSelector , log , scriptLogProvider , homeConfiguration , kubernetesPhysicalFileSystem , scriptPodLogEncryptionKeyProvider , scriptIsolationMutex )
37
+ : base ( podService , podMonitor , secretService , customResourceService , containerResolver , appInstanceSelector , log , scriptLogProvider , homeConfiguration , kubernetesPhysicalFileSystem , scriptPodLogEncryptionKeyProvider , scriptIsolationMutex )
37
38
{
38
39
this . containerResolver = containerResolver ;
39
40
}
40
41
41
- protected override async Task < IList < V1Container > > CreateInitContainers ( StartKubernetesScriptCommandV1 command , string podName , string homeDir , string workspacePath , InMemoryTentacleScriptLog tentacleScriptLog )
42
+ protected override async Task < IList < V1Container > > CreateInitContainers ( StartKubernetesScriptCommandV1 command , string podName , string homeDir , string workspacePath , InMemoryTentacleScriptLog tentacleScriptLog , V1Container ? containerSpec )
42
43
{
43
- var container = new V1Container
44
+ V1Container container ;
45
+ if ( containerSpec is not null )
44
46
{
45
- Name = $ "{ podName } -init",
46
- Image = command . PodImageConfiguration ? . Image ?? await containerResolver . GetContainerImageForCluster ( ) ,
47
- ImagePullPolicy = KubernetesConfig . ScriptPodPullPolicy ,
48
- Command = new List < string > { "sh" , "-c" , GetInitExecutionScript ( "/nfs-mount" , homeDir , workspacePath ) } ,
49
- VolumeMounts = new List < V1VolumeMount > { new ( "/nfs-mount" , "init-nfs-volume" ) , new ( homeDir , "tentacle-home" ) } ,
50
- Resources = GetScriptPodResourceRequirements ( tentacleScriptLog )
51
- } ;
47
+ container = containerSpec ;
48
+ }
49
+ else
50
+ {
51
+ container = new V1Container
52
+ {
53
+ Resources = GetScriptPodResourceRequirements ( tentacleScriptLog )
54
+ } ;
55
+ }
56
+
57
+ container . Name = $ "{ podName } -init";
58
+ container . Image = command . PodImageConfiguration ? . Image ?? await containerResolver . GetContainerImageForCluster ( ) ;
59
+ container . ImagePullPolicy = KubernetesConfig . ScriptPodPullPolicy ;
60
+ container . Command = new List < string > { "sh" , "-c" , GetInitExecutionScript ( "/nfs-mount" , homeDir , workspacePath ) } ;
61
+ container . VolumeMounts = new List < V1VolumeMount > { new ( "/nfs-mount" , "init-nfs-volume" ) , new ( homeDir , "tentacle-home" ) } ;
52
62
53
63
return new List < V1Container > { container } ;
54
64
}
55
-
56
- protected override async Task < IList < V1Container > > CreateScriptContainers ( StartKubernetesScriptCommandV1 command , string podName , string scriptName , string homeDir , string workspacePath , string [ ] ? scriptArguments , InMemoryTentacleScriptLog tentacleScriptLog )
65
+
66
+ protected override async Task < IList < V1Container > > CreateScriptContainers ( StartKubernetesScriptCommandV1 command , string podName , string scriptName , string homeDir , string workspacePath , string [ ] ? scriptArguments , InMemoryTentacleScriptLog tentacleScriptLog , ScriptPodTemplateSpec ? spec )
57
67
{
58
68
return new List < V1Container >
59
69
{
60
- await CreateScriptContainer ( command , podName , scriptName , homeDir , workspacePath , scriptArguments , tentacleScriptLog )
70
+ await CreateScriptContainer ( command , podName , scriptName , homeDir , workspacePath , scriptArguments , tentacleScriptLog , spec ? . ScriptContainerSpec )
61
71
} ;
62
72
}
63
73
@@ -82,7 +92,7 @@ protected override IList<V1Volume> CreateVolumes(StartKubernetesScriptCommandV1
82
92
} ;
83
93
}
84
94
85
- string GetInitExecutionScript ( string nfsVolumeDirectory , string homeDir , string workspacePath )
95
+ static string GetInitExecutionScript ( string nfsVolumeDirectory , string homeDir , string workspacePath )
86
96
{
87
97
var nfsWorkspacePath = Path . Combine ( nfsVolumeDirectory , workspacePath ) ;
88
98
var homeWorkspacePath = Path . Combine ( homeDir , workspacePath ) ;
0 commit comments