Introduction
In this article we will see how to deploy an application with Kubernetes in local machine, which will be very usefull for CI/CD implementation. As per our previous article
Running Kubernetes in Local Machine we are ready to deploy our containerized Docker-based application into Kubernetes. There are a few ways to do the deployment and manage the application.
1. Create from input.
2. Create from file.
3. Create from form input.
So, now we are in the below Kubernetes dashboard that is running in localhost 8090 port.
Step 1 - Create from input
Let's start by deploying our application by clicking + symbol on top right cornor of the Kubernetes dashboard. Select Create from input option and enter the script that you want. For now I have entered a sample script.
- apiVersion: apps/v1
- kind: Deployment
- metadata:
- name: webapp1
- spec:
- replicas: 1
- selector:
- matchLabels:
- app: webapp1
- template:
- metadata:
- labels:
- app: webapp1
- spec:
- containers:
- - name: webapp1
- image: DockerHubId/demo:v2
- ports:
- - containerPort: 80
- ---
- apiVersion: apps/v1
- kind: Service
- metadata:
- name: webapp1
- spec:
- type: NodePort
- ports:
- - protocol: TCP
- port: 80
- selector:
- app: webapp1
Step 2 - Create from file
In this option we can deploy our application by uploading yaml file.
Step 3 - Create from form input.
In this option we can input form values and deploy our application.
Note
There are lots of of options available for application configuration in Kubernetes. For ex : Deployment,Service.
Step 4
From these above three steps, we have deployed our application in Kubernetes and the dashboard looks like below. There you can see Deployments, Replicas, Pods, Services.
These sections are all have their own cababilities. Let's see a few options of it. I am not describing more about those sections as it is not in the scope of this article.
Step 5
- In Deployment section, you can do scale up/down you application, edit yaml file and update yaml configuration.
- In Pod section, you can check logs and operate with shell commands of specific pod.
3. In Replica section, you can set default replica sets of your application (No down time).
4. In Services section, it is used to expose our application to the outside world and you can edit the yaml file.
Step 6
In the service section, if you click localhost:8082 under External Endpoints, it will redirect to our application. That's it, we have successfully run our application in a local kubernetes machine.
I hope this was helpful for you. Enjoy ;)