Kompose

Kompose

Easily generate Kubernetes configuration files using docker-compose.yml

Hi, If you're just starting out with learning kubernetes then this is gonna be a very useful tool for you. I came across this tool while following Brian Holt's course complete-intro-containers on Frontend Masters. He also maintains his notes on GitHub. You can check the github repo and notes here later.

Click here to see how to install Kompose on your platform.

Steps:

  1. Go into the directory where your docker-compose.yml is present. For example, you can create a docker-compose.yaml file and put this content in it. This is the same game that I have explained in my previous blog post Raise A Fox.

    
    version: '3'
    services:
     fox-game:
       image: akanksha0307/fox-game:v1
       ports:
         - "1234:1234"
    
  2. Run thekompose convert command to convert the docker-compose file into kubernetes configuration files. asciicast

  3. Then you can use kubectl apply to create these resources in minikube cluster.

    kubectl apply -f fox-game-deployment.yaml
    kubectl apply -f fox-game-service.yaml
    
  4. You can check if the pods are running using:

    
    kubectl get pods -A | grep fox-game
    
  5. Now we still cannot access the application from the browser as we will need to do port-forwarding.

    
    kubectl port-forward --namespace default svc/fox-game 1234:1234
    
  6. Access the application from the browser at localhost:1234.

  7. Once you're done playing, you can delete the pods and services by:

    # To get the Pod name
    kubectl get pods -A | grep fox-game
    # Delete pod
    kubectl delete pods <pod-name>
    --------------------------------------------------
    # To get the Service name
    kubectl get svc -A | grep fox-game
    # Delete service
    kubectl delete service <service-name>
    

fox-game 2.png