Answer for Kodekloud DEVOPS Questions - Deploy Tomcat App on Kubernetes

 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:

1. Create a namespace named tomcat-namespace-nautilus.

2. Create a deployment for tomcat app which should be named tomcat-deployment-nautilus under the same namespace you created. Replicas count should be 1, the container should be named as tomcat-container-nautilus, its image should be gcr.io/kodekloud/centos-ssh-enabled:tomcat and its container port should be 8080.

3. Create a service for tomcat app which should be named as tomcat-service-nautilus 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.


Sample Answer:


#To create the deployment, it's a good practice to create the YAML file using the given details in the question.

check below github link for the sample deployment yaml <deploy.yaml> file for this task

##To create the Service, its good practice to prepare the YAML file using the given details in the question

check below github link for the sample service yaml  <service.yaml> file for this task.



#please not that i  have created separate files for each steps for better understand and learning but these can be done via single YAML file.

#hope you prepared the YAML file from the above steps NOW let's do the task

#create the namespace 

    kubectl create ns <namespace name from your question>


#create deployment

    kubectl apply -f <your-deploy.yaml > -n <namespace-name>

#check pods ( wait to running the pods)
     
    kubectl get pods -n <nameapace-name>

#now create-service 

    kubectl apply -f <your-service.yaml> -n <namespace-name>

#check the service 

    kubectl get service -n <namespace-name>


#Final verification 

#get the pod name from the below commands and replace it with the following command 

     kubectl get pods -n <namespace-name>
    
    
    kubectl exec <pod-name> -n <namespace-name>  -- curl -I http://localhost/

*Please comment on this post if you have any questions or facing any issues in the above steps, also provide your feedback in the comments :)

Note: **The Question copied it for learning purposes.** Commands are correct but based on your question the server, user name, and other details might differ, so please do check.

check below video too for how to do the task (i have done a sample task on Ubuntu OS)




No comments:

Post a Comment

Featured Post

Answer for Kodekloud DEVOPS Questions - Init container in Kubernetes

Question: 1. Create a Deployment named as ic-deploy-devops. 2. Configure spec as replicas should be 1 , labels app should be ic-devops , ...