Files
csharp/examples/logs/Logs.cs
2018-03-26 12:49:38 -07:00

29 lines
865 B
C#
Executable File

using System;
using System.IO;
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.ListNamespacedPod("default");
if (list.Items.Count == 0) {
Console.WriteLine("No pods!");
return;
}
var pod = list.Items[0];
var response = await client.ReadNamespacedPodLogWithHttpMessagesAsync(pod.Metadata.Name, pod.Metadata.NamespaceProperty, follow: true);
var stream = response.Body;
stream.CopyTo(Console.OpenStandardOutput());
}
}
}