K8s download logs from pod

There are two ways to access Pod logs.

Console Logs

If the logs are being written into the console Pod

kubectl logs connector-5f84b9d984-mggjg > test-file.log

File Logs

If logs are being written into an internal file, we may download it

kubectl -n aks-dev cp connector-5fb7574d94-2npvk:/usr/src/app/logs/CONNECTOR-2024-05-02.log log-connector-02.log

Multicontainer Pod

If there’s a sidecar Pod we can access a specific container with -c

kubectl logs connector-5f84b9d984-mggjg -c specific_container > test-file.log