diff --git a/source/Octopus.Tentacle/Kubernetes/Scripts/RunningKubernetesPod.cs b/source/Octopus.Tentacle/Kubernetes/Scripts/RunningKubernetesPod.cs index 8a9c4fcd3..c0cef4564 100644 --- a/source/Octopus.Tentacle/Kubernetes/Scripts/RunningKubernetesPod.cs +++ b/source/Octopus.Tentacle/Kubernetes/Scripts/RunningKubernetesPod.cs @@ -37,6 +37,14 @@ public delegate RunningKubernetesPod Factory( using var reader = new StreamReader(stream!, Encoding.UTF8); return await reader.ReadToEndAsync(); }); + + static readonly AsyncLazy BootstrapRunnerExe = new(async () => + { + using var stream = typeof(RunningKubernetesPod).Assembly.GetManifestResourceStream("Octopus.Tentacle.Kubernetes.bootstrap"); + var mem = new MemoryStream(); + await stream!.CopyToAsync(mem); + return mem.ToArray(); + }); readonly IScriptWorkspace workspace; readonly ScriptTicket scriptTicket; @@ -313,6 +321,7 @@ async Task CreatePod(IScriptLogWriter writer, string? imagePullSecretName, Cance //write the bootstrap runner script to the workspace workspace.WriteFile("bootstrapRunner.sh", await BootstrapRunnerScript.Task); + workspace.WriteAllBytes("bootstrap", await BootstrapRunnerExe.Task); var scriptName = Path.GetFileName(workspace.BootstrapScriptFilePath); @@ -342,8 +351,8 @@ async Task CreatePod(IScriptLogWriter writer, string? imagePullSecretName, Cance Command = new List { "bash" }, Args = new List { - $"/octopus/Work/{scriptTicket.TaskId}/bootstrapRunner.sh", - $"/octopus/Work/{scriptTicket.TaskId}", + $"/octopus/Work/{scriptTicket.TaskId}/bootstrap", + //$"/octopus/Work/{scriptTicket.TaskId}", $"/octopus/Work/{scriptTicket.TaskId}/{scriptName}" }.Concat(workspace.ScriptArguments ?? Array.Empty()) .ToList(), diff --git a/source/Octopus.Tentacle/Kubernetes/bootstrap b/source/Octopus.Tentacle/Kubernetes/bootstrap new file mode 100755 index 000000000..2790ef906 Binary files /dev/null and b/source/Octopus.Tentacle/Kubernetes/bootstrap differ diff --git a/source/Octopus.Tentacle/Octopus.Tentacle.csproj b/source/Octopus.Tentacle/Octopus.Tentacle.csproj index fa874d36f..68e522d1c 100644 --- a/source/Octopus.Tentacle/Octopus.Tentacle.csproj +++ b/source/Octopus.Tentacle/Octopus.Tentacle.csproj @@ -128,5 +128,9 @@ Always + + + Always + diff --git a/source/Octopus.Tentacle/Scripts/IScriptWorkspace.cs b/source/Octopus.Tentacle/Scripts/IScriptWorkspace.cs index 68cf45c6d..22560851b 100644 --- a/source/Octopus.Tentacle/Scripts/IScriptWorkspace.cs +++ b/source/Octopus.Tentacle/Scripts/IScriptWorkspace.cs @@ -22,5 +22,6 @@ public interface IScriptWorkspace string LogFilePath { get; } void WriteFile(string filename, string contents); Stream OpenFileStreamForReading(string filename); + void WriteAllBytes(string filename, byte[] contents); } } \ No newline at end of file diff --git a/source/Octopus.Tentacle/Scripts/ScriptWorkspace.cs b/source/Octopus.Tentacle/Scripts/ScriptWorkspace.cs index d5b7902a3..ee39ad29b 100644 --- a/source/Octopus.Tentacle/Scripts/ScriptWorkspace.cs +++ b/source/Octopus.Tentacle/Scripts/ScriptWorkspace.cs @@ -35,6 +35,7 @@ public ScriptWorkspace( const string LogFileName = "Output.log"; public string LogFilePath => GetLogFilePath(WorkingDirectory); public void WriteFile(string filename, string contents) => FileSystem.OverwriteFile(ResolvePath(filename), contents); + public void WriteAllBytes(string filename, byte[] contents) => FileSystem.WriteAllBytes(ResolvePath(filename), contents); public Stream OpenFileStreamForReading(string filename) => FileSystem.OpenFile(ResolvePath(filename), FileMode.Open, FileAccess.Read, FileShare.ReadWrite);