Tuesday, May 12, 2020

Minikube to deploy tomcat container from docker

To deploy the any container from the docker we need to first create the deployment.yaml file. Please refer to the below file
apiVersion: apps/v1
kind: Deployment
metadata:
name: siddhu-tomcat-deployment
spec:
selector:
matchLabels:
app: tomcat
replicas: 1
template:
metadata:
labels:
app: tomcat
spec:
containers:
- name: tomcat
image: tomcat:9.0
ports:
- containerPort: 8999
use the following command in sequence wise
1- kubectl apply -f C:\kubernetes-minikube\deployment.yaml
Image1
2- kubectl expose deployment siddhu-new-tomcat-deployment --type=NodePort
Image2
Please make sure to check the status of the container using
kubectl get pod
Image4Image5Image6Image7
Finally to check if the tomcat is running expose the above in url using below command

To install minikube use this site

https://minikube.sigs.k8s.io/docs/start/

and download the minikube installer from 

https://storage.googleapis.com/minikube/releases/latest/minikube-installer.exe

3- minikube service siddhu-new-tomcat-deployment --url

Image3
4- check if it is running using curl or browser
For deploying Apache httpd in docker using kubernetes use below deployment,yaml
'- deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: httpd-deployment
spec:
selector:
matchLabels:
app: httpd
replicas: 1
template:
metadata:
labels:
app: httpd
spec:
containers:
- name: httpd
image: httpd:2.4.43
ports:
- containerPort: 80

Before Deployment
Image1
After Deployment
Image2
Exposing to url and cheking if the httpd is running

Image3Image4

Note: Important command to get all
kubectl get all
'- And to delete the pod or deployment use
kubectl delete pod/nameofthepod

No comments: