Skip to main content

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}
}

Metadata

Release files for kmonitor 0.2.12

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for kmonitor 0.2.12
File Size Uploaded Provenance Actions
kmonitor-0.2.12.tar.gz 13.4 kB Without provenance Details for kmonitor-0.2.12.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for kmonitor 0.2.12
File Interpreter ABI Platform Actions
kmonitor-0.2.12-py3-none-any.whl Python 3 none any Details for kmonitor-0.2.12-py3-none-any.whl

Total release size: 26.9 kB

Release files / kmonitor-0.2.12.tar.gz

Download URL kmonitor-0.2.12.tar.gz
Size 13.4 kB
Tags Source
SHA-256 checksum
How to use checksums
12d94fb1228c8a9e0ffe08a27e4c9f070bd483044631c25d6fe29dd5b52f2eda
BLAKE2b-256 checksum
How to use checksums
1a6fd7358895c3692da5cf8a1e2d4d42f7ee9f4d12e7c46de904add9eeeda067
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.8

Release files / kmonitor-0.2.12-py3-none-any.whl

Download URL kmonitor-0.2.12-py3-none-any.whl
Size 13.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7d34271a41e3dfa626f4d91d5d8814e8201552c7ddb89d02e690e42006e4dcfc
BLAKE2b-256 checksum
How to use checksums
68d88839edb2ad80065a1e950a0907a23cd28790179f499d54cc150769ca3299
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.8

Security for kmonitor 0.2.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page