Init Containers in Kubernetes Kodekloud

 

Question:

Solution:

N.B: Configuration name can be different according to question

In jump_host create a deployment.yaml file

sudo vi deployment.yaml

Then create the deployment according to question configuration

apiVersion: apps/v1
kind: Deployment
metadata:
name: ic-deploy-nautilus
labels:
app: ic-nautilus
spec:
replicas: 1
selector:
matchLabels:
app: ic-nautilus
template:
metadata:
labels:
app: ic-nautilus
spec:
containers:
- name: ic-main-nautilus
image: debian:latest
command: ["/bin/bash", "-c"]
args: ['while true; do cat /ic/news; sleep 5; done']
volumeMounts:
- mountPath: /ic
name: ic-volume-nautilus
initContainers:
- name: ic-msg-nautilus
image: debian:latest
command: ["/bin/bash", '-c']
args: ['echo Init Done - Welcome to xFusionCorp Industries > /ic/news']
volumeMounts:
- name: ic-volume-nautilus
mountPath: /ic
volumes:
- name: ic-volume-nautilus
emptyDir: {}

After that save the file and apply the deployment

kubectl apply -f deployment.yaml

Finally see the status of pod

kubectl get po

Download Coding Interview Book and Get More Tutorials for Coding and Interview Solution: Click Here

Download System Design Interview Book and Get More Tutorials and Interview Solution: Click Here

Do you need more Guidance or Help? Then Book 1:1 Quick Call with Me: Click Here

Share on Google Plus

About Ashadullah Shawon

I am Ashadullah Shawon. I am a Software Engineer. I studied Computer Science and Engineering (CSE) at RUET. I Like To Share Knowledge. Learn More: Click Here
    Blogger Comment
    Facebook Comment

0 comments:

Post a Comment