• Kubernetes: get logs from an already restarted container

    2 min read

    kubernetes kubectl logs

    If we need to investigate why a container keeps restarting, a good place to start is taking a look at the logs when it crashes. Since Kubernetes will automatically restart a failed container, if we use kubectl logs we will get the logs of the restarted container instead of the one that have crashed:

    $ kubectl logs ampa-7d98c84675-dpzjw -c ampa 
    [2021-10-15 14:20:41 +0000] [1] [INFO] Starting gunicorn 20.0.4
    [2021-10-15 14:20:41 +0000] [1] [INFO] Listening at: http://0.0.0.0:8000 (1)
    [2021-10-15 14:20:41 +0000] [1] [INFO] Using worker: sync
    [2021-10-15 14:20:41 +0000] [8] [INFO] Booting worker with pid: 8
    

    How can we retrieve the logs of the previous container?

    18/10/2021

    Read more...
  • CLI tool to retrieve CloudWatch logs

    1 min read

    Using the awslogs cli tool we can query groups, streams and events from Amazon CloudWatch logs. It also has a human-friendly format for time-filtering

    It's available as using pip so to install it we just need to run:

    pip install awslogs
    

    09/07/2021

    Read more...

From pet to cattle
Treat your kubernetes clusters like cattle, not pets