Skip to main content

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


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.3.tar.gz (10.5 kB view details)

Uploaded Source

Built Distribution

kmonitor-0.1.3-py3-none-any.whl (9.5 kB view details)

Uploaded Python 3

File details

Details for the file kmonitor-0.1.3.tar.gz.

File metadata

  • Download URL: kmonitor-0.1.3.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

Hashes for kmonitor-0.1.3.tar.gz
Algorithm Hash digest
SHA256 6db2394edc48161b0ea2279b13b0287b57880e973a7574eefde335aa15a13712
MD5 f41d60f472cfc116b76cf0de293b0e5e
BLAKE2b-256 96826b57d6a6b117c73c833d0a076e8b42dea4914adb8206d202c53c53182f3f

See more details on using hashes here.

File details

Details for the file kmonitor-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: kmonitor-0.1.3-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

Hashes for kmonitor-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 b9d181b976a7ed145e6a8addce65212e87bf684f057c5ceddc9dca0bd4df2829
MD5 f3e1a7a527b6c1848fc36a66dfee32d5
BLAKE2b-256 dc77f53dcee6f90af26e53574fe44c6afe34785d95deaa4cb1fa629b50c75d63

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page