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/k8s_monitor.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.2.1.tar.gz (12.0 kB view details)

Uploaded Source

Built Distribution

kmonitor-0.2.1-py3-none-any.whl (12.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: kmonitor-0.2.1.tar.gz
  • Upload date:
  • Size: 12.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.8

File hashes

Hashes for kmonitor-0.2.1.tar.gz
Algorithm Hash digest
SHA256 7e856cdef937616b3eeab7792532e57e7fc34f12cafc31062e3f05188a5c07cf
MD5 c50ec217e4a4e7412e52f5a89031ab75
BLAKE2b-256 242d76ebd9162b1129aaedd2b90a2fdc95cb800d292e85fc747bcd1d3e1c7764

See more details on using hashes here.

File details

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

File metadata

  • Download URL: kmonitor-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 12.0 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.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 58147b448e3ccbe849fc2470e98624f153787149662029dbd6428b5bd85180d5
MD5 889e907d07b43ec1028fc85d41579f27
BLAKE2b-256 d70586770840f80278b404214c8f60edc9f8994a9bb12a91f4d3054cc06f718b

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