I am trying to get the Kubernetes pod status through Kubernetes C# client library client library. One of my pods is a crash loop in the state. But the status of the pod from API is running. How to get the actual status of the pod?
Iam using
<PackageReference Include="KubernetesClient" Version="5.0.13" /> c# library . Code isusing k8s;
var config = KubernetesClientConfiguration.InClusterConfig();
var client = new Kubernetes(config);
var namespaces = client.ListNamespacedPodAsync("cronjob").GetAwaiter().GetResult();
foreach (var ns in namespaces.Items)
{
var status = ns.Status.Phase;
Console.WriteLine(status);
}
Output is
Running
Running
But the actual result is while using kubectl command is
kubectl get pods -n cronjob
test3-1625640480-9vjg4 0/1 CrashLoopBackOff 5 5m51s
test1-cron-1625640600-mrqcg 0/1 Completed 0 4m39s