Add a logs example. (#117)

This commit is contained in:
Brendan Burns
2018-03-26 12:49:38 -07:00
committed by GitHub
parent d0c17ee2d5
commit 4046256472
2 changed files with 41 additions and 0 deletions

28
examples/logs/Logs.cs Executable file
View File

@@ -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());
}
}
}

13
examples/logs/logs.csproj Executable file
View File

@@ -0,0 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk">
<ItemGroup>
<ProjectReference Include="..\..\src\KubernetesClient.csproj" />
</ItemGroup>
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.0</TargetFramework>
<LangVersion>7.1</LangVersion>
</PropertyGroup>
</Project>