Files
csharp/examples/logs/Logs.cs
Boshi Lian ae79be6665 Clean up warnings in examples (#1628)
* Refactor examples to streamline code structure and improve readability

* Update LangVersion to 13.0 for improved compatibility
2025-04-29 16:55:55 -07:00

22 lines
631 B
C#
Executable File

using k8s;
using System;
var config = KubernetesClientConfiguration.BuildConfigFromConfigFile();
IKubernetes client = new Kubernetes(config);
Console.WriteLine("Starting Request!");
var list = client.CoreV1.ListNamespacedPod("default");
if (list.Items.Count == 0)
{
Console.WriteLine("No pods!");
return;
}
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);
var stream = response.Body;
stream.CopyTo(Console.OpenStandardOutput());