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.12.tar.gz
(13.4 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.12-py3-none-any.whl
(13.5 kB
view details)
File details
Details for the file kmonitor-0.2.12.tar.gz.
File metadata
- Download URL: kmonitor-0.2.12.tar.gz
- Upload date:
- Size: 13.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
12d94fb1228c8a9e0ffe08a27e4c9f070bd483044631c25d6fe29dd5b52f2eda
|
|
| MD5 |
ab074b64725a7c6636d08cc59c29e232
|
|
| BLAKE2b-256 |
1a6fd7358895c3692da5cf8a1e2d4d42f7ee9f4d12e7c46de904add9eeeda067
|
File details
Details for the file kmonitor-0.2.12-py3-none-any.whl.
File metadata
- Download URL: kmonitor-0.2.12-py3-none-any.whl
- Upload date:
- Size: 13.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7d34271a41e3dfa626f4d91d5d8814e8201552c7ddb89d02e690e42006e4dcfc
|
|
| MD5 |
db2dfb585d9da900902a37c6722d208d
|
|
| BLAKE2b-256 |
68d88839edb2ad80065a1e950a0907a23cd28790179f499d54cc150769ca3299
|