Kopf is a Python framework that simplifies writing Kubernetes operators with minimal code using a declarative and Pythonic approach.
A Python framework to write Kubernetes operators in just a few lines of code
Kopf is designed for developers and DevOps engineers who want to automate Kubernetes custom resource management by writing operators in Python quickly and efficiently. It enables the creation of Kubernetes operators that encapsulate domain logic to manage infrastructure as code, enhancing security automation and DevSecOps workflows.
The project is currently in maintenance mode, focusing on bug fixes and dependency updates without adding major new features. Users should be aware that Kopf aims to keep operator logic domain-focused with minimal infrastructure boilerplate. It supports both synchronous and asynchronous handlers and provides advanced features like admission webhooks and in-memory indexing, making it suitable for complex Kubernetes operator development within a Pythonic environment.
Install Kopf via pip: pip install kopf
Create a Python file defining your operator handlers using Kopf decorators
Build a Docker image including your operator code and dependencies
Deploy the operator container image to your Kubernetes cluster
pip install kopf
Installs the Kopf framework Python package.
kopf run my_operator.py
Runs a Kubernetes operator defined in the Python file 'my_operator.py'.