Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion csharp.settings
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export KUBERNETES_BRANCH=v1.23.0
export KUBERNETES_BRANCH=v1.24.0
export CLIENT_VERSION=0.0.1
export PACKAGE_NAME=k8s
2 changes: 1 addition & 1 deletion examples/attach/Attach.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ private static async Task Main(string[] args)
IKubernetes client = new Kubernetes(config);
Console.WriteLine("Starting Request!");

var list = client.ListNamespacedPod("default");
var list = client.CoreV1.ListNamespacedPod("default");
var pod = list.Items[0];
await AttachToPod(client, pod).ConfigureAwait(false);
}
Expand Down
6 changes: 3 additions & 3 deletions examples/csrApproval/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,14 @@ string GenerateCertificate(string name)
}
};

await client.CreateCertificateSigningRequestAsync(request);
await client.CertificatesV1.CreateCertificateSigningRequestAsync(request);

var serializeOptions = new JsonSerializerOptions
{
PropertyNamingPolicy = JsonNamingPolicy.CamelCase,
WriteIndented = true
};
var readCert = await client.ReadCertificateSigningRequestAsync(name);
var readCert = await client.CertificatesV1.ReadCertificateSigningRequestAsync(name);
var old = JsonSerializer.SerializeToDocument(readCert, serializeOptions);

var replace = new List<V1CertificateSigningRequestCondition>
Expand All @@ -74,4 +74,4 @@ string GenerateCertificate(string name)
var expected = JsonSerializer.SerializeToDocument(readCert, serializeOptions);

