Skip to content

Commit

Permalink
Bump KubernetesClient from 4.0.26 to 11.0.36 (#1854)
Browse files Browse the repository at this point in the history
  • Loading branch information
sungam3r authored Jul 5, 2023
1 parent d47f21a commit ccd215a
Show file tree
Hide file tree
Showing 13 changed files with 24 additions and 24 deletions.
4 changes: 2 additions & 2 deletions src/HealthChecks.Kubernetes/HealthChecks.Kubernetes.csproj
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<TargetFrameworks>net6;net7</TargetFrameworks>
<PackageTags>$(PackageTags);Kubernetes;k8s;Cluster</PackageTags>
<Description>HealthChecks.HealthChecks is the health check package for Kubernetes clusters.</Description>
<VersionPrefix>$(HealthCheckKubernetes)</VersionPrefix>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="KubernetesClient" Version="4.0.26" />
<PackageReference Include="KubernetesClient" Version="11.0.36" />
<PackageReference Include="Microsoft.Extensions.Diagnostics.HealthChecks" Version="7.0.1" />
</ItemGroup>

Expand Down
6 changes: 3 additions & 3 deletions src/HealthChecks.Kubernetes/KubernetesChecksExecutor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand All @@ -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));
Expand All @@ -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));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,25 +6,25 @@ public static class IKubernetesExtensions
{
public static async Task<V1Deployment?> 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<V1Service?> 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<V1Secret?> 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<V1ConfigMap?> 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);
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/HealthChecks.UI.K8s.Operator/Handlers/ConfigMapHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public ConfigMaphandler(IKubernetes client, ILogger<K8sOperator> 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)
Expand All @@ -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)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public async Task<V1Deployment> 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);
Expand All @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions src/HealthChecks.UI.K8s.Operator/Handlers/SecretHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public async Task<V1Secret> 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);
Expand All @@ -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)
{
Expand Down
4 changes: 2 additions & 2 deletions src/HealthChecks.UI.K8s.Operator/Handlers/ServiceHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public async Task<V1Service> 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)
Expand All @@ -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)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="KubernetesClient" Version="4.0.26" />
<PackageReference Include="KubernetesClient" Version="11.0.36" />
<PackageReference Include="Microsoft.Extensions.Hosting" Version="7.0.1" />
<PackageReference Include="Microsoft.Extensions.Http" Version="7.0.0" />
<PackageReference Include="Serilog.Extensions.Logging" Version="3.1.0" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ internal static async Task<V1ServiceList> 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()
{
Expand Down
2 changes: 1 addition & 1 deletion src/HealthChecks.UI/HealthChecks.UI.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="7.0.5" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="7.0.4" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="KubernetesClient" Version="4.0.26" />
<PackageReference Include="KubernetesClient" Version="11.0.36" />
</ItemGroup>

<ItemGroup>
Expand Down

0 comments on commit ccd215a

Please sign in to comment.