kompose is a tool to help users familiar with docker-compose move to Kubernetes. It takes a Docker Compose file and translates it into Kubernetes resources.

View the Project on GitHub kubernetes/kompose

Watch Star Fork

Kubernetes + Compose = Kompose

What’s Kompose? It’s a conversion tool for all things compose (namely Docker Compose) to container orchestrators (Kubernetes or OpenShift).

In three simple steps, we’ll take you from Docker Compose to Kubernetes.

1. Take a sample docker-compose.yaml file

version: "2"


    image: gcr.io/google_containers/redis:e2e 
      - "6379"

    image: gcr.io/google_samples/gb-redisslave:v1
      - "6379"
      - GET_HOSTS_FROM=dns

    image: gcr.io/google-samples/gb-frontend:v4
      - "80:80"
      - GET_HOSTS_FROM=dns
      kompose.service.type: LoadBalancer

2. Run kompose up in the same directory

$ kompose up
We are going to create Kubernetes Deployments, Services and PersistentVolumeClaims for your Dockerized application. 
If you need different kind of resources, use the 'kompose convert' and 'kubectl create -f' commands instead. 

INFO Successfully created Service: redis          
INFO Successfully created Service: web            
INFO Successfully created Deployment: redis       
INFO Successfully created Deployment: web         

Your application has been deployed to Kubernetes. You can run 'kubectl get deployment,svc,pods,pvc' for details.

Alternatively, you can run kompose convert and deploy with kubectl

2.1. Run kompose convert in the same directory

$ kompose convert                           
INFO Kubernetes file "frontend-service.yaml" created         
INFO Kubernetes file "redis-master-service.yaml" created     
INFO Kubernetes file "redis-slave-service.yaml" created      
INFO Kubernetes file "frontend-deployment.yaml" created      
INFO Kubernetes file "redis-master-deployment.yaml" created  
INFO Kubernetes file "redis-slave-deployment.yaml" created   

2.2. And start it on Kubernetes!

$ kubectl create -f frontend-service.yaml,redis-master-service.yaml,redis-slave-service.yaml,frontend-deployment.yaml,redis-master-deployment.yaml,redis-slave-deployment.yaml
service "frontend" created
service "redis-master" created
service "redis-slave" created
deployment "frontend" created
deployment "redis-master" created
deployment "redis-slave" created

3. View the newly deployed service

Now that your service has been deployed, let’s access it.

If you’re already using minikube for your development process:

$ minikube service frontend

Otherwise, let’s look up what IP your service is using!

$ kubectl describe svc frontend
Name:                   frontend
Namespace:              default
Labels:                 service=frontend
Selector:               service=frontend
Type:                   LoadBalancer
LoadBalancer Ingress:
Port:                   80      80/TCP
NodePort:               80      31144/TCP
Session Affinity:       None
No events.

If you’re using a cloud provider, your IP will be listed next to LoadBalancer Ingress.

$ curl