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
This commit is contained in:
Saar Shen 2023-01-26 09:59:51 -08:00 коммит произвёл GitHub
Родитель 3d1f8ce5c3
Коммит e3eb4de7cf
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
3 изменённых файлов: 9 добавлений и 13 удалений

Просмотреть файл

@ -3,7 +3,7 @@
<Features>IOperation</Features>
</PropertyGroup>
<PropertyGroup>
<TargetFramework>netstandard2.1</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
<RootNamespace>Microsoft.ApplicationInsights.Kubernetes</RootNamespace>
<AssemblyName>Microsoft.ApplicationInsights.Kubernetes</AssemblyName>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
@ -17,7 +17,7 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="KubernetesClient" Version="7.2.19" />
<PackageReference Include="KubernetesClient" Version="[10.0.16, 11.0.0)" />
<PackageReference Include="Microsoft.ApplicationInsights" Version="2.21.0" />
<PackageReference Include="Microsoft.Extensions.Configuration" Version="6.0.1" />
<PackageReference Include="Microsoft.Extensions.Hosting" Version="6.0.1" />
@ -27,10 +27,6 @@
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="6.0.1" />
</ItemGroup>
<ItemGroup>
<Compile Remove="Extensions\ObsoletedExtensions.cs" />
</ItemGroup>
<ItemGroup>
<None Include="./Readme.Nuget.md" Pack="true" PackagePath="\" />
</ItemGroup>

Просмотреть файл

@ -49,22 +49,22 @@ internal sealed class K8sClientService : IDisposable, IK8sClientService
public async Task<IEnumerable<V1Pod>> 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<V1Pod?> GetPodByNameAsync(string podName, CancellationToken cancellationToken)
=> _kubernetesClient.ReadNamespacedPodAsync(podName, _namespace, cancellationToken: cancellationToken);
=> _kubernetesClient.CoreV1.ReadNamespacedPodAsync(podName, _namespace, cancellationToken: cancellationToken);
public async Task<IEnumerable<V1ReplicaSet>> 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<IEnumerable<V1Deployment>> 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)

Просмотреть файл

@ -19,8 +19,8 @@
<AssemblyOriginatorKeyFile>$(MSBuildThisFileDirectory)PublicKey.snk</AssemblyOriginatorKeyFile>
<!--Package-->
<VersionSuffix Condition=" '$(VersionSuffix)' == '' ">$([System.DateTime]::Now.ToString(yyyyMMddHHmm))</VersionSuffix>
<Version Condition=" '$(Version)' == '' ">3.0.0-private-$(VersionSuffix)</Version>
<AssemblyVersion Condition=" '$(AssemblyVersion)' == '' ">3.0.0.0</AssemblyVersion>
<Version Condition=" '$(Version)' == '' ">6.0.0-private-$(VersionSuffix)</Version>
<AssemblyVersion Condition=" '$(AssemblyVersion)' == '' ">6.0.0.0</AssemblyVersion>
<Authors>Microsoft</Authors>
<Company>Microsoft</Company>
<PackageRequireLicenseAcceptance>True</PackageRequireLicenseAcceptance>