8.0: API Group + v1.24 (#850)
* swagger 1.24 * trim converter * api group * before moving method * grouped api for client * fix classic build * fix e2e * move all code to v8 * fix vis to * bump ver * fix authtest filename
This commit is contained in:
@@ -13,7 +13,7 @@ namespace attach
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -55,14 +55,14 @@ var request = new V1CertificateSigningRequest
|
||||
}
|
||||
};
|
||||
|
||||
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>
|
||||
@@ -74,4 +74,4 @@ readCert.Status.Conditions = replace;
|
||||
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);
|
||||
|
||||
@@ -31,7 +31,7 @@ namespace customResource
|
||||
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",
|
||||
@@ -66,7 +66,7 @@ namespace customResource
|
||||
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,
|
||||
|
||||
@@ -13,7 +13,7 @@ namespace exec
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ namespace simple
|
||||
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);
|
||||
@@ -30,7 +30,7 @@ namespace simple
|
||||
|
||||
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);
|
||||
|
||||
@@ -12,7 +12,7 @@ namespace logs
|
||||
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!");
|
||||
@@ -21,7 +21,7 @@ namespace logs
|
||||
|
||||
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;
|
||||
|
||||
@@ -10,7 +10,7 @@ namespace @namespace
|
||||
{
|
||||
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);
|
||||
@@ -29,7 +29,7 @@ namespace @namespace
|
||||
await Task.Delay(delayMillis).ConfigureAwait(false);
|
||||
try
|
||||
{
|
||||
await client.ReadNamespaceAsync(name).ConfigureAwait(false);
|
||||
await client.CoreV1.ReadNamespaceAsync(name).ConfigureAwait(false);
|
||||
}
|
||||
catch (AggregateException ex)
|
||||
{
|
||||
@@ -73,12 +73,12 @@ namespace @namespace
|
||||
|
||||
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)
|
||||
{
|
||||
|
||||
@@ -13,7 +13,7 @@ namespace patch
|
||||
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);
|
||||
|
||||
@@ -26,8 +26,8 @@ namespace patch
|
||||
}
|
||||
}";
|
||||
|
||||
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)
|
||||
|
||||
@@ -16,7 +16,7 @@ namespace portforward
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -21,9 +21,9 @@ namespace prom
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -11,7 +11,7 @@ namespace simple
|
||||
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);
|
||||
|
||||
@@ -14,7 +14,7 @@ namespace watch
|
||||
|
||||
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>())
|
||||
{
|
||||
@@ -30,7 +30,7 @@ namespace watch
|
||||
|
||||
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==");
|
||||
|
||||
Reference in New Issue
Block a user