Kubernetes which is also known as K8 is a well-known container management solution. The main advantage of
Kubernetes is it is open source and production ready. The other advantage is when there are multiple instances or deployments happens, it becomes very difficult to manage them manually and it requires great tools like Kubernetes.
To start with, we need Minikube , which is a tool that makes it easy to run Kubernetes locally. The very first thing we need to do is to download minikube-windows-amd64 form GitHub . Then it needs to be renamed as minikube.exe.
We also need kubectl.exe from here, which controls the Kubernetes cluster manager and put it on the same path.
So, we are ready to start. We will get into command prompt and run the following:
minikube start and will get the following:
So Kubernetes is ready to bang on our system!
We can now run the following command to test the status:
minikube status and will get the following:
Which shows minikube is ready and running, kubectl is also configured!
We can get the IP address of the cluster using ip command minikube ip:
As we can see 192.168.99.100 is the virtual host where Kubernetes is running. We will use this while testing our deployed services once we deploy and expose our deployment.
We can start the dashboard which is a web console using minikube dashboard as following:
The dashboard will open right as follows in the browser:
We can check the current deployment using kubectl get deployments which will display No resource found. as there is no deployment we did:
Let’s create a new deployment from the console dashboard by clicking create on top right:
We will fill the App-name as test-mule-app and pull a docker image from docker hub, this time let’s take a Mule docker image and pull it from there. If we go to docker hub, we can see a Mule runtime docker image is already there which we will now pull on our docker container of Kubernetes.
So, now let’s start to configure our application for deployment in Kubernetes as follows:
Here if we see above image, we can see the configuration details. We are providing App-name as test-mule-app, Container-image name as anir37/anirban-mule, Number of pods let be 1 and Port and Target port be 9082 and finally, we click Deploy.
Once the deployment starts we can see the deployment name in the Dashboard under Deployments:
Now, if we run the kubectl get deployments command again in the console, we will get the deployment list there:
In our Dashboard, we check the logs, we will find the Mule runtime is deployed and running successfully in the container as we can see below:
Testing the Application:
Now we are ready to test the image we pulled in our container. As we already mentioned above, we have a sample Mule application that runs on HTTP port 9082 which we can test on our Kubernetes after deployment.
When we deploy our application through Dashboard, services are automatically created and exposed. We can check using following kubectl describe service test-mule-app :
We can see all the details of the services exposed for our deployed application above. The service has exposed the external port 32285 which will be mapped to the internal port 9082 which is being used by sample Mule application deployed in the container.
To run the service following command we need minikube service test-mule-app :
It will automatically open the browser and we can see our deployed Mule application responding:
It confirms our application is running well!.
We only need to add the valid url that our sample application is using. Our sample application is using internally the following url http://localhost:9082/testApplication, so, we just need to add /testApplication in the external url that our Kubernetes service has exposed.
So, the entire url will be: http://192.168.99.100:32285/testApplication as follows: