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:
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"
Run the
kompose convert
command to convert the docker-compose file into kubernetes configuration files.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
You can check if the pods are running using:
kubectl get pods -A | grep fox-game
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
Access the application from the browser at
localhost:1234
.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>