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](https://shdhumale.files.wordpress.com/2020/05/image1-3.jpg)
2- kubectl expose deployment siddhu-new-tomcat-deployment --type=NodePort
![Image2](https://shdhumale.files.wordpress.com/2020/05/image2-3.jpg)
Please make sure to check the status of the container using
kubectl get pod
![Image4](https://shdhumale.files.wordpress.com/2020/05/image4-3.jpg)
![Image5](https://shdhumale.files.wordpress.com/2020/05/image5-3.jpg)
![Image6](https://shdhumale.files.wordpress.com/2020/05/image6-3.jpg)
![Image7](https://shdhumale.files.wordpress.com/2020/05/image7-2.jpg)
Finally to check if the tomcat is running expose the above in url using below command
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](https://shdhumale.files.wordpress.com/2020/05/image1-3.jpg)
2- kubectl expose deployment siddhu-new-tomcat-deployment --type=NodePort
![Image2](https://shdhumale.files.wordpress.com/2020/05/image2-3.jpg)
Please make sure to check the status of the container using
kubectl get pod
![Image4](https://shdhumale.files.wordpress.com/2020/05/image4-3.jpg)
![Image5](https://shdhumale.files.wordpress.com/2020/05/image5-3.jpg)
![Image6](https://shdhumale.files.wordpress.com/2020/05/image6-3.jpg)
![Image7](https://shdhumale.files.wordpress.com/2020/05/image7-2.jpg)
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](https://shdhumale.files.wordpress.com/2020/05/image3-3.jpg)
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](https://shdhumale.files.wordpress.com/2020/05/image1-4.jpg)
After Deployment
![Image2](https://shdhumale.files.wordpress.com/2020/05/image2-4.jpg)
Exposing to url and cheking if the httpd is running
![Image3](https://shdhumale.files.wordpress.com/2020/05/image3-4.jpg)
![Image4](https://shdhumale.files.wordpress.com/2020/05/image4-4.jpg)
Note: Important command to get all
kubectl get all
'- And to delete the pod or deployment use
kubectl delete pod/nameofthepod
No comments:
Post a Comment