Kompose is a CLI utility that translates docker-compose.yml files into native Kubernetes objects such as Deployments, Services, and PVCs. It eliminates the manual work of rewriitng Compose declarations into YAML manifests.
Installation
# Linux
curl -L https://github.com/kubernetes/kompose/releases/latest/download/kompose-linux-amd64 -o kompose
chmod +x kompose
sudo mv kompose /usr/local/bin/
# macOS
curl -L https://github.com/kubernetes/kompose/releases/latest/download/kompose-darwin-amd64 -o kompose
chmod +x kompose
sudo mv kompose /usr/local/bin/
# Windows (PowerShell)
curl.exe -L https://github.com/kubernetes/kompose/releases/latest/download/kompose-windows-amd64.exe -o kompose.exe
Example Workflow
Compose File
version: "3"
services:
cache:
image: redis:7-alpine
ports:
- "6379"
backend:
image: ghcr.io/example/api:latest
depends_on:
- cache
environment:
- REDIS_HOST=cache
ports:
- "8080:8080"
labels:
kompose.service.type: LoadBalancer
Deploy Immediately
$ kompose up
INFO Creating Kubernetes resources ...
INFO Successfully created Service: cache
INFO Successfully created Service: backend
INFO Successfully created Deployment: cache
INFO Successfully created Deployment: backend
Generate Manifests Only
$ kompose convert
INFO Writing file cache-service.yaml
INFO Writing file backend-service.yaml
INFO Writing file cache-deployment.yaml
INFO Writing file backend-deployment.yaml
The genreated YAML files can be reviewed, edited, and applied with kubectl apply -f.