Answer for Kodekloud DEVOPS Questions-Kubernetes Shared Volumes

 Question: Read the full details of your question. 

sample Answer:

# first we need to create a YAML file based on the given details in the question.

check below the Github link for the sample YAML file for this task.( share-volume-pod.yaml) 



#Hope you prepared the YAML file from the above step using your question details.
NOW let's do the task.

  # pod creation 
    
    kubectl apply -f <your.yaml file> 

# login to 1 container and create a file in container 1

   echo 'Welcome to xFusionCorp Industries!' > tmp/beta/beta.text

#now login to check in another container location that beta. text is presented 

    cd /tmp/apps/ 


Note: Commands are correct but based on your question the server, user name, and other details might differ, so please do check.

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


*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 :)

Answer for Kodekloud DEVOPS Questions --Install Puppet agent

 The Nautilus DevOps team to would like to set up a Puppet agent mode to manage their infrastructure in Stratos DC. For testing they are trying to install and set up Puppet agent package on App Server 3. Please find below more details about the task to proceed further.

1. Install puppet agent on App Server 3 also start its service.


Sample Answer: 

#login to the given app server 

    ssh <user>@<app-server>

#switch to root user ( or you can execute commands with "sudo" in front)


    sudo su

#Install a release package to enable Puppet Platform repositories. (it should be base on the OS version)


    rpm -Uvh https://yum.puppet.com/puppet5-release-el-7.noarch.rpm


#install puppet agent


    yum -y install puppet-agent


#starting puppet agent

    /opt/puppetlabs/bin/puppet resource service puppet ensure=running enable=true

#status
 
    systemctl status puppet

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

    

Answer for Kodekloud DEVOPS Questions - Deploy voting app on kubernetes

 Question: Deploy voting app on Kubernetes

        please read your question details carefully 

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 deployments and services yaml files for this task.


#please note that I have created separate files for each steps for better understand and learning but these can be done via a 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>

#deploy the yaml file one by one to create the pods and services 

   kubectl apply -f <filename> -n < namespace_name>


Note: Commands are correct but based on your question the server, user name, and other details might differ, so please do check.

*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 :)

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




Answer for Kodekloud DEVOPS Questions - Deploy an App on Docker Containers

The Nautilus Application development team recently finished development of one of the apps that they want to deploy on a containerized platform. The Nautilus Application development and DevOps teams met to discuss some of the basic pre-requisites and requirements to complete the deployment. The team wants to test the deployment on one of the app servers before going live and set up a complete containerized stack using a docker compose fie. Below are the details of the task:

1. On App Server 2 in Stratos Datacenter create a docker compose file /opt/security/docker-compose.yml (should be named exactly).

2. The compose should deploy two services (web and DB), and each service should deploy a container as per details below:

For web service:

a. Container name must be php_host.

b. Use image php with any apache tag. Check here for more details https://hub.docker.com/_/php?tab=tags.

c. Map php_host container's port 80 with host port 8089

d. Map php_host container's /var/www/html volume with host volume /var/www/html.

For DB service:

a. Container name must be mysql_host.

b. Use image mariadb with any tag (preferably latest). Check here for more details https://hub.docker.com/_/mariadb?tab=tags.

c. Map mysql_host container's port 3306 with host port 3306

d. Map mysql_host container's /var/lib/mysql volume with host volume /var/lib/mysql.

e. Set MYSQL_DATABASE=database_host and use any custom user ( except root ) with some complex password for DB connections.

3. After running docker-compose up you can access the app with curl command curl <server-ip or hostname>:8089/

For more details check here: https://hub.docker.com/_/mariadb?tab=description

Note: Once you click on FINISH button, all currently running/stopped containers will be destroyed and stack will be deployed again using your compose file.

 

Sample Answer:

#login to the correct app server as given in the question

       ssh <user>@<app-server>

#switch to root user

    sudo su 

#now you need to create a docker-compose.yml file inside the given location.(check your question)

check below the Github link for the sample docker-compose.yml file for this task.


