# Kompose — Convert Docker Compose to Kubernetes > An official Kubernetes tool that translates Docker Compose files into Kubernetes Deployments, Services, and PersistentVolumeClaims in a single command. ## Install Save as a script file and run: # Kompose — Convert Docker Compose to Kubernetes ## Quick Use ```bash # Install on macOS brew install kompose # Install on 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/ # Convert and apply kompose convert kubectl apply -f . ``` ## Introduction Kompose bridges the gap between Docker Compose and Kubernetes. Teams that prototyped with Compose can migrate to Kubernetes without manually rewriting manifests, letting Kompose handle the translation of services, volumes, and networks into native K8s resources. ## What Kompose Does - Converts docker-compose.yml into Kubernetes Deployments and Services - Maps Compose volumes to PersistentVolumeClaims automatically - Supports output as standard YAML, Helm charts, or OpenShift resources - Handles Compose v2 and v3 file formats including build directives - Provides a `kompose up` shortcut that converts and deploys in one step ## Architecture Overview Kompose is a Go CLI that parses Docker Compose files using the official Compose library, builds an intermediate object model, then transforms each service into the corresponding Kubernetes resource types. A provider abstraction allows swapping the output target between Kubernetes, OpenShift, and Helm. ## Self-Hosting & Configuration - Single binary install with no dependencies on Docker or Compose CLI - Add labels like `kompose.service.type: LoadBalancer` in Compose to customize output - Control replica count with `kompose.service.replicas` label - Use `--volumes hostPath` flag for local dev or `persistentVolumeClaim` for production - Integrate into CI to auto-generate manifests from a Compose source of truth ## Key Features - Official Kubernetes SIG project maintained under kubernetes/kompose - Outputs Helm v3 charts with `--chart` flag for templated deployments - Supports OpenShift DeploymentConfig and Route generation - Preserves environment variables, secrets, and config references - Handles depends_on ordering with init containers when needed ## Comparison with Similar Tools - **kubectl create** — manual manifest writing, no Compose import path - **Docker Desktop K8s** — runs Compose on K8s but not portable manifests - **Podman Compose** — runs Compose files natively, doesn't produce K8s YAML - **Helm** — template engine for K8s, but requires writing charts from scratch - **Skaffold** — dev workflow tool, doesn't convert Compose to manifests ## FAQ **Q: Does Kompose support Compose v3 deploy keys?** A: Yes. It maps `deploy.replicas`, resource limits, and restart policies to equivalent Kubernetes spec fields. **Q: Can I customize the generated Kubernetes resource names?** A: Yes. Use Compose labels prefixed with `kompose.` to override service type, expose settings, image pull policy, and more. **Q: Will Kompose handle my build directives?** A: Kompose converts the runtime configuration. Build directives are noted but you still need a separate image build step like `docker build` or Kaniko. **Q: Is Kompose suitable for production migrations?** A: It is a great starting point. Review the generated manifests and tune resource requests, health checks, and ingress rules for production readiness. ## Sources - https://github.com/kubernetes/kompose - https://kompose.io --- Source: https://tokrepo.com/en/workflows/062f66b1-397e-11f1-9bc6-00163e2b0d79 Author: Script Depot