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

2- kubectl expose deployment siddhu-new-tomcat-deployment --type=NodePort

Please make sure to check the status of the container using
kubectl get pod




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

2- kubectl expose deployment siddhu-new-tomcat-deployment --type=NodePort

Please make sure to check the status of the container using
kubectl get pod




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

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

After Deployment

Exposing to url and cheking if the httpd is running


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