forked from kubernetes-client/csharp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLogs.cs
executable file
·31 lines (27 loc) · 894 Bytes
/
Logs.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
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());
}
}
}