{"id":13468632,"url":"https://github.com/kr8s-org/kr8s","last_synced_at":"2025-05-14T01:08:10.178Z","repository":{"id":154205569,"uuid":"615259748","full_name":"kr8s-org/kr8s","owner":"kr8s-org","description":"A batteries-included Python client library for Kubernetes that feels familiar for folks who already know how to use kubectl","archived":false,"fork":false,"pushed_at":"2025-05-13T09:21:16.000Z","size":3932,"stargazers_count":887,"open_issues_count":39,"forks_count":49,"subscribers_count":8,"default_branch":"main","last_synced_at":"2025-05-13T10:32:28.742Z","etag":null,"topics":["asyncio","devops-tools","hacktoberfest","k8s","kr8s","kubectl","kubernetes","kubernetes-client","kubernetes-python-client","python","pythonic","sync","trio"],"latest_commit_sha":null,"homepage":"https://kr8s.org","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/kr8s-org.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"docs/contributing.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2023-03-17T09:51:02.000Z","updated_at":"2025-05-13T09:21:19.000Z","dependencies_parsed_at":"2024-02-20T12:29:26.924Z","dependency_job_id":"51bec901-75ca-4112-8571-c625a325b179","html_url":"https://github.com/kr8s-org/kr8s","commit_stats":null,"previous_names":[],"tags_count":88,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kr8s-org%2Fkr8s","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kr8s-org%2Fkr8s/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kr8s-org%2Fkr8s/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kr8s-org%2Fkr8s/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kr8s-org","download_url":"https://codeload.github.com/kr8s-org/kr8s/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253927024,"owners_count":21985615,"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","devops-tools","hacktoberfest","k8s","kr8s","kubectl","kubernetes","kubernetes-client","kubernetes-python-client","python","pythonic","sync","trio"],"created_at":"2024-07-31T15:01:15.406Z","updated_at":"2025-05-14T01:08:05.164Z","avatar_url":"https://github.com/kr8s-org.png","language":"Python","funding_links":[],"categories":["Python"],"sub_categories":[],"readme":"\u003cdiv style=\"text-align: center; width: 100%;\"\u003e\u003cimg src=\"https://github.com/kr8s-org/kr8s/raw/v0.17.2/branding/logo-wide.png\" style=\"max-height: 200px;\" /\u003e\u003c/div\u003e\n\n[![Test](https://github.com/kr8s-org/kr8s/actions/workflows/test-kr8s.yaml/badge.svg)](https://github.com/kr8s-org/kr8s/actions/workflows/test.yaml)\n[![Codecov](https://img.shields.io/codecov/c/gh/kr8s-org/kr8s?logo=codecov\u0026logoColor=ffffff)](https://app.codecov.io/gh/kr8s-org/kr8s)\n[![pre-commit.ci status](https://results.pre-commit.ci/badge/github/kr8s-org/kr8s/main.svg)](https://results.pre-commit.ci/latest/github/kr8s-org/kr8s/main)\n[![Read the Docs](https://img.shields.io/readthedocs/kr8s?logo=readthedocs\u0026logoColor=white)](https://docs.kr8s.org/en/stable/)\n[![EffVer Versioning](https://img.shields.io/badge/version_scheme-EffVer-0097a7)](https://jacobtomlinson.dev/effver)\n[![PyPI](https://img.shields.io/pypi/v/kr8s)](https://pypi.org/project/kr8s/)\n[![Python Version Support](https://img.shields.io/badge/Python%20support-3.9%7C3.10%7C3.11%7C3.12-blue)](https://pypi.org/project/kr8s/)\n[![Kubernetes Version Support](https://img.shields.io/badge/Kubernetes%20support-1.30%7C1.31%7C1.32-blue)](https://docs.kr8s.org/en/stable/installation.html#supported-kubernetes-versions)\n[![PyPI - Wheel](https://img.shields.io/pypi/wheel/kr8s)](https://pypi.org/project/kr8s/)\n[![PyPI - License](https://img.shields.io/pypi/l/kr8s)](https://pypi.org/project/kr8s/)\n\nA simple, extensible Python client library for Kubernetes that feels familiar for folks who already know how to use `kubectl`.\n\n## Highlights\n\n- API inspired by `kubectl` for a shallow learning curve.\n- [Sensible defaults](https://docs.kr8s.org/en/stable/authentication.html) to reduce boiler plate.\n- No swagger generated code, human readable code only.\n- Has both a standard and an [async API](https://docs.kr8s.org/en/stable/asyncio.html) that can be used with `asyncio` and `trio`.\n- [Client caching](https://docs.kr8s.org/en/stable/client.html#client-caching) to reduce passing API objects around.\n- Batteries included by providing [useful utilities and methods](https://docs.kr8s.org/en/stable/examples/pod_operations.html) inspired by `kubectl`.\n\n## Quickstart\n\n### Installation\n\n```console\n$ pip install kr8s\n```\n\n## Examples\n\n\u003e [!TIP]\n\u003e See the [Examples Documentation](https://docs.kr8s.org/en/stable/examples/) for a full set of examples including `asyncio` examples.\n\n### List Nodes\n\nPrint out all of the node names in the cluster.\n\n```python\nimport kr8s\n\nfor node in kr8s.get(\"nodes\"):\n    print(node.name)\n```\n\n### Create a Pod\n\nCreate a new Pod.\n\n```python\nfrom kr8s.objects import Pod\n\npod = Pod({\n        \"apiVersion\": \"v1\",\n        \"kind\": \"Pod\",\n        \"metadata\": {\n            \"name\": \"my-pod\",\n        },\n        \"spec\": {\n            \"containers\": [{\"name\": \"pause\", \"image\": \"gcr.io/google_containers/pause\",}]\n        },\n    })\n\npod.create()\n```\n\n### Scale a Deployment\n\nScale the Deployment `metrics-server` in the Namespace `kube-system` to `1` replica.\n\n```python\nfrom kr8s.objects import Deployment\n\ndeploy = Deployment.get(\"metrics-server\", namespace=\"kube-system\")\ndeploy.scale(1)\n```\n\n### List Pods by label selector\n\nGet all Pods from all Namespaces matching a label selector.\n\n```python\nimport kr8s\n\nselector = {'component': 'kube-scheduler'}\n\nfor pod in kr8s.get(\"pods\", namespace=kr8s.ALL, label_selector=selector):\n    print(pod.namespace, pod.name)\n```\n\n### Add a label to a Pod\n\nAdd the label `foo` with the value `bar` to an existing Pod.\n\n```python\nfrom kr8s.objects import Pod\n\npod = Pod(\"kube-apiserver\", namespace=\"kube-system\")\npod.label({\"foo\": \"bar\"})\n```\n\n### Generate a Pod\n\nGenerate a simple Pod with a couple of keyword arguments.\n\n```python\nfrom kr8s.objects import Pod\n\npod = Pod.gen(name=\"example-1\", image=\"nginx:latest\")\npod.create()\n```\n\n### Cordon a Node\n\nCordon a Node to mark it as unschedulable.\n\n```python\nfrom kr8s.objects import Node\n\nnode = Node(\"k8s-node-1\")\n\nnode.cordon()\n```\n\n### Pod Exec\n\nExec a command in a Pod.\n\n```python\nfrom kr8s.objects import Pod\n\npod = Pod.get(\"my-pod\")\n\ncommand = pod.exec([\"uptime\"])\nprint(command.stdout.decode())\n# 13:49:05 up 23:03,  0 users,  load average: 0.66, 0.87, 0.85\n```\n\n### Port forward a Pod\n\nOpen a port forward to a Pod as a background task/thread.\n\n```python\nfrom kr8s.objects import Pod\n\npod = Pod.get(\"my-pod\")\npf = pod.portforward(remote_port=1234, local_port=5678)\n\n# Starts the port forward in a background thread\npf.start()\n\n# Your other code goes here\n\n# Optionally stop the port forward thread (it will exit with Python anyway)\npf.stop()\n```\n\n\u003e [!TIP]\n\u003e See the [Examples Documentation](https://docs.kr8s.org/en/stable/examples/) for a full set of examples including `asyncio` examples.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkr8s-org%2Fkr8s","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkr8s-org%2Fkr8s","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkr8s-org%2Fkr8s/lists"}