Docker Compose to Kubernetes: Step-by-Step Migration

Why Move from Docker Compose to Kubernetes?

Compose’s Single-Cluster Limitation

Compose’s Single Point of Failure

Kubernetes Extensibility

Kubernetes Open Source Support and Large Ecosystem

Step-by-Step Migration

Docker Compose Configuration

version: "3.3"
services:
client:
image: 'lukondefmwila/dkr-multicontainer-app-client'
#build:
# dockerfile: Dockerfile
# context: ./client
restart: on-failure
container_name: client
ports:
- '3000:3000'
backend:
image: 'lukondefmwila/dkr-multicontainer-app-backend'
#build:
# dockerfile: Dockerfile
# context: ./backend
restart: on-failure
container_name: backend
ports:
- '3001:3001'
docker-compose up

Modifying the Docker Compose File

labels:
kompose.service.type: LoadBalancer

Install Kompose

# Linux
curl -L https://github.com/kubernetes/kompose/releases/download/v1.22.0/kompose-linux-amd64 -o kompose

# macOS
curl -L https://github.com/kubernetes/kompose/releases/download/v1.22.0/kompose-darwin-amd64 -o kompose

chmod +x kompose
sudo mv ./kompose /usr/local/bin/kompose

Create Kubernetes Manifests with Kompose

kompose convert
INFO Kubernetes file "client-service.yaml" created 
INFO Kubernetes file "client-pod.yaml" created
INFO Kubernetes file "backend-service.yaml" created
INFO Kubernetes file "backend-pod.yaml" created

Deploy Resources to Kubernetes Cluster

kubectl apply -f client-service.yaml,client-pod.yaml,backend-service.yaml,backend-pod.yaml

Other Options

skaffold init --compose-file docker-compose.yaml

Conclusion

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store