Answer for Kodekloud DEVOPS Questions --Deploy Guest Book App on Kubernetes

The Nautilus Application development team has finished development of one of the applications and it is ready for deployment. It is a guestbook application that will be used to manage entries for guests/visitors. As per discussion with the DevOps team, they have finalized the infrastructure that will be deployed on Kubernetes cluster. Below you can find more details about it.

BACK-END TIER

1. Create a deployment named redis-master for Redis master.

a.) Replicas count should be 1.

b.) Container name should be master-redis-nautilus and it should use image redis.

c.) Request resources as CPU should be 100m and Memory should be 100Mi.

d.) Container port should be redis default port i.e 6379.

2. Create a service named redis-master for Redis master. Port and targetPort should be Redis default port i.e 6379.

3. Create another deployment named redis-slave for Redis slave.

a.) Replicas count should be 2.

b.) Container name should be slave-redis-nautilus and it should use gcr.io/google_samples/gb-redisslave:v3 image.

c.) Requests resources as CPU should be 100m and Memory should be 100Mi.

d.) Define an environment variable named GET_HOSTS_FROM and its value should be dns.

e.) Container port should be Redis default port i.e 6379.

4. Create another service named redis-slave. It should use Redis default port i.e 6379.

FRONT END TIER

1. Create a deployment named frontend.

a.) Replicas count should be 3.

b.) Container name should be php-redis-nautilus and it should use gcr.io/google-samples/gb-frontend:v4 image.

c.) Request resources as CPU should be 100m and Memory should be 100Mi.

d.) Define an environment variable named as GET_HOSTS_FROM and its value should be dns.

e.) Container port should be 80.

2. Create a service named frontend. Its type should be NodePort, port should be 80 and its nodePort should be 30009.

Finally, you can check the guestbook app by clicking on + button in the top left corner and Select port to view on Host 1 then enter your nodePort.

You can use any labels as per your choice.

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

Sample Answer:

#To create the deployments and services, 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 and service yaml files for this task.

(BkE-deploy.yaml, BkE-service.yaml, Bk-slave-deploy.yaml,Bk-salve-service.yaml,FE-deploy.yaml, FE-service.yaml)

#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 backend deployment

    kubectl apply -f <your-deploy.yaml > 

#create- backend -service 

    kubectl apply -f <your-service.yaml>

#create slave deployment

    kubectl apply -f <your-deploy.yaml > 

#now create-slave-service 

    kubectl apply -f <your-service.yaml>

#create frontend deployment

    kubectl apply -f <your-deploy.yaml > 

#now front-end-service 

    kubectl apply -f <your-service.yaml>


#check pods ( wait to running the pods)
     
    kubectl get pods 

#check the service 

    kubectl get service 

#Final verification 

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

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

you can check the guestbook app by clicking on + button in the top left corner and Select port to view on Host 1 then enter your nodePort.

*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.

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 , ...