From e3eb4de7cfe27b72ecfe8c02af0e1bab93520b35 Mon Sep 17 00:00:00 2001 From: Saar Shen Date: Thu, 26 Jan 2023 09:59:51 -0800 Subject: [PATCH] Application Insights for Kubernetes 6.0 (#334) * Upgrade to latest K8sClient * Update default version to 6.0 to align with targeted framework * Remove an unintended change --- .../ApplicationInsights.Kubernetes.csproj | 8 ++------ src/ApplicationInsights.Kubernetes/K8sClientService.cs | 10 +++++----- src/Directory.Build.props | 4 ++-- 3 files changed, 9 insertions(+), 13 deletions(-) diff --git a/src/ApplicationInsights.Kubernetes/ApplicationInsights.Kubernetes.csproj b/src/ApplicationInsights.Kubernetes/ApplicationInsights.Kubernetes.csproj index e3db709..bd3f04b 100644 --- a/src/ApplicationInsights.Kubernetes/ApplicationInsights.Kubernetes.csproj +++ b/src/ApplicationInsights.Kubernetes/ApplicationInsights.Kubernetes.csproj @@ -3,7 +3,7 @@ IOperation - netstandard2.1 + net6.0 Microsoft.ApplicationInsights.Kubernetes Microsoft.ApplicationInsights.Kubernetes true @@ -17,7 +17,7 @@ - + @@ -27,10 +27,6 @@ - - - - diff --git a/src/ApplicationInsights.Kubernetes/K8sClientService.cs b/src/ApplicationInsights.Kubernetes/K8sClientService.cs index d7bc418..b5c570b 100644 --- a/src/ApplicationInsights.Kubernetes/K8sClientService.cs +++ b/src/ApplicationInsights.Kubernetes/K8sClientService.cs @@ -49,22 +49,22 @@ internal sealed class K8sClientService : IDisposable, IK8sClientService public async Task> GetPodsAsync(CancellationToken cancellationToken) { - V1PodList? list = await _kubernetesClient.ListNamespacedPodAsync(_namespace, cancellationToken: cancellationToken).ConfigureAwait(false); + V1PodList? list = await _kubernetesClient.CoreV1.ListNamespacedPodAsync(_namespace, cancellationToken: cancellationToken).ConfigureAwait(false); return list.AsEnumerable(); } public Task GetPodByNameAsync(string podName, CancellationToken cancellationToken) - => _kubernetesClient.ReadNamespacedPodAsync(podName, _namespace, cancellationToken: cancellationToken); + => _kubernetesClient.CoreV1.ReadNamespacedPodAsync(podName, _namespace, cancellationToken: cancellationToken); public async Task> GetReplicaSetsAsync(CancellationToken cancellationToken) { - V1ReplicaSetList? replicaSetList = await _kubernetesClient.ListNamespacedReplicaSetAsync(_namespace, cancellationToken: cancellationToken).ConfigureAwait(false); + V1ReplicaSetList? replicaSetList = await _kubernetesClient.AppsV1.ListNamespacedReplicaSetAsync(_namespace, cancellationToken: cancellationToken).ConfigureAwait(false); return replicaSetList.AsEnumerable(); } public async Task> GetDeploymentsAsync(CancellationToken cancellationToken) { - V1DeploymentList? deploymentList = await _kubernetesClient.ListNamespacedDeploymentAsync(_namespace, cancellationToken: cancellationToken).ConfigureAwait(false); + V1DeploymentList? deploymentList = await _kubernetesClient.AppsV1.ListNamespacedDeploymentAsync(_namespace, cancellationToken: cancellationToken).ConfigureAwait(false); return deploymentList.AsEnumerable(); } @@ -72,7 +72,7 @@ internal sealed class K8sClientService : IDisposable, IK8sClientService { try { - V1NodeList? nodeList = await _kubernetesClient.ListNodeAsync(); + V1NodeList? nodeList = await _kubernetesClient.CoreV1.ListNodeAsync().ConfigureAwait(false); return nodeList.AsEnumerable(); } catch (HttpOperationException ex) when (ex.Response.StatusCode == HttpStatusCode.Forbidden) diff --git a/src/Directory.Build.props b/src/Directory.Build.props index 25883d3..054b625 100644 --- a/src/Directory.Build.props +++ b/src/Directory.Build.props @@ -19,8 +19,8 @@ $(MSBuildThisFileDirectory)PublicKey.snk $([System.DateTime]::Now.ToString(yyyyMMddHHmm)) - 3.0.0-private-$(VersionSuffix) - 3.0.0.0 + 6.0.0-private-$(VersionSuffix) + 6.0.0.0 Microsoft Microsoft True