Adds methods for streaming container log

This commit is contained in:
benbierens 2023-10-01 08:56:21 +02:00
parent b96751cd2c
commit cec6d787de
No known key found for this signature in database
GPG Key ID: FE44815D96D0A1AA
3 changed files with 21 additions and 0 deletions

View File

@ -36,6 +36,12 @@ namespace Core
return logHandler.DownloadLog();
}
public Stream MonitorLog(RunningContainer container)
{
var workflow = entryPoint.Tools.CreateWorkflow();
return workflow.MonitorContainerLog(container);
}
public string ExecuteContainerCommand(IHasContainer containerSource, string command, params string[] args)
{
return ExecuteContainerCommand(containerSource.Container, command, args);

View File

@ -57,6 +57,12 @@ namespace KubernetesWorkflow
logHandler.Log(stream);
}
public Stream MonitorContainerLog(RunningContainer container)
{
log.Debug();
return client.Run(c => c.ReadNamespacedPodLog(container.Pod.PodInfo.Name, K8sNamespace, container.Recipe.Name, follow: true));
}
public string ExecuteCommand(RunningPod pod, string containerName, string command, params string[] args)
{
var cmdAndArgs = $"{containerName}: {command} ({string.Join(",", args)})";

View File

@ -11,6 +11,7 @@ namespace KubernetesWorkflow
CrashWatcher CreateCrashWatcher(RunningContainer container);
void Stop(RunningContainers runningContainers);
void DownloadContainerLog(RunningContainer container, ILogHandler logHandler, int? tailLines = null);
Stream MonitorContainerLog(RunningContainer container);
string ExecuteCommand(RunningContainer container, string command, params string[] args);
void DeleteNamespace();
void DeleteNamespacesStartingWith(string namespacePrefix);
@ -83,6 +84,14 @@ namespace KubernetesWorkflow
});
}
public Stream MonitorContainerLog(RunningContainer container)
{
return K8s(controller =>
{
return controller.MonitorContainerLog(container);
});
}
public string ExecuteCommand(RunningContainer container, string command, params string[] args)
{
return K8s(controller =>