Add a logs example. (#117)
This commit is contained in:
28
examples/logs/Logs.cs
Executable file
28
examples/logs/Logs.cs
Executable 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
13
examples/logs/logs.csproj
Executable 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>
|
||||
Reference in New Issue
Block a user