#hope you check the above sample docker-compose.yml and created with the details in your question.

#now deploy the file 

    docker-compose up -d 

#if everything ok, you will not be getting any errors

#Testing 

    curl <server-ip or hostname>:<port>/

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



Answer for Kodekloud DEVOPS Questions --Puppet Manage Services

 New packages need to be installed on all app servers in Stratos Datacenter. The Nautilus DevOps team has decided to install the same using Puppet. Since jump host is already configured to run as Puppet master server and all app servers are already configured to work as puppet agent nodes, we need to create required manifests on the Puppet master server so that it can be applied on all Puppet agent nodes. Please find more details about the task below.

Create a Puppet programming file apps.pp under /etc/puppetlabs/code/environments/production/manifests directory on master node i.e Jump Server and using puppet package resource perform the tasks below.

1. Install package vsftpd through Puppet package resource and start its service through puppet service resource on all Puppet agent nodes i.e all App Servers.

Note: Please perform this task using apps.pp only, do not create any separate inventory file.


Sample Answer:

#on jump host first create the apps.pp file in the given directory ( check your question for the name of the pp file )

check below the Github link for the sample .pp file for this task 



#Now hope you edit the above .pp file with the detail from your question

#appy the puppet file 
    
    puppet apply apps.pp

#now login to ALL the app servers and pull the config file. (you can also click on + button in the top left corner and select a new host to open another jump host terminal from there you can log in to app server )

    ssh <user>@<app-server>

#switch to root user

    sudo su 

# run below command 

    puppet agent -tv 

# now check the package status 

     systemctl status vsftpd 

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

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.

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)




Answer for Kodekloud DEVOPS Questions - Install Puppet Server

 The Nautilus DevOps team started experimenting with the Puppet server to manage some of their infrastructure in Stratos DC. For testing different scenarios, the team will be using jump host as puppet master. At this point we just need to install puppet server package and ensure its service is up and running. Below you can find more details about the task.

1. Install puppetserver package on jump host and start its service.

2. Before starting puppetserver service, you might need to change its memory allocation configuration. We recommend to allocating it 512m of memory.

Note: Please make sure to install puppetserver package only not any other alternate package.

Answer:

#the task needs to be performed on jump host 
# install the puppet server ( the question clearly mentioned that install puppetserver only NO need to install agent) 

# first you need to add the package to your repo by using the below command 

    rpm -Uvh https://yum.puppet.com/puppet7-release-el-7.noarch.rpm

#now install puppetserver 
    
    yum -y install puppetserver 

# change its memory allocation on puppetserver  config file
    
    vi /etc/sysconfig/puppetserver

 # Modify this if you'd like to change the memory allocation, enable JMX, etc
 JAVA_ARGS="-Xms2g -Xmx2g"

Replace 2g with the amount of memory you want to allocate to Puppet Server.
 JAVA_ARGS="-Xms512m -Xmx512m".

#save the file 

# start the puppet server and check the status 

    systemctl start puppetserver 

    systemctl status puppetserver 

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

Answer for Kodekloud DEVOPS Questions - Docker Ports Mapping

 The Nautilus DevOps team is planning to host an application on a nginx-based container. There are number of tickets already been created for similar tasks. One of the tickets has been assigned to set up a nginx container on Application Server 2 in Stratos Datacenter. Please perform the task as per details mentioned below:

a. Pull nginx:alpine docker image on Application Server 2.

b. Create a container named cluster using the image you pulled.

c. Map host port 3003 to container port 80. Please keep the container in running state.

Sample Answer:

#login to the correct app server as per your  question 

    ssh <user>@<app-server>

#switch to root user

    sudo su 

#pull the docker image ( check your question)

    docker pull < image from your question>

#you can cehck the image using below command 

    docker images 

#run the docker with the name and port  given in the question (check your question)

    docker run -d --name=<name from your question> -p <hostport>:<container port> <image>

#verify using below command 

    docker ps 


*Please comment on this post if you are facing any issues in the 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)



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