diff --git a/src/HealthChecks.Kubernetes/HealthChecks.Kubernetes.csproj b/src/HealthChecks.Kubernetes/HealthChecks.Kubernetes.csproj index 830bb76aaf..0328a4cabd 100644 --- a/src/HealthChecks.Kubernetes/HealthChecks.Kubernetes.csproj +++ b/src/HealthChecks.Kubernetes/HealthChecks.Kubernetes.csproj @@ -1,14 +1,14 @@ - netstandard2.0 + net6;net7 $(PackageTags);Kubernetes;k8s;Cluster HealthChecks.HealthChecks is the health check package for Kubernetes clusters. $(HealthCheckKubernetes) - + diff --git a/src/HealthChecks.Kubernetes/KubernetesChecksExecutor.cs b/src/HealthChecks.Kubernetes/KubernetesChecksExecutor.cs index 7e56ef61de..9e2b610017 100644 --- a/src/HealthChecks.Kubernetes/KubernetesChecksExecutor.cs +++ b/src/HealthChecks.Kubernetes/KubernetesChecksExecutor.cs @@ -32,7 +32,7 @@ public KubernetesChecksExecutor(k8s.Kubernetes client) try { - var result = await _client.ReadNamespacedDeploymentStatusWithHttpMessagesAsync(resourceCheck.Name, + var result = await _client.AppsV1.ReadNamespacedDeploymentStatusWithHttpMessagesAsync(resourceCheck.Name, resourceCheck.Namespace, cancellationToken: cancellationToken).ConfigureAwait(false); tsc.SetResult((resourceCheck.Check(result.Body), resourceCheck.Name)); @@ -51,7 +51,7 @@ public KubernetesChecksExecutor(k8s.Kubernetes client) var tsc = new TaskCompletionSource<(bool, string)>(); try { - var result = await _client.ReadNamespacedPodStatusWithHttpMessagesAsync(resourceCheck.Name, + var result = await _client.CoreV1.ReadNamespacedPodStatusWithHttpMessagesAsync(resourceCheck.Name, resourceCheck.Namespace, cancellationToken: cancellationToken).ConfigureAwait(false); tsc.SetResult((resourceCheck.Check(result.Body), resourceCheck.Name)); @@ -70,7 +70,7 @@ public KubernetesChecksExecutor(k8s.Kubernetes client) var tsc = new TaskCompletionSource<(bool, string)>(); try { - var result = await _client.ReadNamespacedServiceStatusWithHttpMessagesAsync(resourceCheck.Name, + var result = await _client.CoreV1.ReadNamespacedServiceStatusWithHttpMessagesAsync(resourceCheck.Name, resourceCheck.Namespace, cancellationToken: cancellationToken).ConfigureAwait(false); tsc.SetResult((resourceCheck.Check(result.Body), resourceCheck.Name)); diff --git a/src/HealthChecks.UI.K8s.Operator/Extensions/IKubernetesExtensions.cs b/src/HealthChecks.UI.K8s.Operator/Extensions/IKubernetesExtensions.cs index 84e298c857..35cde0f59a 100644 --- a/src/HealthChecks.UI.K8s.Operator/Extensions/IKubernetesExtensions.cs +++ b/src/HealthChecks.UI.K8s.Operator/Extensions/IKubernetesExtensions.cs @@ -6,25 +6,25 @@ public static class IKubernetesExtensions { public static async Task ListNamespacedOwnedDeploymentAsync(this IKubernetes client, string k8sNamespace, string ownerUniqueId) { - var services = await client.ListNamespacedDeploymentAsync(k8sNamespace); + var services = await client.AppsV1.ListNamespacedDeploymentAsync(k8sNamespace); return services.Items.FirstOrDefault(i => i.Metadata.OwnerReferences?.Any(or => or.Uid == ownerUniqueId) ?? false); } public static async Task ListNamespacedOwnedServiceAsync(this IKubernetes client, string k8sNamespace, string ownerUniqueId) { - var services = await client.ListNamespacedServiceAsync(k8sNamespace); + var services = await client.CoreV1.ListNamespacedServiceAsync(k8sNamespace); return services.Items.FirstOrDefault(i => i.Metadata.OwnerReferences?.Any(or => or.Uid == ownerUniqueId) ?? false); } public static async Task ListNamespacedOwnedSecretAsync(this IKubernetes client, string k8sNamespace, string ownerUniqueId) { - var services = await client.ListNamespacedSecretAsync(k8sNamespace); + var services = await client.CoreV1.ListNamespacedSecretAsync(k8sNamespace); return services.Items.FirstOrDefault(i => i.Metadata.OwnerReferences?.Any(or => or.Uid == ownerUniqueId) ?? false); } public static async Task ListNamespacedOwnedConfigMapAsync(this IKubernetes client, string k8sNamespace, string ownerUniqueId) { - var configMaps = await client.ListNamespacedConfigMapAsync(k8sNamespace); + var configMaps = await client.CoreV1.ListNamespacedConfigMapAsync(k8sNamespace); return configMaps.Items.FirstOrDefault(i => i.Metadata.OwnerReferences?.Any(or => or.Uid == ownerUniqueId) ?? false); } } diff --git a/src/HealthChecks.UI.K8s.Operator/Handlers/ConfigMapHandler.cs b/src/HealthChecks.UI.K8s.Operator/Handlers/ConfigMapHandler.cs index ac88da740b..471d6c276b 100644 --- a/src/HealthChecks.UI.K8s.Operator/Handlers/ConfigMapHandler.cs +++ b/src/HealthChecks.UI.K8s.Operator/Handlers/ConfigMapHandler.cs @@ -31,7 +31,7 @@ public ConfigMaphandler(IKubernetes client, ILogger logger) try { var configMapResource = Build(resource); - configMap = await _client.CreateNamespacedConfigMapAsync(configMapResource, resource.Metadata.NamespaceProperty); + configMap = await _client.CoreV1.CreateNamespacedConfigMapAsync(configMapResource, resource.Metadata.NamespaceProperty); _logger.LogInformation("Config Map {name} has been created", configMap.Metadata.Name); } catch (Exception ex) @@ -46,7 +46,7 @@ public async Task DeleteAsync(HealthCheckResource resource) { try { - await _client.DeleteNamespacedConfigMapAsync($"{resource.Spec.Name}-config", resource.Metadata.NamespaceProperty); + await _client.CoreV1.DeleteNamespacedConfigMapAsync($"{resource.Spec.Name}-config", resource.Metadata.NamespaceProperty); } catch (Exception ex) { diff --git a/src/HealthChecks.UI.K8s.Operator/Handlers/DeploymentHandler.cs b/src/HealthChecks.UI.K8s.Operator/Handlers/DeploymentHandler.cs index 453d285a79..8ab1cde092 100644 --- a/src/HealthChecks.UI.K8s.Operator/Handlers/DeploymentHandler.cs +++ b/src/HealthChecks.UI.K8s.Operator/Handlers/DeploymentHandler.cs @@ -34,7 +34,7 @@ public async Task GetOrCreateAsync(HealthCheckResource resource) try { var deploymentResource = Build(resource); - var response = await _client.CreateNamespacedDeploymentWithHttpMessagesAsync(deploymentResource, resource.Metadata.NamespaceProperty); + var response = await _client.AppsV1.CreateNamespacedDeploymentWithHttpMessagesAsync(deploymentResource, resource.Metadata.NamespaceProperty); deployment = response.Body; _operatorDiagnostics.DeploymentCreated(deployment.Metadata.Name); @@ -51,7 +51,7 @@ public async Task DeleteAsync(HealthCheckResource resource) { try { - await _client.DeleteNamespacedDeploymentAsync($"{resource.Spec.Name}-deploy", + await _client.AppsV1.DeleteNamespacedDeploymentAsync($"{resource.Spec.Name}-deploy", resource.Metadata.NamespaceProperty); } catch (Exception ex) diff --git a/src/HealthChecks.UI.K8s.Operator/Handlers/SecretHandler.cs b/src/HealthChecks.UI.K8s.Operator/Handlers/SecretHandler.cs index 49c599a71f..27d45e4c92 100644 --- a/src/HealthChecks.UI.K8s.Operator/Handlers/SecretHandler.cs +++ b/src/HealthChecks.UI.K8s.Operator/Handlers/SecretHandler.cs @@ -26,7 +26,7 @@ public async Task GetOrCreateAsync(HealthCheckResource resource) try { var secretResource = Build(resource); - secret = await _client.CreateNamespacedSecretAsync(secretResource, + secret = await _client.CoreV1.CreateNamespacedSecretAsync(secretResource, resource.Metadata.NamespaceProperty); _logger.LogInformation("Secret {name} has been created", secret.Metadata.Name); @@ -49,7 +49,7 @@ public async Task DeleteAsync(HealthCheckResource resource) { try { - await _client.DeleteNamespacedSecretAsync($"{resource.Spec.Name}-secret", resource.Metadata.NamespaceProperty); + await _client.CoreV1.DeleteNamespacedSecretAsync($"{resource.Spec.Name}-secret", resource.Metadata.NamespaceProperty); } catch (Exception ex) { diff --git a/src/HealthChecks.UI.K8s.Operator/Handlers/ServiceHandler.cs b/src/HealthChecks.UI.K8s.Operator/Handlers/ServiceHandler.cs index eeaea6c69a..d4e673f6be 100644 --- a/src/HealthChecks.UI.K8s.Operator/Handlers/ServiceHandler.cs +++ b/src/HealthChecks.UI.K8s.Operator/Handlers/ServiceHandler.cs @@ -30,7 +30,7 @@ public async Task GetOrCreateAsync(HealthCheckResource resource) try { var serviceResource = Build(resource); - service = await _client.CreateNamespacedServiceAsync(serviceResource, resource.Metadata.NamespaceProperty); + service = await _client.CoreV1.CreateNamespacedServiceAsync(serviceResource, resource.Metadata.NamespaceProperty); _logger.LogInformation("Service {name} has been created", service.Metadata.Name); } catch (Exception ex) @@ -46,7 +46,7 @@ public async Task DeleteAsync(HealthCheckResource resource) { try { - await _client.DeleteNamespacedServiceAsync($"{resource.Spec.Name}-svc", resource.Metadata.NamespaceProperty); + await _client.CoreV1.DeleteNamespacedServiceAsync($"{resource.Spec.Name}-svc", resource.Metadata.NamespaceProperty); } catch (Exception ex) { diff --git a/src/HealthChecks.UI.K8s.Operator/HealthChecks.UI.K8s.Operator.csproj b/src/HealthChecks.UI.K8s.Operator/HealthChecks.UI.K8s.Operator.csproj index 28f734713d..6f236c19b0 100644 --- a/src/HealthChecks.UI.K8s.Operator/HealthChecks.UI.K8s.Operator.csproj +++ b/src/HealthChecks.UI.K8s.Operator/HealthChecks.UI.K8s.Operator.csproj @@ -10,7 +10,7 @@ - + diff --git a/src/HealthChecks.UI.K8s.Operator/Operator/ClusterServiceWatcher.cs b/src/HealthChecks.UI.K8s.Operator/Operator/ClusterServiceWatcher.cs index 00fb798f72..b013d83aea 100644 --- a/src/HealthChecks.UI.K8s.Operator/Operator/ClusterServiceWatcher.cs +++ b/src/HealthChecks.UI.K8s.Operator/Operator/ClusterServiceWatcher.cs @@ -29,7 +29,7 @@ NotificationHandler notificationHandler internal Task Watch(HealthCheckResource resource, CancellationToken token) { - var response = _client.ListServiceForAllNamespacesWithHttpMessagesAsync( + var response = _client.CoreV1.ListServiceForAllNamespacesWithHttpMessagesAsync( labelSelector: $"{resource.Spec.ServicesLabel}", watch: true, cancellationToken: token); diff --git a/src/HealthChecks.UI.K8s.Operator/Operator/HealthChecksOperator.cs b/src/HealthChecks.UI.K8s.Operator/Operator/HealthChecksOperator.cs index 698053ff21..974be40a41 100644 --- a/src/HealthChecks.UI.K8s.Operator/Operator/HealthChecksOperator.cs +++ b/src/HealthChecks.UI.K8s.Operator/Operator/HealthChecksOperator.cs @@ -72,7 +72,7 @@ public Task StopAsync(CancellationToken cancellationToken) private async Task StartWatcherAsync(CancellationToken token) { - var response = await _client.ListClusterCustomObjectWithHttpMessagesAsync( + var response = await _client.CustomObjects.ListClusterCustomObjectWithHttpMessagesAsync( group: Constants.GROUP, version: Constants.VERSION, plural: Constants.PLURAL, diff --git a/src/HealthChecks.UI.K8s.Operator/Operator/NamespacedServiceWatcher.cs b/src/HealthChecks.UI.K8s.Operator/Operator/NamespacedServiceWatcher.cs index cc77c05b5a..5783d950f9 100644 --- a/src/HealthChecks.UI.K8s.Operator/Operator/NamespacedServiceWatcher.cs +++ b/src/HealthChecks.UI.K8s.Operator/Operator/NamespacedServiceWatcher.cs @@ -35,7 +35,7 @@ internal Task Watch(HealthCheckResource resource, CancellationToken token) if (!_watchers.Keys.Any(filter)) { - var response = _client.ListNamespacedServiceWithHttpMessagesAsync( + var response = _client.CoreV1.ListNamespacedServiceWithHttpMessagesAsync( namespaceParameter: resource.Metadata.NamespaceProperty, labelSelector: $"{resource.Spec.ServicesLabel}", watch: true, diff --git a/src/HealthChecks.UI/Core/Discovery/K8S/Extensions/IKubernetesExtensions.cs b/src/HealthChecks.UI/Core/Discovery/K8S/Extensions/IKubernetesExtensions.cs index 8073d174cc..2d36df41f7 100644 --- a/src/HealthChecks.UI/Core/Discovery/K8S/Extensions/IKubernetesExtensions.cs +++ b/src/HealthChecks.UI/Core/Discovery/K8S/Extensions/IKubernetesExtensions.cs @@ -10,11 +10,11 @@ internal static async Task GetServicesAsync(this IKubernetes clie { if (k8sNamespaces is null || k8sNamespaces.Count == 0) { - return await client.ListServiceForAllNamespacesAsync(labelSelector: label, cancellationToken: cancellationToken); + return await client.CoreV1.ListServiceForAllNamespacesAsync(labelSelector: label, cancellationToken: cancellationToken); } else { - var responses = await Task.WhenAll(k8sNamespaces.Select(k8sNamespace => client.ListNamespacedServiceAsync(k8sNamespace, labelSelector: label, cancellationToken: cancellationToken))); + var responses = await Task.WhenAll(k8sNamespaces.Select(k8sNamespace => client.CoreV1.ListNamespacedServiceAsync(k8sNamespace, labelSelector: label, cancellationToken: cancellationToken))); return new V1ServiceList() { diff --git a/src/HealthChecks.UI/HealthChecks.UI.csproj b/src/HealthChecks.UI/HealthChecks.UI.csproj index 7e3ffdca26..3e808386d3 100644 --- a/src/HealthChecks.UI/HealthChecks.UI.csproj +++ b/src/HealthChecks.UI/HealthChecks.UI.csproj @@ -22,7 +22,7 @@ - +