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

Uploaded Source

Built Distribution

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

Uploaded Python 3

File details

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

File metadata

  • Download URL: kmonitor-0.2.0.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.0.tar.gz
Algorithm Hash digest
SHA256 a51f19b3f72bd97742a13ababffb1e1533a3f01a30e0988f2577d47196d28f01
MD5 89e97e74a51dff57ec80eb99f0231f3d
BLAKE2b-256 8d1428a5b35d3060b9d5bb10a832e0e1be15ef92648dfd2b6caaa23ec0d5b3b4

See more details on using hashes here.

File details

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

File metadata

  • Download URL: kmonitor-0.2.0-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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 913da56d78afa2c05689f34b442313f915d5e6b2a0002295466c59bd6af2fb08
MD5 da7ecf90bdb1a9f6389b50316633f6a1
BLAKE2b-256 164b58725eab121b82affaeecf0a99f2cf4182d4374a635f18f670eac6a43cd7

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