An opinionated way of deploying docker-compose to kubernetes clusters by managing them with a helm chart.
Project description
kube-compose
An opinionated way of deploying docker-compose to kubernetes clusters by managing them with a helm chart.
The CLI is intended to be easy to use for those familiar with docker-compose and includes some additional features. Basically all features expect you to have a docker-compose.yaml file in the working directory.
kube-compose init=> specify the helm release name/namespace in yourdocker-compose.yamlfile- docker-compose-like features
kube-compose up=>helm install/upgrade+ volume create (pvc)kube-compose down=>helm uninstallkube-compose ps=>helm statuskube-compose logs SERVICE=>kubectl logskube-compose exec SERVICE=>kubectl execkube-compose restart SERVICE=>kubectl rollout restartkube-compose top SERVICE=>kubectl exec pod -- cat /proc/*/statskube-compose stats SERVICE=>kubectl top podkube-compose events SERVICE=>kubectl eventskube-compose start SERVICE=>kubectl scale --replicas={compose_defined}kube-compose scale SERVICE=>kubectl scale --replicas={user_specified}kube-compose stop SERVICE=>kubectl scale --replicas=0
- helm-like features
kube-compose ls=>helm listkube-compose template=>helm templatekube-compose history=>helm historykube-compose status=>helm statuskube-compose get WHAT=>helm get WHATkube-compose rollback REVISION=>helm rollback REVISION
- additional features
kube-compose volume ...=> manage docker-compose defined volumes as persistent volume claimskube-compose volume create [VOLUME]=> create the claim(s)kube-compose volume rm [VOLUME]=> delete the claim(s)
kube-compose diff=>diff -Naur <(helm get values) <(docker-compose config)kube-compose drift=>helm template | kubectl diff -f -kube-compose version SERVICE [<newversion> | major | minor | patch]=> like npm version but for services in the docker-compose.yamlkube-compose port-forward SERVICE local:remote
Pre-requisites
- kubernetes cluster
- kubectl
- helm
- docker-compose
Installation
# install off of pypi
pip install kube-compose
# verify install was successful
kube-compose --help
CLI Usage with Docker
# Assuming your kubeconfig is at the default location ~/.kube/config
alias kube-compose="docker run -v .:/work -v ~/.kube/config:/work/.kube/config -it u8sand/kube-compose"
# verify install was successful
kube-compose --help
End-to-end Example with K3D
# launch a test kubernetes cluster
k3d cluster create -a1 -p "80:80@loadbalancer" -p "443:443@loadbalancer"
# one option for auto-creating Ingress resources from annotations on the deployment
helm repo add maayanlab https://maayanlab.github.io/helm-charts
helm install kubernetes-auto-ingress maayanlab/kubernetes-auto-ingress --set ingressClassName=traefik
# with one of the unit tests
cd tests/units/simple
# OR for testing the current source base
# alias kube-compose="python -m kube_compose -f tests/units/simple/docker-compose.yaml"
# start the docker-compose service(s) on the kubernetes cluster
kube-compose up
# check the status of the kubernetes resources
kube-compose ps
# check logs of a service
kube-compose logs test-web
# get into the service container
kube-compose exec -it test-web /bin/sh
# restart a service
kube-compose restart test-web
# see top processes running on the service
kube-compose top test-web
# see cpu/memory being used by the service
kube-compose stats test-web
# see any events that may have occurred for the service
kube-compose events test-web
# stop the service temporarily
kube-compose stop test-web
# start it back up
kube-compose start test-web
# scale the service up
kube-compose scale test-web=2
# we can see helm charts (like kube-compose deployed things) deployed to the cluster with
kube-compose ls
# we can get the actual deployment kubernetes would use with
kube-compose template
# we can see what revision we're at/when it was updated with
kube-compose history
kube-compose status
# we can rollback (with optional version number) if a change we made was bad with
kube-compose rollback
# we can get information like the docker-compose.yaml that was deployed with
kube-compose get values
# we can access cluster services locally with port-forward hostport:containerport
kube-compose port-forward test-web 8080:80
# we can manage persistent volumes with the volume subcommand
kube-compose volume ls
# we can version image in the docker-compose
kube-compose version test-web 1.0.0
# we can diff our local docker-compose with the one that is deployed
kube-compose diff
# we can use drift to see if the deployment spec has been modified outside of kube-compose
kube-compose drift
# let's revert that change
kube-compose version test-web latest
# remove it from the cluster (with volumes, otherwise they stay)
kube-compose down -v
# remove test cluster
k3d cluster delete
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file kube_compose-0.7.0.tar.gz.
File metadata
- Download URL: kube_compose-0.7.0.tar.gz
- Upload date:
- Size: 19.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.5 CPython/3.8.18 Linux/6.15.3-arch1-1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b40a9f16712f81225c5744ee6d9529bc67f07df5cd8f6bd8f596e691e1ab1c2d
|
|
| MD5 |
3008157a82f9c3939f7e782ac8b81a1c
|
|
| BLAKE2b-256 |
c25808f19b0c4332a01b9b0f2868c1040ae36a56e2a4cb2e9b006c90a3cca4ce
|
File details
Details for the file kube_compose-0.7.0-py3-none-any.whl.
File metadata
- Download URL: kube_compose-0.7.0-py3-none-any.whl
- Upload date:
- Size: 34.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.5 CPython/3.8.18 Linux/6.15.3-arch1-1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
93a9a818e954f07976fb33cc5b9518cc75bbc56135f9bb877202f317c2d8afe1
|
|
| MD5 |
30492540e19595be1e754086f65e5d12
|
|
| BLAKE2b-256 |
4fe38147a4c8f40f93b1b7b07b14613f66bc2afd2b0b0e50c8207bc64e316bd3
|