Skip to main content

Collection of Kubernetes command-line utilities

Project description

k8s-utils

A collection of Kubernetes command-line utilities built with Python and Typer.

Installation

This project uses uv for package management.

# Install dependencies
uv sync

# Run commands
uv run k8stools <command> [args]

Alternatively, install the package to use it without the uv run prefix:

uv pip install -e .
k8stools <command> [args]

Commands

podcount

Count non-daemonset pods per node in the current Kubernetes context.

# Use current context
uv run k8stools podcount

# Specify a different context
uv run k8stools podcount --context my-context

This command:

  • Retrieves all pods and nodes in the cluster
  • Excludes pods managed by DaemonSets
  • Displays a table showing pod count per node
  • Shows total non-DaemonSet pod count

Example output:

Fetching pods...
Fetching nodes...

3
 Node                 Pod Count 
!G)
 node-1                      12 
 node-2                       8 
 node-3                      15 
\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x004\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00

Total non-DaemonSet pods: 35

Development

The project structure:

k8s-utils/
\x00\x00 k8s_utils/
   \x00\x00 __init__.py
   \x00\x00 main.py              # CLI entry point
   \x00\x00 commands/
       \x00\x00 __init__.py
       \x00\x00 podcount.py      # podcount command implementation
\x00\x00 pyproject.toml
\x00\x00 README.md

To add a new command:

  1. Create a new file in k8s_utils/commands/ (e.g., mycommand.py)
  2. Implement your command as a function with Typer annotations
  3. Import and register it in k8s_utils/main.py:
from k8s_utils.commands import mycommand

app.command(name="mycommand")(mycommand.mycommand)

Requirements

  • Python 3.13+
  • Access to a Kubernetes cluster with a valid kubeconfig
  • uv package manager

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

k8s_helpers-1.0.2a8.tar.gz (17.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

k8s_helpers-1.0.2a8-py3-none-any.whl (5.6 kB view details)

Uploaded Python 3

File details

Details for the file k8s_helpers-1.0.2a8.tar.gz.

File metadata

  • Download URL: k8s_helpers-1.0.2a8.tar.gz
  • Upload date:
  • Size: 17.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for k8s_helpers-1.0.2a8.tar.gz
Algorithm Hash digest
SHA256 b7f97af18d5b50d562be0a7af857b1f5e4c4075e064db2a592bd2ce684ed97a6
MD5 103d4bbddb13f49111028ff9ad3b19d8
BLAKE2b-256 86a35205eb3f0a3434689c816120129cdb0afb68492ed9721ae998a29637fd90

See more details on using hashes here.

Provenance

The following attestation bundles were made for k8s_helpers-1.0.2a8.tar.gz:

Publisher: ci.yml on trondhindenes/k8s-helpers

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file k8s_helpers-1.0.2a8-py3-none-any.whl.

File metadata

  • Download URL: k8s_helpers-1.0.2a8-py3-none-any.whl
  • Upload date:
  • Size: 5.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for k8s_helpers-1.0.2a8-py3-none-any.whl
Algorithm Hash digest
SHA256 210c8293f9af1bb8529af681e31809abf8b1b02777dfbbefa6bfc36616076b92
MD5 a29991a7440bd02e1290eddb77d10b72
BLAKE2b-256 3434af9fda39bed42e3dcfdb539bc2dd9f8abea1a4131d4fc68a484c19b2d037

See more details on using hashes here.

Provenance

The following attestation bundles were made for k8s_helpers-1.0.2a8-py3-none-any.whl:

Publisher: ci.yml on trondhindenes/k8s-helpers

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

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