kopf
Kubernetes Operator Pythonic Framework (Kopf)
What it is and what it does
Kopf is a framework that simplifies Kubernetes operator development by letting you write domain logic in Python without infrastructure boilerplate. Instead of managing Kubernetes API calls and event loops directly, you decorate Python functions to respond to resource creation, updates, deletion, and other lifecycle events. The framework handles marshalling resource data into function arguments, persisting handler progress across restarts, retrying on failure, and publishing logs as Kubernetes events.
It supports both synchronous and asynchronous handlers, timers, daemons, admission webhooks, and cross-operator coordination (peering). The framework is production-ready and stable; the maintainer has stated that the core design is complete with no major new functionality planned, though maintenance for new Python and Kubernetes versions continues regularly.
Use it for:
- Build a custom Kubernetes resource operator that automatically provisions or reconciles infrastructure when resources are created or modified.
- Implement admission webhooks to validate or mutate custom resources before they are persisted to the cluster.
- Run background daemons or periodic timers tied to individual resources, with automatic cleanup when resources are deleted.
- Migrate domain logic from imperative scripts into a declarative operator that survives pod restarts and cluster disruptions.
- Coordinate multiple Kopf-based operators on the same resource kinds to avoid duplicate processing and manage dev/prod operator switching.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Kopf is a Python framework for building Kubernetes operators with minimal boilerplate, using decorators to register event handlers that respond to changes in custom and built-in Kubernetes resources.
Yes, if you are building Kubernetes operators in Python. Kopf eliminates boilerplate and provides a stable, actively maintained framework with a permissive license. The low install friction and support for current Python versions (3.10–3.14) make it a practical choice for production operators. No known vulnerabilities and 2631 GitHub stars indicate community confidence.
Install
kopf on PyPI
pip
pip install kopfuv
uv add kopfpoetry
poetry add kopfInstalling kopf
Before you install
Low friction install with a pure-Python wheel. Actively maintained as of June 2026 with no major feature development planned but regular maintenance for Python and Kubernetes compatibility.
License in practice
MIT license permits commercial and private use with minimal restrictions; suitable for most deployment contexts.
Quickstart
pip install kopf
import kopf
@kopf.on.create('kopfexamples')
def create_fn(spec, name, **kwargs):
print(f"Created {name} with spec: {spec}")
# Run with: kopf run handlers.py
Requires Python 3.10 or later (CPython or PyPy officially supported).
Verify before relying
- Whether the six runtime dependencies (aiohttp, click, pyyaml, iso8601, jsonpatch, python-json-logger) are all required for basic operator functionality or only for specific features.
- Performance characteristics and memory footprint under high-load scenarios, as the description mentions planned optimizations but does not quantify current behavior.
Package facts
| License | MIT (permissive) |
| Python support | supports the current Python release (>=3.10) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 6 — python-json-logger, jsonpatch, iso8601, pyyaml, click, aiohttp |
| Maintenance | actively maintained — 72 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 1,729,170/month — #3,610 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: kopf-1.44.6-py3-none-any.whl
Keywords: kubernetes, operator, framework, python, k8s
Tags
More Libraries packages
urllib3 is an HTTP client library that provides…
permissive · top 100 on PyPI
requestsRequests is a Python HTTP library that…
permissive · top 100 on PyPI
pluggyPluggy provides a plugin system that lets you…
permissive · top 100 on PyPI
python-dateutilProvides parsing, arithmetic, and recurrence…
permissive · top 100 on PyPI
sixSix provides utility functions to write Python…
permissive · top 100 on PyPI
pytestpytest is a testing framework that lets you…
permissive · top 100 on PyPI
kr8sA Python client library for Kubernetes that…
permissive · top 5,000 on PyPI
spaceforgeSpaceforge is a Python framework for building…
permissive · top 15,000 on PyPI
k8Provides Python type models for Kubernetes…
permissive · top 15,000 on PyPI
cdk8scdk8s is a framework for defining Kubernetes…
permissive · top 15,000 on PyPI
lightkube-modelsProvides Python type definitions and model…
permissive · top 15,000 on PyPI
pulumi-kubernetesPulumi Kubernetes Resource Provider lets you…
permissive · top 5,000 on PyPI
portforwardProvides Python bindings for Kubernetes…
permissive · top 15,000 on PyPI
kubernetesProvides a Python interface to the Kubernetes…
permissive · top 1,000 on PyPI
kubernetes-typedA mypy plugin that adds type checking support…
permissive · top 15,000 on PyPI
kubernetes-validateValidates Kubernetes resource definitions…
permissive · top 15,000 on PyPI