One of the most common uses when troubleshooting an application is to redirect the logs somewhere else to not lose them and being able to analyze those later to look for errors or patterns.
Solving these CKA exercises you will learn how to store in a safer place logs from pods even if they have multiple containers and to read them to be able to fix a Deployment which is not working.
Don’t forget to visit killercoda to get more exercises like this one and visit our other posts from Kuberentes
Used commands:
- kubectl config set-context –namespace=<namespace_name> –current
Set the desired namespace to the current context so we don’t need to declare it in each execution - kubectl logs –all-containers deploy/<deploy_name>
Get the logs from each container in the desired Deployment - <first_command> > <second_command>
Redirect the output of “first command” to “second command” - kubectl edit deploy/<deployment_name>
Edit the Deployment yaml and apply changes when exit