Migrating from Docker Compose to Kubernetes (Kompose & Patterns)
Map Compose services to Kubernetes objects and use Kompose thoughtfully.
In plain words
Use the migration as a mapping exercise: preserve application contracts, then redesign lifecycle and storage for a scheduler.
Think of it like…
Kompose is a language translator; it preserves rough sentences, but legal and operational idioms still need a native Kubernetes writer.
Where you’ve seen it
In practice, kompose convert -f compose.yaml --out k8s/; kubectl apply --dry-run=server -f k8s/ is the concrete move for this job: map Compose services to Kubernetes objects and use Kompose thoughtfully. The release is not accepted until compare generated Deployment replicas, readiness/liveness, Service selectors, PVC storageClass and Secret references to the Compose intent confirms the result.
Words you’ll hear
- Kompose
- The implementation control in
kompose convert -f compose.yaml --out k8s/; kubectl apply --dry-run=server -f k8s/for map Compose services to Kubernetes objects and use Kompose thoughtfully. - Deployments
- The result to observe with
compare generated Deployment replicas, readiness/liveness, Service selectors, PVC storageClass and Secret references to the Compose intent, rather than infer from a successful command alone. - Migration
- The production boundary exposed when applying generated YAML without readiness probes and PVC migration, or assuming one Compose volume automatically has multi-node durability.
Visual diagram
Theory & deep dive
Kompose control path
The concrete mechanism is kompose convert -f compose.yaml --out k8s/; kubectl apply --dry-run=server -f k8s/. The observable result is compare generated Deployment replicas, readiness/liveness, Service selectors, PVC storageClass and Secret references to the Compose intent; if those disagree, inspect the runtime evidence before changing unrelated settings.
Map Compose services to Kubernetes objects and use Kompose thoughtfully. Keep Kompose, Deployments and Migration in the same deployment record so the intent and the observed state cannot drift apart.
kompose convert -f compose.yaml --out k8s/; kubectl apply --dry-run=server -f k8s/
compare generated Deployment replicas, readiness/liveness, Service selectors, PVC storageClass and Secret references to the Compose intent, not with command success alone.Migration failure boundary
Compose depends_on has no direct Kubernetes ordering guarantee, container_name is not an object name policy, and local named volumes do not become durable cluster storage. A blind Kompose output also carries development ports and credentials. The narrow failure to design for is applying generated YAML without readiness probes and PVC migration, or assuming one Compose volume automatically has multi-node durability.
Accept this compromise explicitly: Automated conversion is a strong inventory starter; hand-designed Kubernetes manifests or a Helm/chart pipeline support cluster policy better. The controlled check-compare generated Deployment replicas, readiness/liveness, Service selectors, PVC storageClass and Secret references to the Compose intent-also identifies the point where a different design is safer.
Exercise this failure safely: applying generated YAML without readiness probes and PVC migration, or assuming one Compose volume automatically has multi-node durability.
How it works, step by step
Step 1 of 41. State the boundary
Write down why the workload needs this: Compose depends_on has no direct Kubernetes ordering guarantee, container_name is not an object name policy, and local named volumes do not become durable cluster storage. A blind Kompose output also carries development ports and credentials.
- Intent
- Kompose
When to use it & trade-offs
What it is
Kompose can translate Compose services into Kubernetes objects, but networking, scaling, health, secrets and persistence require platform-specific review. A Service exposes Pods, a Deployment owns desired replicas, ConfigMaps/Secrets inject config, and PersistentVolumeClaims request storage.
Why it matters: Compose depends_on has no direct Kubernetes ordering guarantee, container_name is not an object name policy, and local named volumes do not become durable cluster storage. A blind Kompose output also carries development ports and credentials.
When to reach for it
- The fit is strongest for this job: map Compose services to Kubernetes objects and use Kompose thoughtfully. Pair it with
compare generated Deployment replicas, readiness/liveness, Service selectors, PVC storageClass and Secret references to the Compose intentin the runbook. - Production Kompose changes should make Deployments observable through
kompose convert -f compose.yaml --out k8s/; kubectl apply --dry-run=server -f k8s/, rather than trusting the runtime default. - Keep a rollback example for the case where applying generated YAML without readiness probes and PVC migration, or assuming one Compose volume automatically has multi-node durability.
When to avoid or be careful
- Do not accept command success while the system can still fail by applying generated YAML without readiness probes and PVC migration, or assuming one Compose volume automatically has multi-node durability.
- Avoid erasing Migration protection merely to dodge this cost: “Automated conversion is a strong inventory starter; hand-designed Kubernetes manifests or a Helm/chart pipeline support cluster policy better”.
- Do not replace the evidence path-
compare generated Deployment replicas, readiness/liveness, Service selectors, PVC storageClass and Secret references to the Compose intent-with a screenshot or a mutable tag.
kompose convert -f compose.yaml --out k8s/; kubectl apply --dry-run=server -f k8s/: practical choices
Strengths: Kompose can translate Compose services into Kubernetes objects, but networking, scaling, health, secrets and persistence require platform-specific review. A Service exposes Pods, a Deployment owns desired replicas, ConfigMaps/Secrets inject config, and PersistentVolumeClaims request storage.
Watch out: Automated conversion is a strong inventory starter; hand-designed Kubernetes manifests or a Helm/chart pipeline support cluster policy better.
Strengths: It can begin with kompose convert -f compose.yaml --out k8s/; kubectl apply --dry-run=server -f k8s/ and fewer surrounding controls.
Watch out: It silently accepts applying generated YAML without readiness probes and PVC migration, or assuming one Compose volume automatically has multi-node durability, which makes the result hard to reproduce after promotion.
Strengths: Compose depends_on has no direct Kubernetes ordering guarantee, container_name is not an object name policy, and local named volumes do not become durable cluster storage. A blind Kompose output also carries development ports and credentials.
Watch out: The platform adds an ownership and debugging layer; retain compare generated Deployment replicas, readiness/liveness, Service selectors, PVC storageClass and Secret references to the Compose intent as the direct check.
Interview signals & numbers to know
When this topic comes up
- kompose convert -f compose.yaml --out k8s/; kubectl apply --dry-run=server -f k8s/
- compare generated Deployment replicas, readiness/liveness, Service selectors, PVC storageClass and Secret references to the Compose intent
- Failure signature: applying generated YAML without readiness probes and PVC migration, or assuming one Compose volume automatically has multi-node durability
- Trade-off: Automated conversion is a strong inventory starter; hand-designed Kubernetes manifests or a Helm/chart pipeline support cluster policy better.
Benchmarks & rules of thumb
- 4 core mappings
- service→workload+Service, volume→PVC, env→ConfigMap/Secret
- 1 scheduler
- replaces Compose’s one-host controller
- 0 direct depends_on contract
- in ordinary Deployment readiness
Common mistakes & follow-ups
Common interview mistakes
- Treating a successful
kompose convert -f compose.yaml --out k8s/; kubectl apply --dry-run=server -f k8s/as proof and skippingcompare generated Deployment replicas, readiness/liveness, Service selectors, PVC storageClass and Secret references to the Compose intent. - Applying generated YAML without readiness probes and PVC migration, or assuming one Compose volume automatically has multi-node durability
- Optimizing Kompose without accepting that automated conversion is a strong inventory starter; hand-designed Kubernetes manifests or a Helm/chart pipeline support cluster policy better.
Likely interviewer follow-ups
- Why does
kompose convert -f compose.yaml --out k8s/; kubectl apply --dry-run=server -f k8s/address Kompose here rather than through application code? - How would you distinguish healthy Deployments from the failure “applying generated YAML without readiness probes and PVC migration, or assuming one Compose volume automatically has multi-node durability” using
compare generated Deployment replicas, readiness/liveness, Service selectors, PVC storageClass and Secret references to the Compose intent? - When would this trade-off-“Automated conversion is a strong inventory starter; hand-designed Kubernetes manifests or a Helm/chart pipeline support cluster policy better”-justify a different Migration design?
kompose convert -f compose.yaml --out k8s/; kubectl apply --dry-run=server -f k8s/-and one proof-compare generated Deployment replicas, readiness/liveness, Service selectors, PVC storageClass and Secret references to the Compose intent. Then name the boundary: applying generated YAML without readiness probes and PVC migration, or assuming one Compose volume automatically has multi-node durability.Knowledge check
Put it into practice
Practice related interview Q&A
Apply Migrating from Docker Compose to Kubernetes (Kompose & Patterns) with generative AI interview Q&A and hands-on practice.