zalando-incubator / Kopf

Licence: mit
A Python framework to write Kubernetes operators in just few lines of code.

Programming Languages

python
139335 projects - #7 most used programming language
python3
1442 projects

Projects that are alternatives of or similar to Kopf

Kopf
A Python framework to write Kubernetes operators in just a few lines of code
Stars: ✭ 488 (-49.74%)
Mutual labels:  asyncio, framework, operator, kubernetes-operator
rabbitmq-operator
RabbitMQ Kubernetes operator
Stars: ✭ 16 (-98.35%)
Mutual labels:  operator, kubernetes-operator
siddhi-operator
Operator allows you to run stream processing logic directly on a Kubernetes cluster
Stars: ✭ 16 (-98.35%)
Mutual labels:  operator, kubernetes-operator
Es Operator
Kubernetes Operator for Elasticsearch
Stars: ✭ 282 (-70.96%)
Mutual labels:  operator, kubernetes-operator
oracle-database-operator
The Oracle Database Operator for Kubernetes (a.k.a. OraOperator) helps developers, DBAs, DevOps and GitOps teams reduce the time and complexity of deploying and managing Oracle Databases. It eliminates the dependency on a human operator or administrator for the majority of database operations.
Stars: ✭ 74 (-92.38%)
Mutual labels:  operator, kubernetes-operator
grafana-operator
An operator for Grafana that installs and manages Grafana instances, Dashboards and Datasources through Kubernetes/OpenShift CRs
Stars: ✭ 449 (-53.76%)
Mutual labels:  operator, kubernetes-operator
Capsule
Kubernetes Operator for multi-tenancy
Stars: ✭ 261 (-73.12%)
Mutual labels:  operator, kubernetes-operator
sieve
Automatic Reliability Testing for Kubernetes Controllers
Stars: ✭ 183 (-81.15%)
Mutual labels:  operator, kubernetes-operator
Cp Ddd Framework
A lightweight flexible development framework for complex business architecture with full ecosystem!轻量级业务中台开发框架,中台架构的顶层设计和完整解决方案!
Stars: ✭ 566 (-41.71%)
Mutual labels:  framework, domain-driven-design
Kooper
Kooper is a simple Go library to create Kubernetes operators and controllers.
Stars: ✭ 388 (-60.04%)
Mutual labels:  framework, operator
mysql-operator
Asynchronous MySQL Replication on Kubernetes using Percona Server and Openark's Orchestrator.
Stars: ✭ 810 (-16.58%)
Mutual labels:  operator, kubernetes-operator
Fastapi
FastAPI framework, high performance, easy to learn, fast to code, ready for production
Stars: ✭ 39,588 (+3977.03%)
Mutual labels:  asyncio, framework
td-redis-operator
一款强大的云原生redis-operator,经过大规模生产级运行考验,支持分布式集群、支持主备切换等缓存集群解决方案…The powerful cloud-native redis-operator, which has passed the test of large-scale production-level operation, supports distributed clusters and active/standby switching ...
Stars: ✭ 327 (-66.32%)
Mutual labels:  operator, kubernetes-operator
chaos-operator
chaos engineering via kubernetes operator
Stars: ✭ 90 (-90.73%)
Mutual labels:  operator, kubernetes-operator
varnish-operator
Run and manage Varnish clusters on Kubernetes
Stars: ✭ 47 (-95.16%)
Mutual labels:  operator, kubernetes-operator
Service Level Operator
Manage application's SLI and SLO's easily with the application lifecycle inside a Kubernetes cluster
Stars: ✭ 260 (-73.22%)
Mutual labels:  operator, kubernetes-operator
microcks-ansible-operator
Kubernetes Operator for easy setup and management of Microcks installs
Stars: ✭ 21 (-97.84%)
Mutual labels:  operator, kubernetes-operator
cmak-operator
CMAK (prev. Kafka Manager) for Kubernetes
Stars: ✭ 45 (-95.37%)
Mutual labels:  operator, kubernetes-operator
Metering Operator
The Metering Operator is responsible for collecting metrics and other information about what's happening in a Kubernetes cluster, and providing a way to create reports on the collected data.
Stars: ✭ 320 (-67.04%)
Mutual labels:  operator, kubernetes-operator
Kudo
Kubernetes Universal Declarative Operator (KUDO)
Stars: ✭ 849 (-12.56%)
Mutual labels:  operator, kubernetes-operator

