2025-10-12 06:10:53 +08:00
|
|
|
|
using k8s;
|
2025-09-16 07:40:17 -07:00
|
|
|
|
using k8s.Models;
|
2025-10-12 06:10:53 +08:00
|
|
|
|
using k8s.ClientSets;
|
2025-05-22 15:56:39 +08:00
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
|
|
|
|
|
|
namespace clientset
|
|
|
|
|
|
{
|
|
|
|
|
|
internal class Program
|
|
|
|
|
|
{
|
|
|
|
|
|
private static async Task Main(string[] args)
|
|
|
|
|
|
{
|
|
|
|
|
|
var config = KubernetesClientConfiguration.BuildConfigFromConfigFile();
|
|
|
|
|
|
var client = new Kubernetes(config);
|
|
|
|
|
|
|
2025-10-12 06:10:53 +08:00
|
|
|
|
var clientSet = new ClientSet(client);
|
2025-05-22 15:56:39 +08:00
|
|
|
|
var list = await clientSet.CoreV1.Pod.ListAsync("default").ConfigureAwait(false);
|
|
|
|
|
|
foreach (var item in list)
|
|
|
|
|
|
{
|
|
|
|
|
|
System.Console.WriteLine(item.Metadata.Name);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-09-22 14:18:16 -07:00
|
|
|
|
var pod = await clientSet.CoreV1.Pod.GetAsync("test", "default").ConfigureAwait(false);
|
2025-05-22 15:56:39 +08:00
|
|
|
|
System.Console.WriteLine(pod?.Metadata?.Name);
|
2025-10-12 06:10:53 +08:00
|
|
|
|
|
|
|
|
|
|
var watch = clientSet.CoreV1.Pod.WatchListAsync("default");
|
|
|
|
|
|
await foreach (var (_, item) in watch.ConfigureAwait(false))
|
|
|
|
|
|
{
|
|
|
|
|
|
System.Console.WriteLine(item.Metadata.Name);
|
|
|
|
|
|
}
|
2025-05-22 15:56:39 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2025-10-12 06:10:53 +08:00
|
|
|
|
}
|