kmonitor is a simple utility wrapper around kubernetes package
Project description
K8s Monitor
Description
Simple wrapper around kubernetes
package to monitor the status of a k8s deployment.
Usage
import numpy as np
from kmonitor import KubeMonitor, safe_jsonify
if __name__ == '__main__':
km = KubeMonitor()
pods = km.list_pods()
if pods is not None:
for pod in pods:
print(f"Pod: {pod.metadata.name} in namespace {pod.metadata.namespace} is in phase {pod.status.phase}")
else:
print("Failed to get pods")
namespaces = km.list_namespaces()
if namespaces is not None:
for ns in namespaces:
print(f"Namespace: {ns.metadata.name}")
else:
print("Failed to get namespaces")
nr_pods = len(pods)
idx = np.random.randint(0, nr_pods)
example_pod_name = "basic-test" # pods[idx].metadata.name
print("Checking pod status for pod {}".format(example_pod_name))
status = km.check_pod_by_name(example_pod_name)
print(safe_jsonify(status, indent=2))
example_pod_names = ["nvidia", "calico-node", "emqx"]
print("Checking pod status for pods {}".format(example_pod_names))
status = km.check_pods_by_names(example_pod_names)
print(safe_jsonify(status, indent=2))
Citation
If you use this code in your research, please consider citing it with the following BibTeX entry:
@misc{KMonitor,
author = {Andrei Damian},
title = {kmonitor - a simple K8s monitor framework},
year = {2023-2024},
publisher = {GitHub},
journal = {https://github.com/aidamian/kmonitor.git}
}
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
kmonitor-0.1.4.tar.gz
(10.5 kB
view details)
Built Distribution
File details
Details for the file kmonitor-0.1.4.tar.gz
.
File metadata
- Download URL: kmonitor-0.1.4.tar.gz
- Upload date:
- Size: 10.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 68ab06912c474b3975c1a87fb7fd51462d55ddc34b27edcf3ed225d7d31e1f8f |
|
MD5 | 3f4648f0bac7967a9f892436082745f5 |
|
BLAKE2b-256 | 5d8f29dc9ae4cb8c1f79618bb42e2c6bc92d7fd598180ecfd7a239133eefba38 |
File details
Details for the file kmonitor-0.1.4-py3-none-any.whl
.
File metadata
- Download URL: kmonitor-0.1.4-py3-none-any.whl
- Upload date:
- Size: 9.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.8
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | bbd0e7a177d2ae1028e3a370117f00feb164360bbe6b7501ff13cb4c97d64251 |
|
MD5 | ae069e86081be15538a2ac230b3bf657 |
|
BLAKE2b-256 | 2c17680dd5aa15fd857d8f83d5a68ac0c7ab857206b4ed8c96f6383942afe165 |