* feat: enhance Kubernetes client with watch functionality * refactor: simplify watch event handling in Kubernetes client example * refactor: update Kubernetes watch functionality to use new event handling methods and add async enumerable support * fix * fix * fix: correct usage of Pod list items in client example and update Obsolete attribute formatting * fix: update client example to use correct Pod list method and improve Obsolete attribute formatting * refactor: enhance type resolution for list items in TypeHelper by adding TryGetItemTypeFromSchema method * feat: mark Watch methods as obsolete to prepare for future deprecation * fix * refactor: update WatcherExt class to internal and remove obsolete attributes; improve example method signature in Program.cs * refactor: change WatcherExt class from internal to public and mark methods as obsolete for future deprecation
32 lines
1.0 KiB
C#
32 lines
1.0 KiB
C#
using k8s;
|
||
using k8s.Models;
|
||
using k8s.ClientSets;
|
||
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);
|
||
|
||
var clientSet = new ClientSet(client);
|
||
var list = await clientSet.CoreV1.Pod.ListAsync("default").ConfigureAwait(false);
|
||
foreach (var item in list)
|
||
{
|
||
System.Console.WriteLine(item.Metadata.Name);
|
||
}
|
||
|
||
var pod = await clientSet.CoreV1.Pod.GetAsync("test", "default").ConfigureAwait(false);
|
||
System.Console.WriteLine(pod?.Metadata?.Name);
|
||
|
||
var watch = clientSet.CoreV1.Pod.WatchListAsync("default");
|
||
await foreach (var (_, item) in watch.ConfigureAwait(false))
|
||
{
|
||
System.Console.WriteLine(item.Metadata.Name);
|
||
}
|
||
}
|
||
}
|
||
} |