This repository is suspended and not maintained.

It is kept in place for historic reference, so that all links remain valid, and the issues' & PRs' discussions are preserved for debugging & investigations.

Kopf's development currently happens here:

Please send new issues and pull requests there.


Kubernetes Operator Pythonic Framework (Kopf)

Build Status codecov Coverage Status Total alerts Language grade: Python

Kopf —Kubernetes Operator Pythonic Framework— is a framework and a library to make Kubernetes operators development easier, just in few lines of Python code.

The main goal is to bring the Domain-Driven Design to the infrastructure level, with Kubernetes being an orchestrator/database of the domain objects (custom resources), and the operators containing the domain logic (with no or minimal infrastructure logic).

Documentation

Features

  • A full-featured operator in just 2 files: Dockerfile + a Python module.
  • Implicit object's status updates, as returned from the Python functions.
  • Multiple creation/update/deletion handlers to track the object handling process.
  • Update handlers for the selected fields with automatic value diffs.
  • Dynamically generated sub-handlers using the same handling tracking feature.
  • Retries of the handlers in case of failures or exceptions.
  • Easy object hierarchy building with the labels/naming propagation.
  • Built-in events for the objects to reflect their state (as seen in kubectl describe).
  • Automatic logging/reporting of the handling process (as logs + events).
  • Handling of multiple CRDs in one process.
  • The development instance temporarily suppresses the deployed ones.

Examples

See examples for the examples of the typical use-cases.

The minimalistic operator can look like this:

import kopf

@kopf.on.create('zalando.org', 'v1', 'kopfexamples')
def create_fn(spec, meta, status, **kwargs):
    print(f"And here we are! Creating: {spec}")

The keyword arguments available to the handlers:

  • body for the whole body of the handled objects.
  • spec as an alias for body['spec'].
  • meta as an alias for body['metadata'].
  • status as an alias for body['status'].
  • patch is a dict with the object changes to applied after the handler.
  • retry (int) is the sequential number of retry of this handler.
  • started (datetime.datetime) is the start time of the handler, in case of retries & errors.
  • runtime (datetime.timedelay) is the duration of the handler run, in case of retries & errors.
  • diff is a list of changes of the object (only for the update events).
  • old is the old state of the object or a field (only for the update events).
  • new is the new state of the object or a field (only for the update events).
  • logger is a per-object logger, with the messages prefixed with the object's namespace/name.
  • event is the raw event as received from the Kubernetes API.
  • cause is the processed cause of the handler as detected by the framework (create/update/delete).

**kwargs (or **_ to stop lint warnings) is required for the forward compatibility: the framework can add new keyword arguments in the future, and the existing handlers should accept them.

Usage

We assume that when the operator is executed in the cluster, it must be packaged into a docker image with CI/CD tool of your preference.

FROM python:3.7
ADD . /src
RUN pip install kopf
CMD kopf run /src/handlers.py

Where handlers.py is your Python script with the handlers (see examples/*/example.py for the examples).

See kopf run --help for others ways of attaching the handlers.

Contributing

Please read CONTRIBUTING.md for details on our process for submitting pull requests to us, and please ensure you follow the CODE_OF_CONDUCT.md.

To install the environment for the local development, read DEVELOPMENT.md.

Versioning

We use SemVer for versioning. For the versions available, see the releases on this repository.

License

This project is licensed under the MIT License — see the LICENSE file for details.

Acknowledgments

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].