Files
csharp/examples/logs/Logs.cs

32 lines
970 B
C#
Raw Normal View History

2018-03-26 12:49:38 -07:00
using System;
using System.Threading.Tasks;
using k8s;
namespace logs
{
internal class Logs
{
private static async Task Main(string[] args)
{
var config = KubernetesClientConfiguration.BuildConfigFromConfigFile();
IKubernetes client = new Kubernetes(config);
Console.WriteLine("Starting Request!");
var list = client.CoreV1.ListNamespacedPod("default");
2020-04-22 12:15:45 -07:00
if (list.Items.Count == 0)
{
2018-03-26 12:49:38 -07:00
Console.WriteLine("No pods!");
return;
}
2018-03-26 12:49:38 -07:00
var pod = list.Items[0];
var response = await client.CoreV1.ReadNamespacedPodLogWithHttpMessagesAsync(
pod.Metadata.Name,
pod.Metadata.NamespaceProperty, container: pod.Spec.Containers[0].Name, follow: true).ConfigureAwait(false);
2018-03-26 12:49:38 -07:00
var stream = response.Body;
stream.CopyTo(Console.OpenStandardOutput());
}
}
}