{"id":27941276,"url":"https://github.com/editd/kubetools","last_synced_at":"2025-05-07T10:38:54.268Z","repository":{"id":37796600,"uuid":"168360866","full_name":"EDITD/kubetools","owner":"EDITD","description":":nut_and_bolt:   Kubetools is a tool and processes for developing and deploying microservices to Kubernetes.","archived":false,"fork":false,"pushed_at":"2024-12-18T09:57:51.000Z","size":661,"stargazers_count":14,"open_issues_count":26,"forks_count":2,"subscribers_count":17,"default_branch":"master","last_synced_at":"2025-04-19T08:14:56.434Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","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/EDITD.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.md","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}},"created_at":"2019-01-30T14:57:16.000Z","updated_at":"2024-12-18T09:57:53.000Z","dependencies_parsed_at":"2023-12-05T13:27:20.503Z","dependency_job_id":"79f843bd-d356-41eb-ae71-3780a7977516","html_url":"https://github.com/EDITD/kubetools","commit_stats":null,"previous_names":[],"tags_count":51,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EDITD%2Fkubetools","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EDITD%2Fkubetools/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EDITD%2Fkubetools/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EDITD%2Fkubetools/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/EDITD","download_url":"https://codeload.github.com/EDITD/kubetools/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252861288,"owners_count":21815651,"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":[],"created_at":"2025-05-07T10:38:52.828Z","updated_at":"2025-05-07T10:38:54.259Z","avatar_url":"https://github.com/EDITD.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"![Build Status](https://github.com/EDITD/kubetools/actions/workflows/run_tests.yml/badge.svg?branch=master)\n[![Pypi Version](https://img.shields.io/pypi/v/kubetools.svg)](https://pypi.org/project/kubetools/)\n[![Python Versions](https://img.shields.io/pypi/pyversions/kubetools.svg)](https://pypi.org/project/kubetools/)\n\n# Kubetools\n\nKubetools is a tool and processes for developing and deploying microservices to Kubernetes. Say that:\n\n+ You have **a bunch of repositories, each containing one or more microservices**\n+ You want to **deploy each of these microservices into one or more Kubernetes clusters**\n+ You want a **single configuration file per project** (repository)\n\nAnd you would like:\n\n+ **Development setup should be near-instant** - and _not_ require specific K8s knowledge\n+ **Deployment to production can be automated** - and integrated with existing CI tooling\n\nKubetools provides the tooling required to achieve this, by way of two CLI tools:\n\n+ **`ktd`**: generates _100% local_ development environments using Docker/docker-compose\n+ **`kubetools`**: deploys projects to Kubernetes, handling any changes/jobs as required\n\nBoth of these use a single configuration file, `kubetools.yml`, for example a basic `django` app:\n\n```yaml\nname: my-app\n\ncontainerContexts:\n  django_app:\n    build:\n      registry: my-registry.net\n      dockerfile: Dockerfile\n    dev:\n      volumes:\n        - ./:/opt/django_app\n\nupgrades:\n  - name: Upgrade database\n    containerContext: django_app\n    command: [./manage.py, migrate, --noinput]\n\ntests:\n  - name: Nosetests\n    containerContext: django_app\n    command: [./manage.py, test]\n\ndeployments:\n  my-app-webserver:\n    annotations:\n      imageregistry: \"https://hub.docker.com/\"\n    labels:\n      app.kubernetes.io/name: my-app-webserver\n    serviceAccountName: webserver\n    secrets:\n      secret-volume:\n        mountPath: /mnt/secrets-store\n        secretProviderClass: webserver-secrets\n    containers:\n      uwsgi:\n        command: [uwsgi, --ini, /etc/uwsgi.conf]\n        containerContext: django_app\n        ports:\n          - 80\n        dev:\n          command: [./manage.py, runserver, '0.0.0.0:80']\n\ndependencies:\n  mariadb:\n    containers:\n      mariadb:\n        image: mariadb:v10.4.1\n\ncronjobs:\n  my-cronjob:\n    batch-api-version: 'batch/v1beta1'  # Must add if k8s version \u003c 1.21+\n    schedule: \"*/1 * * * *\"\n    concurrency_policy: \"Replace\"\n    containers:\n      hello:\n        image: busybox\n        command: [/bin/sh, -c, date; echo Hello from the Kubernetes cluster]\n```\n\nWith this in your current directory, you can now:\n\n```sh\n# Bring up a local development environment using docker-compose\nktd up\n\n# Deploy the project to a Kubernetes namespace\nkubetools deploy my-namespace\n```\n\n## Installing\n\n```sh\npip install kubetools\n```\n\n**NOTE**: Since Cython 3.0 was released, the installation of `kubetools` dependencies will fail\n due to compatibility issues between Cython 3 and PyYaml (see\n [this issue](https://github.com/yaml/pyyaml/issues/601)). This can be worked around for example\n with `pip` by using a \"constraints\" file containing `cython\u003c3`.\n\n## Configuration\nUsers can configure some aspects of `kubetools`. The configuration folder location depends on the\noperating system of the user. See the\n[Click documentation](https://click.palletsprojects.com/en/8.1.x/api/#click.get_app_dir)\nto find the appropriate one for you. Note that we use the \"POSIX\" version (for example\n`~/.kubetools/` on Unix systems).\n* `kubetools.conf` contains key-value settings, see [`settings.py`](kubetools/settings.py) for the\n  possible settings and their meaning.\n* `scripts/` can contain scripts to be made available to `ktd script` command\n\n## Developing\n\nInstall the package in editable mode, with the dev extras:\n\n```sh\npip install -e .[dev]\n```\n\n## Local deployment testing\n\nFor deployment testing, you will need a kubernetes cluster and a docker registry. You can get both\neasily using `minikube`:\n```shell\nminikube start --addons registry --insecure-registry ${MINIKUBE_IP}:5000\n```\nThen you can deploy to that environment:\n```shell\nkubetools --context minikube deploy --default-registry ${MINIKUBE_IP}:5000 default .\n```\n\n`MINIKUBE_IP` value can vary depending on your local environment. The easiest way to get the correct\nvalue is to start minikube once then reset it:\n```shell\nminikube start\nMINIKUBE_IP=$(minikube ip)\nminikube delete\n...\n```\n\n## Releasing (admins/maintainers only)\n* Update [CHANGELOG](CHANGELOG.md) to add new version and document it\n* In GitHub, create a new release\n  * Title the release `v\u003cversion\u003e` (for example `v1.2.3`)\n  * Select to create a new tag `v\u003cversion\u003e` against `master` branch\n  * Copy changes in the release from `CHANGELOG.md` into the release description\n  * [GitHub Actions](https://github.com/EDITD/kubetools/actions) will package the release and\n    publish it to [Pypi](https://pypi.org/project/kubetools/)\n\n## Mounting K8s Secrets\nWe assume that `ServiceAccount` and `SecretProviderClass` are already created (if needed), before deploying the project with kubetools.\n\n## Docker build args\n`kubetools` now supports passing values for `ARG` parameters used in Dockerfiles, using\n`--build-args`. This has a couple of caveats though:\n* it is NOT supported in `ktd`. A workaround for this is to use the default value of the `ARG`\n  instruction.\n* this doesn't affect the image tag pushed to the docker registry, which is based only on the git\n  commit hash. This means that these arguments cannot be used to generate multiple images from the\n  same Dockerfile. So their main usage should be to pass secrets that should not be recorded in the\n  git repository but are needed at build time, to access external resources for example.\n* these values could be recorded in the docker image layer history. To prevent leaking secrets, you\n  should consider using multi-stage builds where the secrets are only used in a \"builder\" image.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feditd%2Fkubetools","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Feditd%2Fkubetools","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feditd%2Fkubetools/lists"}