- Notifications
You must be signed in to change notification settings - Fork 301
/
Copy pathProgram.cs
35 lines (29 loc) · 861 Bytes
/
Program.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
29
30
31
32
33
34
35
usingk8s;
usingk8s.Models;
usingSystem;
usingSystem.Linq;
varconfig=KubernetesClientConfiguration.BuildConfigFromConfigFile();
IKubernetesclient=newKubernetes(config);
Console.WriteLine("Starting Request!");
varpod=client.CoreV1.ListNamespacedPod("default").Items.First();
varname=pod.Metadata.Name;
PrintLabels(pod);
varpatchStr=@"
{
""metadata"": {
""labels"": {
""test"": ""test""
}
}
}";
client.CoreV1.PatchNamespacedPod(newV1Patch(patchStr,V1Patch.PatchType.MergePatch),name,"default");
PrintLabels(client.CoreV1.ReadNamespacedPod(name,"default"));
voidPrintLabels(V1Podpod)
{
Console.WriteLine($"Labels: for {pod.Metadata.Name}");
foreach(var(k,v)inpod.Metadata.Labels)
{
Console.WriteLine($"{k} : {v}");
}
Console.WriteLine("=-=-=-=-=-=-=-=-=-=-=");
}