Challenge from iximiuz labs
Try this challenge using below link
Scenario:
There is an Nginx Pod named web running in the default
namespace. Whoever started it forgot to add the required nginx.conf
file to its container. Your task is to copy the config file to the Pod without restarting it. After that, you will need to copy the nginx
binary from the Pod to the host for further analysis by the security team.
- You can access the Nginx server at Pod’s IP address on port 80.
- The correct config file is located on the host at
/root/nginx.conf
. - The config file in the
web
container is located at/etc/nginx/nginx.conf
. - Use
kubectl exec web -c web -- nginx -s reload
to trigger a config reload. - The Nginx binary is located in the
web
container at/usr/sbin/nginx
. - Copy the Nginx binary to the host at
/root/nginx-bin
.
Solution:
- First checking , if we can access the pod using its IP.
- Now copy the nginx config file to the pod using “kubectl cp” command.By default, Volume in kubernetes pod is accessible to all the containers inside them.
- Now reload the nginx config file to take effect in container .By using “kubectl exec” command we can run command in pod/contianer.
- Checking the pod to confirm the new changes .
- After verifying the changes. Now, we have to copy the nginx binary from the pod to the host system. Here also we can use “kubectl cp” command to achieve the task. To verify we can use “ls” command.
- In the left side of the website, We can see the status of challenge . From that i can verify that i have successfully completed the challenge.
For DevOps related blogs and challenges, pleased visit iximiuz.com . It provides In-depth articles of docker and kubernetes which is a gold mine for those who want to understand internals of containers and orchestration.
Thanks for reading this short article/write-up. Have a nice day.