From 4046256472cddc8d2e80e44ddb7ff59b112024ce Mon Sep 17 00:00:00 2001 From: Brendan Burns Date: Mon, 26 Mar 2018 12:49:38 -0700 Subject: [PATCH] Add a logs example. (#117) --- examples/logs/Logs.cs | 28 ++++++++++++++++++++++++++++ examples/logs/logs.csproj | 13 +++++++++++++ 2 files changed, 41 insertions(+) create mode 100755 examples/logs/Logs.cs create mode 100755 examples/logs/logs.csproj diff --git a/examples/logs/Logs.cs b/examples/logs/Logs.cs new file mode 100755 index 0000000..b6bcb96 --- /dev/null +++ b/examples/logs/Logs.cs @@ -0,0 +1,28 @@ +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()); + } + } +} diff --git a/examples/logs/logs.csproj b/examples/logs/logs.csproj new file mode 100755 index 0000000..1ce9471 --- /dev/null +++ b/examples/logs/logs.csproj @@ -0,0 +1,13 @@ + + + + + + + + Exe + netcoreapp2.0 + 7.1 + + +