Shared utilities, contracts, and middleware for KubeMind services
Project description
KubeMind Common Library
Shared Python library for all KubeMind services.
Overview
kubemind-common provides shared functionality across all KubeMind services:
- Configuration management
- Logging setup with correlation IDs
- Middleware (request ID, rate limiting, error handling)
- Contracts (Pydantic models for events, playbooks, triggers)
- HTTP client with retries
- Redis client and utilities
- Database utilities
- Security utilities (JWT, HMAC)
- Metrics instrumentation
- Kubernetes utilities
Contributor Guide
See Repository Guidelines for structure, workflows, and review expectations.
Installation
- From PyPI:
pip install kubemind-common
- With extras (examples):
pip install "kubemind-common[fastapi]"
pip install "kubemind-common[db]"
pip install "kubemind-common[auth]"
- In a monorepo (editable install):
pip install -e ../kubemind-common
Development
pip install -e .[dev]
Running the test suite and building artefacts are managed through the bundled Makefile:
make test # run pytest after a clean build directory
make build # produce wheel and sdist under dist/
make check # twine check on the build outputs
Publishing
- Export a
PYPI_TOKENwith upload permissions (username is always__token__). - Run
make publishwhich will rebuild, validate and upload using Twine. - Tag the release (
git tag vX.Y.Z && git push --tags) so downstream services can pin versions.
Usage
Configuration
from kubemind_common.config.base import BaseServiceSettings
settings = BaseServiceSettings()
Logging
from kubemind_common.logging.setup import setup_logging
setup_logging(level="INFO", format="json")
HTTP Client
from kubemind_common.http.client import create_http_client, http_request
async with create_http_client() as client:
response = await http_request(client, "GET", "https://api.example.com")
Kubernetes
from kubemind_common.k8s.client import create_k8s_client
k8s = create_k8s_client(in_cluster=False)
pods = k8s.core_v1_api.list_pod_for_all_namespaces()
Contracts
from kubemind_common.contracts.events import Event
from kubemind_common.contracts.playbooks import PlaybookSpec
event = Event(
id="evt-123",
source="kubernetes",
type="pod_crash",
timestamp="2025-10-12T17:00:00Z"
)
Project Structure
src/kubemind_common/— library codeconfig/,logging/,middleware/,contracts/,http/,redis/,db/,security/,metrics/,k8s/,utils/, etc.
tests/— unit and integration testsdocs/— documentation (seedocs/index.md)examples/— runnable usage examples.github/workflows/— CI/CD and publishing
Development
# Create a virtual environment and install in editable mode
python -m venv .venv && . .venv/bin/activate
pip install -e ".[dev]"
# Run tests
pytest
# Type checking (if configured)
mypy src/kubemind_common/
# Linting (if configured)
ruff check .
Build & Publish
This project uses modern PEP 621 metadata with Hatchling.
- Local build:
python -m pip install --upgrade build
python -m build
- Trusted Publishing via GitHub Actions:
- Configure the PyPI project to trust this repository (PyPI → Management → Publishing → Trusted Publishers).
- Tag a release
vX.Y.Zto publish to PyPI. - Tag a pre-release like
vX.Y.Z-rc1to publish to TestPyPI. - Or run the
Publishworkflow manually and choosepypiortestpypi.
Versioning
This library follows semantic versioning. Services should pin compatible versions:
kubemind-common = "^0.2.0"
Documentation
See docs/index.md for module documentation and examples.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file kubemind_common-0.1.0.tar.gz.
File metadata
- Download URL: kubemind_common-0.1.0.tar.gz
- Upload date:
- Size: 42.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.12.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ac77f7984ff76053f1fa62d24fe637f219983dfb36412f062beaee80dc78d219
|
|
| MD5 |
dd80798b19fa1a3130bd0cb29fc34712
|
|
| BLAKE2b-256 |
59b0a672805ac10d77d73106430fe99ff9b88173acc3f65e6e190a2505b0528c
|
File details
Details for the file kubemind_common-0.1.0-py3-none-any.whl.
File metadata
- Download URL: kubemind_common-0.1.0-py3-none-any.whl
- Upload date:
- Size: 56.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.12.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
49d4b8d8decb465eb2c56d23e9f51a9a82e8e5a08de4eb3088485d0eceac306b
|
|
| MD5 |
694416efdbca518f76a70ebb1eee1381
|
|
| BLAKE2b-256 |
e5baecbe25fa2a17c7433a3ab8d1470419a8e4af13b0776e4d3df471dc5f6d97
|