Skip to main content

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 your docker-compose.yaml file
  • docker-compose-like features
    • kube-compose up => helm install/upgrade + volume create (pvc)
    • kube-compose down => helm uninstall
    • kube-compose ps => helm status
    • kube-compose logs SERVICE => kubectl logs
    • kube-compose exec SERVICE => kubectl exec
    • kube-compose restart SERVICE => kubectl rollout restart
    • kube-compose top SERVICE => kubectl exec pod -- cat /proc/*/stats
    • kube-compose stats SERVICE => kubectl top pod
    • kube-compose events SERVICE => kubectl events
    • kube-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 list
    • kube-compose template => helm template
    • kube-compose history => helm history
    • kube-compose status => helm status
    • kube-compose get WHAT => helm get WHAT
    • kube-compose rollback REVISION => helm rollback REVISION
  • additional features
    • kube-compose volume ... => manage docker-compose defined volumes as persistent volume claims
      • kube-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.yaml
    • kube-compose port-forward SERVICE local:remote

Pre-requisites

  • kubernetes cluster
  • kubectl
  • helm
  • docker-compose

Usage

# use right away with uvx
uvx kube-compose --help

# install as cli with pipx
pipx install kube-compose
kube-compose --help

# install off of pypi
pip install kube-compose

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 --context k3d-k3s-default
# 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

Metadata

Release files for kube-compose 0.11.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for kube-compose 0.11.5
File Size Uploaded Provenance Actions
kube_compose-0.11.5.tar.gz 19.8 kB Without provenance Details for kube_compose-0.11.5.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for kube-compose 0.11.5
File Interpreter ABI Platform Actions
kube_compose-0.11.5-py3-none-any.whl Python 3 none any Details for kube_compose-0.11.5-py3-none-any.whl

Total release size: 56.6 kB

Release files / kube_compose-0.11.5.tar.gz

Download URL kube_compose-0.11.5.tar.gz
Size 19.8 kB
Tags Source
SHA-256 checksum
How to use checksums
dd0ec70e4f867351c1468f80d586b3788023ea358bd99033750ebcfdc28a6430
BLAKE2b-256 checksum
How to use checksums
177a365d8319eb804ca89b7aac27fcb988ce23a3648a3d8a9529852982ab0b33
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.1.3 CPython/3.9.6 Darwin/27.0.0

Release files / kube_compose-0.11.5-py3-none-any.whl

Download URL kube_compose-0.11.5-py3-none-any.whl
Size 36.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
364c44ece1a47f3e366c2ced4b7ec463e2b6723f9986e3f603947838dd4f8f46
BLAKE2b-256 checksum
How to use checksums
4736120659938e8c45c9cbd9c42eac8ea16ffdd23f08b13b3e1ae010328b1ce4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.1.3 CPython/3.9.6 Darwin/27.0.0

Security for kube-compose 0.11.5

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page