{"id":13501589,"url":"https://github.com/zalando-incubator/kopf","last_synced_at":"2025-03-29T09:30:53.694Z","repository":{"id":69697663,"uuid":"177796736","full_name":"zalando-incubator/kopf","owner":"zalando-incubator","description":"A Python framework to write Kubernetes operators in just few lines of code.","archived":true,"fork":false,"pushed_at":"2020-09-14T15:58:08.000Z","size":1690,"stargazers_count":970,"open_issues_count":70,"forks_count":88,"subscribers_count":32,"default_branch":"master","last_synced_at":"2024-10-31T20:40:27.408Z","etag":null,"topics":["asyncio","domain-driven-design","framework","kubernetes","kubernetes-operator","operator","python","python3"],"latest_commit_sha":null,"homepage":"https://kopf.readthedocs.io","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/zalando-incubator.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-03-26T13:43:32.000Z","updated_at":"2024-10-25T14:17:13.000Z","dependencies_parsed_at":"2023-07-10T02:46:22.508Z","dependency_job_id":null,"html_url":"https://github.com/zalando-incubator/kopf","commit_stats":null,"previous_names":[],"tags_count":52,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zalando-incubator%2Fkopf","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zalando-incubator%2Fkopf/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zalando-incubator%2Fkopf/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zalando-incubator%2Fkopf/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zalando-incubator","download_url":"https://codeload.github.com/zalando-incubator/kopf/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246167028,"owners_count":20734377,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["asyncio","domain-driven-design","framework","kubernetes","kubernetes-operator","operator","python","python3"],"created_at":"2024-07-31T22:01:42.588Z","updated_at":"2025-03-29T09:30:53.678Z","avatar_url":"https://github.com/zalando-incubator.png","language":"Python","funding_links":[],"categories":["Python","Operator Frameworks","Kubernetes Operators","Frameworks / Libraries","HarmonyOS"],"sub_categories":["Windows Manager"],"readme":"**This repository is suspended and not maintained.**\n\nIt is kept in place for historic reference, so that all links remain valid,\nand the issues' \u0026 PRs' discussions are preserved for debugging \u0026 investigations.\n\nKopf's development currently happens here:\n\n* https://github.com/nolar/kopf\n\nPlease send new issues and pull requests there.\n\n---\n\n# Kubernetes Operator Pythonic Framework (Kopf)\n\n[![Build Status](https://travis-ci.org/zalando-incubator/kopf.svg?branch=master)](https://travis-ci.org/zalando-incubator/kopf)\n[![codecov](https://codecov.io/gh/zalando-incubator/kopf/branch/master/graph/badge.svg)](https://codecov.io/gh/zalando-incubator/kopf)\n[![Coverage Status](https://coveralls.io/repos/github/zalando-incubator/kopf/badge.svg?branch=master)](https://coveralls.io/github/zalando-incubator/kopf?branch=master)\n[![Total alerts](https://img.shields.io/lgtm/alerts/g/zalando-incubator/kopf.svg?logo=lgtm\u0026logoWidth=18)](https://lgtm.com/projects/g/zalando-incubator/kopf/alerts/)\n[![Language grade: Python](https://img.shields.io/lgtm/grade/python/g/zalando-incubator/kopf.svg?logo=lgtm\u0026logoWidth=18)](https://lgtm.com/projects/g/zalando-incubator/kopf/context:python)\n\n**Kopf** —Kubernetes Operator Pythonic Framework— is a framework and a library\nto make Kubernetes operators development easier, just in few lines of Python code. \n\nThe main goal is to bring the Domain-Driven Design to the infrastructure level,\nwith Kubernetes being an orchestrator/database of the domain objects (custom resources),\nand the operators containing the domain logic (with no or minimal infrastructure logic).\n\n\n## Documentation\n\n* https://kopf.readthedocs.io/\n\n\n## Features\n\n* A full-featured operator in just 2 files: `Dockerfile` + a Python module.\n* Implicit object's status updates, as returned from the Python functions.\n* Multiple creation/update/deletion handlers to track the object handling process.\n* Update handlers for the selected fields with automatic value diffs.\n* Dynamically generated sub-handlers using the same handling tracking feature.\n* Retries of the handlers in case of failures or exceptions.\n* Easy object hierarchy building with the labels/naming propagation.\n* Built-in _events_ for the objects to reflect their state (as seen in `kubectl describe`).\n* Automatic logging/reporting of the handling process (as logs + _events_).\n* Handling of multiple CRDs in one process.\n* The development instance temporarily suppresses the deployed ones.\n\n\n## Examples\n\nSee [examples](https://github.com/zalando-incubator/kopf/tree/master/examples)\nfor the examples of the typical use-cases.\n\nThe minimalistic operator can look like this:\n\n```python\nimport kopf\n\n@kopf.on.create('zalando.org', 'v1', 'kopfexamples')\ndef create_fn(spec, meta, status, **kwargs):\n    print(f\"And here we are! Creating: {spec}\")\n```\n\nThe keyword arguments available to the handlers:\n\n* `body` for the whole body of the handled objects.\n* `spec` as an alias for `body['spec']`.\n* `meta` as an alias for `body['metadata']`.\n* `status` as an alias for `body['status']`.\n* `patch` is a dict with the object changes to applied after the handler.\n* `retry` (`int`) is the sequential number of retry of this handler.\n* `started` (`datetime.datetime`) is the start time of the handler, in case of retries \u0026 errors.\n* `runtime` (`datetime.timedelay`) is the duration of the handler run, in case of retries \u0026 errors.\n* `diff` is a list of changes of the object (only for the update events).\n* `old` is the old state of the object or a field (only for the update events).\n* `new` is the new state of the object or a field (only for the update events).\n* `logger` is a per-object logger, with the messages prefixed with the object's namespace/name.\n* `event` is the raw event as received from the Kubernetes API.\n* `cause` is the processed cause of the handler as detected by the framework (create/update/delete).\n\n`**kwargs` (or `**_` to stop lint warnings) is required for the forward\ncompatibility: the framework can add new keyword arguments in the future,\nand the existing handlers should accept them.\n\n\n## Usage\n\nWe assume that when the operator is executed in the cluster, it must be packaged\ninto a docker image with CI/CD tool of your preference.\n\n```dockerfile\nFROM python:3.7\nADD . /src\nRUN pip install kopf\nCMD kopf run /src/handlers.py\n```\n\nWhere `handlers.py` is your Python script with the handlers\n(see `examples/*/example.py` for the examples).\n\nSee `kopf run --help` for others ways of attaching the handlers.\n\n\n## Contributing\n\nPlease read [CONTRIBUTING.md](https://github.com/zalando-incubator/kopf/blob/master/CONTRIBUTING.md)\nfor details on our process for submitting pull requests to us, and please ensure\nyou follow the [CODE_OF_CONDUCT.md](https://github.com/zalando-incubator/kopf/blob/master/CODE_OF_CONDUCT.md).\n\nTo install the environment for the local development,\nread [DEVELOPMENT.md](https://github.com/zalando-incubator/kopf/blob/master/DEVELOPMENT.md).\n\n\n## Versioning\n\nWe use [SemVer](http://semver.org/) for versioning. For the versions available,\nsee the [releases on this repository](https://github.com/zalando-incubator/kopf/releases). \n\n\n## License\n\nThis project is licensed under the MIT License —\nsee the [LICENSE](https://github.com/zalando-incubator/kopf/blob/master/LICENSE) file for details.\n\n\n## Acknowledgments\n\n* Thanks to [@side8](https://github.com/side8) and their [k8s-operator](https://github.com/side8/k8s-operator)\n  for the inspiration.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzalando-incubator%2Fkopf","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzalando-incubator%2Fkopf","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzalando-incubator%2Fkopf/lists"}