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!");
|
|
|
|
|
|
2022-05-07 13:05:17 -07:00
|
|
|
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;
|
|
|
|
|
}
|
2020-04-23 11:40:06 -07:00
|
|
|
|
2018-03-26 12:49:38 -07:00
|
|
|
var pod = list.Items[0];
|
|
|
|
|
|
2022-05-07 13:05:17 -07:00
|
|
|
var response = await client.CoreV1.ReadNamespacedPodLogWithHttpMessagesAsync(
|
2020-11-01 12:24:51 -08:00
|
|
|
pod.Metadata.Name,
|
2022-06-22 19:57:43 -07:00
|
|
|
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());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|