var patch = old.CreatePatch(expected);
await client.PatchCertificateSigningRequestApprovalAsync(new V1Patch(patch, V1Patch.PatchType.JsonPatch), name);
await client.CertificatesV1.PatchCertificateSigningRequestApprovalAsync(new V1Patch(patch, V1Patch.PatchType.JsonPatch), name);
4 changes: 2 additions & 2 deletions examples/customResource/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ private static async Task Main(string[] args)
try
{
Console.WriteLine("creating CR {0}", myCr.Metadata.Name);
var response = await client.CreateNamespacedCustomObjectWithHttpMessagesAsync(
var response = await client.CustomObjects.CreateNamespacedCustomObjectWithHttpMessagesAsync(
myCr,
myCRD.Group, myCRD.Version,
myCr.Metadata.NamespaceProperty ?? "default",
Expand Down Expand Up @@ -66,7 +66,7 @@ private static async Task Main(string[] args)
var crPatch = new V1Patch(patch, V1Patch.PatchType.JsonPatch);
try
{
var patchResponse = await client.PatchNamespacedCustomObjectAsync(
var patchResponse = await client.CustomObjects.PatchNamespacedCustomObjectAsync(
crPatch,
myCRD.Group,
myCRD.Version,
Expand Down
2 changes: 1 addition & 1 deletion examples/exec/Exec.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ private static async Task Main(string[] args)
IKubernetes client = new Kubernetes(config);
Console.WriteLine("Starting Request!");

var list = client.ListNamespacedPod("default");
var list = client.CoreV1.ListNamespacedPod("default");
var pod = list.Items[0];
await ExecInPod(client, pod).ConfigureAwait(false);
}
Expand Down
4 changes: 2 additions & 2 deletions examples/labels/PodList.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ private static void Main(string[] args)
IKubernetes client = new Kubernetes(config);
Console.WriteLine("Starting Request!");

var list = client.ListNamespacedService("default");
var list = client.CoreV1.ListNamespacedService("default");
foreach (var item in list.Items)
{
Console.WriteLine("Pods for service: " + item.Metadata.Name);
Expand All @@ -30,7 +30,7 @@ private static void Main(string[] args)

var labelStr = string.Join(",", labels.ToArray());
Console.WriteLine(labelStr);
var podList = client.ListNamespacedPod("default", labelSelector: labelStr);
var podList = client.CoreV1.ListNamespacedPod("default", labelSelector: labelStr);
foreach (var pod in podList.Items)
{
Console.WriteLine(pod.Metadata.Name);
Expand Down
4 changes: 2 additions & 2 deletions examples/logs/Logs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ private static async Task Main(string[] args)
IKubernetes client = new Kubernetes(config);
Console.WriteLine("Starting Request!");

var list = client.ListNamespacedPod("default");
var list = client.CoreV1.ListNamespacedPod("default");
if (list.Items.Count == 0)
{
Console.WriteLine("No pods!");
Expand All @@ -21,7 +21,7 @@ private static async Task Main(string[] args)

var pod = list.Items[0];

var response = await client.ReadNamespacedPodLogWithHttpMessagesAsync(
var response = await client.CoreV1.ReadNamespacedPodLogWithHttpMessagesAsync(
pod.Metadata.Name,
pod.Metadata.NamespaceProperty, follow: true).ConfigureAwait(false);
var stream = response.Body;
Expand Down
8 changes: 4 additions & 4 deletions examples/namespace/NamespaceExample.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ internal class NamespaceExample
{
private static void ListNamespaces(IKubernetes client)
{
var list = client.ListNamespace();
var list = client.CoreV1.ListNamespace();
foreach (var item in list.Items)
{
Console.WriteLine(item.Metadata.Name);
Expand All @@ -29,7 +29,7 @@ private static async Task DeleteAsync(IKubernetes client, string name, int delay
await Task.Delay(delayMillis).ConfigureAwait(false);
try
{
await client.ReadNamespaceAsync(name).ConfigureAwait(false);
await client.CoreV1.ReadNamespaceAsync(name).ConfigureAwait(false);
}
catch (AggregateException ex)
{
Expand Down Expand Up @@ -73,12 +73,12 @@ private static void Main(string[] args)

var ns = new V1Namespace { Metadata = new V1ObjectMeta { Name = "test" } };

var result = client.CreateNamespace(ns);
var result = client.CoreV1.CreateNamespace(ns);
Console.WriteLine(result);

ListNamespaces(client);

var status = client.DeleteNamespace(ns.Metadata.Name, new V1DeleteOptions());
var status = client.CoreV1.DeleteNamespace(ns.Metadata.Name, new V1DeleteOptions());

if (status.HasObject)
{
Expand Down
6 changes: 3 additions & 3 deletions examples/patch/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ private static void Main(string[] args)
IKubernetes client = new Kubernetes(config);
Console.WriteLine("Starting Request!");

var pod = client.ListNamespacedPod("default").Items.First();
var pod = client.CoreV1.ListNamespacedPod("default").Items.First();
var name = pod.Metadata.Name;
PrintLabels(pod);

Expand All @@ -26,8 +26,8 @@ private static void Main(string[] args)
}
}";

client.PatchNamespacedPod(new V1Patch(patchStr, V1Patch.PatchType.MergePatch), name, "default");
PrintLabels(client.ReadNamespacedPod(name, "default"));
client.CoreV1.PatchNamespacedPod(new V1Patch(patchStr, V1Patch.PatchType.MergePatch), name, "default");
PrintLabels(client.CoreV1.ReadNamespacedPod(name, "default"));
}

private static void PrintLabels(V1Pod pod)
Expand Down
2 changes: 1 addition & 1 deletion examples/portforward/PortForward.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ private static async Task Main(string[] args)
IKubernetes client = new Kubernetes(config);
Console.WriteLine("Starting port forward!");

var list = client.ListNamespacedPod("default");
var list = client.CoreV1.ListNamespacedPod("default");
var pod = list.Items[0];
await Forward(client, pod);
}
Expand Down
6 changes: 3 additions & 3 deletions examples/prometheus/Prometheus.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ private static void Main(string[] args)
Console.WriteLine("Making requests!");
while (true)
{
client.ListNamespacedPod("default");
client.ListNode();
client.ListNamespacedDeployment("default");
client.CoreV1.ListNamespacedPod("default");
client.CoreV1.ListNode();
client.AppsV1.ListNamespacedDeployment("default");
Thread.Sleep(1000);
}
}
Expand Down
12 changes: 6 additions & 6 deletions examples/restart/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ double ConvertToUnixTimestamp(DateTime date)

async Task RestartDaemonSetAsync(string name, string @namespace, IKubernetes client)
{
var daemonSet = await client.ReadNamespacedDaemonSetAsync(name, @namespace);
var daemonSet = await client.AppsV1.ReadNamespacedDaemonSetAsync(name, @namespace);
var options = new JsonSerializerOptions { PropertyNamingPolicy = JsonNamingPolicy.CamelCase, WriteIndented = true };
var old = JsonSerializer.SerializeToDocument(daemonSet, options);

Expand All @@ -27,12 +27,12 @@ async Task RestartDaemonSetAsync(string name, string @namespace, IKubernetes cli
var expected = JsonSerializer.SerializeToDocument(daemonSet);

var patch = old.CreatePatch(expected);
await client.PatchNamespacedDaemonSetAsync(new V1Patch(patch, V1Patch.PatchType.JsonPatch), name, @namespace);
await client.AppsV1.PatchNamespacedDaemonSetAsync(new V1Patch(patch, V1Patch.PatchType.JsonPatch), name, @namespace);
}

async Task RestartDeploymentAsync(string name, string @namespace, IKubernetes client)
{
var deployment = await client.ReadNamespacedDeploymentAsync(name, @namespace);
var deployment = await client.AppsV1.ReadNamespacedDeploymentAsync(name, @namespace);
var options = new JsonSerializerOptions { PropertyNamingPolicy = JsonNamingPolicy.CamelCase, WriteIndented = true };
var old = JsonSerializer.SerializeToDocument(deployment, options);

Expand All @@ -46,12 +46,12 @@ async Task RestartDeploymentAsync(string name, string @namespace, IKubernetes cl
var expected = JsonSerializer.SerializeToDocument(deployment);

var patch = old.CreatePatch(expected);
await client.PatchNamespacedDeploymentAsync(new V1Patch(patch, V1Patch.PatchType.JsonPatch), name, @namespace);
await client.AppsV1.PatchNamespacedDeploymentAsync(new V1Patch(patch, V1Patch.PatchType.JsonPatch), name, @namespace);
}

async Task RestartStatefulSetAsync(string name, string @namespace, IKubernetes client)
{
var deployment = await client.ReadNamespacedStatefulSetAsync(name, @namespace);
var deployment = await client.AppsV1.ReadNamespacedStatefulSetAsync(name, @namespace);
var options = new JsonSerializerOptions { PropertyNamingPolicy = JsonNamingPolicy.CamelCase, WriteIndented = true };
var old = JsonSerializer.SerializeToDocument(deployment, options);

Expand All @@ -65,7 +65,7 @@ async Task RestartStatefulSetAsync(string name, string @namespace, IKubernetes c
var expected = JsonSerializer.SerializeToDocument(deployment);

var patch = old.CreatePatch(expected);
await client.PatchNamespacedStatefulSetAsync(new V1Patch(patch, V1Patch.PatchType.JsonPatch), name, @namespace);
await client.AppsV1.PatchNamespacedStatefulSetAsync(new V1Patch(patch, V1Patch.PatchType.JsonPatch), name, @namespace);
}

var config = KubernetesClientConfiguration.BuildConfigFromConfigFile();
Expand Down
2 changes: 1 addition & 1 deletion examples/simple/PodList.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ private static void Main(string[] args)
IKubernetes client = new Kubernetes(config);
Console.WriteLine("Starting Request!");

var list = client.ListNamespacedPod("default");
var list = client.CoreV1.ListNamespacedPod("default");
foreach (var item in list.Items)
{
Console.WriteLine(item.Metadata.Name);
Expand Down
4 changes: 2 additions & 2 deletions examples/watch/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ private async static Task Main(string[] args)

IKubernetes client = new Kubernetes(config);

var podlistResp = client.ListNamespacedPodWithHttpMessagesAsync("default", watch: true);
var podlistResp = client.CoreV1.ListNamespacedPodWithHttpMessagesAsync("default", watch: true);
// C# 8 required https://docs.microsoft.com/en-us/archive/msdn-magazine/2019/november/csharp-iterating-with-async-enumerables-in-csharp-8
await foreach (var (type, item) in podlistResp.WatchAsync<V1Pod, V1PodList>())
{
Expand All @@ -30,7 +30,7 @@ private async static Task Main(string[] args)

private static void WatchUsingCallback(IKubernetes client)
{
var podlistResp = client.ListNamespacedPodWithHttpMessagesAsync("default", watch: true);
var podlistResp = client.CoreV1.ListNamespacedPodWithHttpMessagesAsync("default", watch: true);
using (podlistResp.Watch<V1Pod, V1PodList>((type, item) =>
{
Console.WriteLine("==on watch event==");
Expand Down
Loading