Containerized Application Deployment With Kubernetes In Local Machine

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.
 
Containerized Application Deployment With Kubernetes In Local Machine
 
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.
  1. apiVersion: apps/v1  
  2. kind: Deployment  
  3. metadata:  
  4.   name: webapp1  
  5. spec:  
  6.   replicas: 1  
  7.   selector:  
  8.     matchLabels:  
  9.       app: webapp1  
  10.   template:  
  11.     metadata:  
  12.       labels:  
  13.         app: webapp1  
  14.     spec:  
  15.       containers:  
  16.       - name: webapp1  
  17.         image: DockerHubId/demo:v2  
  18.         ports:  
  19.         - containerPort: 80  
  20. ---  
  21. apiVersion: apps/v1  
  22. kind: Service  
  23. metadata:  
  24.   name: webapp1  
  25. spec:  
  26.   type: NodePort  
  27.   ports:  
  28.   - protocol: TCP  
  29.     port: 80  
  30.   selector:  
  31.     app: webapp1  
Step 2 - Create from file
 
In this option we can deploy our application by uploading yaml file.
 
Containerized Application Deployment With Kubernetes In Local Machine 
 
Step 3 - Create from form input.
 
In this option we can input form values and deploy our application.
 
Containerized Application Deployment With Kubernetes In Local Machine
 
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.
 
Containerized Application Deployment With Kubernetes In Local Machine
 
Step 5
  1. In Deployment section, you can do scale up/down you application, edit yaml file and update yaml configuration.
  2. In Pod section, you can check logs and operate with shell commands of specific pod.
Containerized Application Deployment With Kubernetes In Local Machine 
 
     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.
 
Containerized Application Deployment With Kubernetes In Local Machine
 
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.
 
Containerized Application Deployment With Kubernetes In Local Machine
I hope this was helpful for you. Enjoy ;)


Similar Articles