-
# https://github.com/kubernetes-sigs/kind/issues/398 # kubectl apply -f https://github.com/kubernetes-sigs/metrics-server/releases/download/v0.5.0/components.yaml # kubectl patch -n kube-system deployment metrics-server --type=json \ # -p '[{"op":"add","path":"/spec/template/spec/containers/0/args/-","value":"--kubelet-insecure-tls"}]' from kubernetes import client api_client = client.ApiClient(configuration) custom_api = client.CustomObjectsApi(api_client) response = custom_api.list_cluster_custom_object("metrics.k8s.io", "v1beta1", "nodes") # also works with "pods" instead of "nodes" for node in response["items"]: print(f"{node['metadata']['name']: <30} CPU: {node['usage']['cpu']: <10} Memory: {node['usage']['memory']}") # api-playground-control-plane CPU: 148318488n Memory: 2363504Ki # api-playground-worker CPU: 91635913n Memory: 1858680Ki # api-playground-worker2 CPU: 75473747n Memory: 1880860Ki # api-playground-worker3 CPU: 105692650n Memory: 1881560Ki
-
Judoscale
Save 47% on cloud hosting with autoscaling that just works. Judoscale integrates with Django, FastAPI, Celery, and RQ to make autoscaling easy and reliable. Save big, and say goodbye to request timeouts and backed-up task queues.
-
As you can imagine, that's a lot of functions to choose from, luckily all of them are listed in docs and you can click on any one of them to get an example of its usage.
-
metrics-server
Scalable and efficient source of container resource metrics for Kubernetes built-in autoscaling pipelines.
# https://github.com/kubernetes-sigs/kind/issues/398 # kubectl apply -f https://github.com/kubernetes-sigs/metrics-server/releases/download/v0.5.0/components.yaml # kubectl patch -n kube-system deployment metrics-server --type=json \ # -p '[{"op":"add","path":"/spec/template/spec/containers/0/args/-","value":"--kubelet-insecure-tls"}]' from kubernetes import client api_client = client.ApiClient(configuration) custom_api = client.CustomObjectsApi(api_client) response = custom_api.list_cluster_custom_object("metrics.k8s.io", "v1beta1", "nodes") # also works with "pods" instead of "nodes" for node in response["items"]: print(f"{node['metadata']['name']: <30} CPU: {node['usage']['cpu']: <10} Memory: {node['usage']['memory']}") # api-playground-control-plane CPU: 148318488n Memory: 2363504Ki # api-playground-worker CPU: 91635913n Memory: 1858680Ki # api-playground-worker2 CPU: 75473747n Memory: 1880860Ki # api-playground-worker3 CPU: 105692650n Memory: 1881560Ki
-
If you're looking for more examples beyond what was shown and referenced above, I recommend exploring other popular tools that make use Python Kubernetes client, such kopf - the library for creating Kubernetes operators. I also find it very useful to take a look at tests of the library itself, as it showcases its intended usage such this client test suite.
Related posts
-
Korifi : API Cloud Foundry V3 expérimentale dans Kubernetes …
-
Minikube VM. I’m having all sorts of trouble getting minikube to work. Does anyone know of a vm or lxc/LXD that is ready to go?
-
Simulando um cluster k8s localmente com Kind
-
Building a Secure CI/CD Pipeline for a TypeScript Application Using GitHub Actions and ArgoCD
-
From Helm Chart to Developer UI in 5 Minutes