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.

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


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

Uploaded Source

Built Distribution

kmonitor-0.2.9-py3-none-any.whl (12.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: kmonitor-0.2.9.tar.gz
  • Upload date:
  • Size: 12.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.0 CPython/3.12.4

File hashes

Hashes for kmonitor-0.2.9.tar.gz
Algorithm Hash digest
SHA256 f6466d8b6e2fca106d126040461cf119aeeb328f1f4815cbeb401f06e2c1a1d9
MD5 4d0c190022f66f7a47036649455295c9
BLAKE2b-256 d3ed5ee99261defd2871932630fae89943611851a1411f94cdbe00ce82b31d4a

See more details on using hashes here.

File details

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

File metadata

  • Download URL: kmonitor-0.2.9-py3-none-any.whl
  • Upload date:
  • Size: 12.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.0 CPython/3.12.4

File hashes

Hashes for kmonitor-0.2.9-py3-none-any.whl
Algorithm Hash digest
SHA256 c86701e0ef7ca1943e2b610bdb10efbe6a425ef856ef1094c7e72470b7a057e7
MD5 c158cfc1a0a004f89f7f00958c3959c3
BLAKE2b-256 1366957573fb507d617bfd90a24dad3c3f5b715a35e4929ffc88a85a15a0fe09

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