Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

k8s provider diagnostics #1820

Merged
merged 2 commits into from
Oct 16, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions src/Proto.Cluster.Kubernetes/KubernetesProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
using k8s;
using k8s.Models;
using Microsoft.Extensions.Logging;
using Proto.Diagnostics;
using Proto.Utils;
using static Proto.Cluster.Kubernetes.Messages;
using static Proto.Cluster.Kubernetes.ProtoLabels;
Expand All @@ -38,6 +39,29 @@ public class KubernetesProvider : IClusterProvider
private string _podName;
private int _port;

public async Task<DiagnosticsEntry[]> GetDiagnostics()
{
try
{
var selector = $"{LabelCluster}={_clusterName}";
using var client = _config.ClientFactory();
var res = await client.ListNamespacedPodWithHttpMessagesAsync(
KubernetesExtensions.GetKubeNamespace(),
labelSelector: selector,
watch: false,
timeoutSeconds: _config.WatchTimeoutSeconds
);

var pods = new DiagnosticsEntry("KubernetesProvider", "Pods", res.Body);

return new[] { pods };
}
catch (Exception x)
{
return new[] { new DiagnosticsEntry("KubernetesProvider", "Exception", x.ToString() ) };
}
}

public KubernetesProvider() : this(new KubernetesProviderConfig())
{
}
Expand Down