forked from kubernetes-client/csharp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPodList.cs
executable file
·28 lines (27 loc) · 899 Bytes
/
PodList.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
namespace simple
{
using System;
using System.IO;
using k8s;
class PodList
{
static void Main(string[] args)
{
var k8sClientConfig = KubernetesClientConfiguration.defaultConfiguration();
if (k8sClientConfig.CurrentContext == null) {
Console.WriteLine("No current context");
return;
}
IKubernetes client = new Kubernetes(k8sClientConfig);
Console.WriteLine("Starting Request!");
var listTask = client.ListNamespacedPodWithHttpMessagesAsync("default").Result;
var list = listTask.Body;
foreach (var item in list.Items) {
Console.WriteLine(item.Metadata.Name);
}
if (list.Items.Count == 0) {
Console.WriteLine("Empty!");
}
}
}
}