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.
Installation
pip install kmonitor --upgrade
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/k8s_monitor.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.2.11.tar.gz
(13.2 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
kmonitor-0.2.11-py3-none-any.whl
(13.3 kB
view details)
File details
Details for the file kmonitor-0.2.11.tar.gz.
File metadata
- Download URL: kmonitor-0.2.11.tar.gz
- Upload date:
- Size: 13.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7f255b0c7253bd0655e11d32f4426032774c004cba3907077b2f94d2d75b8b20
|
|
| MD5 |
6e7dda44fe843a1ec9302f5e702162cf
|
|
| BLAKE2b-256 |
9151c78d1b05a114496203cf265d0e675159254efc51db838ebcc9088bb64ae2
|
File details
Details for the file kmonitor-0.2.11-py3-none-any.whl.
File metadata
- Download URL: kmonitor-0.2.11-py3-none-any.whl
- Upload date:
- Size: 13.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
154fee0e942201de9be4316dc4658fb9026969b881981218a02fddd3ddac9ad8
|
|
| MD5 |
852e99456ccfbe56b9666fb8c289ce23
|
|
| BLAKE2b-256 |
253dbbee8b7c156dbbe5555ee63caf868b0335555690d55572100bad8f9a358d
|