Deploy Tomcat App on Kubernetes



Deploy Tomcat App on Kubernetes

 Question : A new java-based application is ready to be deployed on a Kubernetes cluster. The development team had a meeting with the DevOps team share requirements and application scope. The team is ready to setup an application stack for it under their existing cluster. Below you can find the details for this:

Create a namespace named tomcat-namespace-xfusion.

Create a deployment for tomcat app which should be named tomcat-deployment-xfusion under the same namespace you created. Replicas count should be 1, the container should be named as tomcat-container-xfusion, its image should be and its container port should be 8080.

Create a service for tomcat app which should be named as tomcat-service-xfusion under the same namespace you created. Service type should be NodePort. Port's protocol should be TCP, port should be 80, targetPort should be 8080 and nodePort should be 32227.

Before clicking on Finish button please make sure the application is up and running.

You can use any labels as per your choice.

Note: The kubectl on jump_host has been configured to work with the kubernetes cluster.

Please Note :-  Perform the below commands based on your question  server,  user name & other details might differ . So please read task carefully before executing. All the Best 👍


1. At first  kubectl  utility configure and working from jump server, run below commands

    kubectl get namespace

    kubectl get pods

2. Create new namespace 


thor@jump_host /$ kubectl create namespace tomcat-namespace-xfusion

namespace/tomcat-namespace-xfusion   created

thor@jump_host /$ kubectl get namespace

NAME                        STATUS   AGE

default                     Active   2m1s

kube-node-lease             Active   2m6s

kube-public                 Active   2m6s

kube-system                 Active   2m6s

tomcat-namespace-xfusion  Active   36s

3.  Create yaml  file with all the parameters , you can copy form gitlab

    Refer Below Video for more clarity )

apiVersion: v1

kind: Service


  name: tomcat-service-xfusion

  namespace: tomcat-namespace-xfusion


  type: NodePort


    app: tomcat


    - port: 80

      protocol: TCP

      targetPort: 8080

      nodePort: 32227


apiVersion: apps/v1                          

kind: Deployment


  name: tomcat-deployment-xfusion

  namespace: tomcat-namespace-xfusion


  replicas: 1



      app: tomcat




        app: tomcat



        - name: tomcat-container-xfusion



            - containerPort: 8080

4. Run below command to create pod

thor@jump_host /$ kubectl create -f /tmp/tomcat.yaml

service/tomcat-service-xfusion  created

deployment.apps/tomcat-deployment-xfusion created

5.  Wait for  deployment & pods to get running status

thor@jump_host /$ kubectl get deploy -n tomcat-namespace-xfusion

NAME                         READY   UP-TO-DATE   AVAILABLE   AGE

tomcat-deployment-xfusion   1/1     1            1           91s

thor@jump_host /$

thor@jump_host /$ kubectl get pods -n tomcat-namespace-xfusion

NAME                                          READY   STATUS              RESTARTS   AGE

tomcat-deployment-xfusion-654c5b77ff-x8q7h   0/1     ContainerCreating   0          18s

thor@jump_host /$


6.  Validate the task by running below command 

thor@jump_host /$ kubectl exec tomcat-deployment-xfusion-654c5b77ff-x8q7h -n tomcat-namespace-xfusion -- curl http://localhost:8080

  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current

                                 Dload  Upload   Total   Spent    Left  Speed

100   471  100   471    0     0   4528      0 --:--:-- --:--:-- --:--:--  4528

<!DOCTYPE html>


To change this license header, choose License Headers in Project Properties.

To change this template file, choose Tools | Templates

and open the template in the editor.





        <meta charset="UTF-8">

        <meta name="viewport" content="width=device-width, initial-scale=1.0">



        <h2>Welcome to xFusionCorp Industries!</h2>





thor@jump_host /$


7.  Click on Finish & Confirm to complete the task successful

Happy Learning!!!!

Apart from this if you need more clarity,  I have made a  tutorial video on this , 

please go through and share your comments. Like and share the knowledge

Post a Comment


Latest Posts

Deploy MySQL on Kubernetes