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.10.tar.gz
(13.2 kB
view details)
Built Distribution
kmonitor-0.2.10-py3-none-any.whl
(13.2 kB
view details)
File details
Details for the file kmonitor-0.2.10.tar.gz
.
File metadata
- Download URL: kmonitor-0.2.10.tar.gz
- Upload date:
- Size: 13.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.12.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f193007029390d8b9f432e4b65019521bd8869a4eb83db4e30f80d3c16a96f3d |
|
MD5 | 4343d0d9fca637c3638b73c0a040c9d8 |
|
BLAKE2b-256 | 8ae00ee95f14ee67dbf40a67bba62c322891f3a0f9532b52e7d89cb589a43dda |
File details
Details for the file kmonitor-0.2.10-py3-none-any.whl
.
File metadata
- Download URL: kmonitor-0.2.10-py3-none-any.whl
- Upload date:
- Size: 13.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.0 CPython/3.12.5
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4a29384ad3aa56fe2b584be8bfb6405dc6a3647aeb8c9f42350a6fa808c7678a |
|
MD5 | 3329fd059266254392ef441431bb8a02 |
|
BLAKE2b-256 | 92f607234520b26e49957a103a87dad2e9686742551a3d30dee0798acfa4eaa5 |