Hi,
I’m looking for a way (maybe it already exists on github?) to make a simple web service to print “kubectl get pods” and refresh every minute. I know kubernetes-dashboard does it, but just looking for something really simple. Thx!
I sadly don’t have an example but I think the simplest way to achieve this is to make use of the K8s client libraries in your preferred language here’s a list of officially supported client libraries (Go, Javascript, Python, dotNet, Haskell, Java) and have it run on a timed loop.
Here’s the typescript example from the javascript client for getting all pods in a namespace.
const k8s = require('@kubernetes/client-node');
const kc = new k8s.KubeConfig();
kc.loadFromDefault();
const k8sApi = kc.makeApiClient(k8s.CoreV1Api);
k8sApi.listNamespacedPod('default').then((res) => {
console.log(res.body);
});
Hope that helps to put you in the right direction. Let me know if there’s any thing else.
1 Like