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, template's metadata lables app should be the same ic-devops.

3. The initContainers should be named as ic-msg-devops, use image centos, preferably with latest tag and use command '/bin/bash', '-c' and 'echo Init Done - Welcome to xFusionCorp Industries > /ic/ecommerce'. The volume mount should be named as ic-volume-devops and mount path should be /ic.

4. Main container should be named as ic-main-devops, use image centos, preferably with latest tag and use command '/bin/bash', '-c' and 'while true; do cat /ic/ecommerce; sleep 5; done'. The volume mount should be named as ic-volume-devops and mount path should be /ic.

5. Volume to be named as ic-volume-devops and it should be an emptyDir type.

Sample Answer: 

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

check below the Github link for the sample YAML file for this task.( init-container-deploy.yaml) 



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

 #deploy the file 

        kubectl apply -f <your-yaml-file>

#checking

    kubectl get pods


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 the below video too for how to do this task (i have done a sample task on Ubuntu OS)


LIKE, SUBSCRIBE my channel and stay tuned for more videos


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