• Kubernetes: get logs from an already restarted container

    2 min read

    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...
  • Update local kubeconfig to connect to an AWS EKS cluster

    2 min read

    If we want to connect to an AWS EKS cluster using kubectl we need to update our kubeconfig (~/.kube/config) To do se we can use awscli

    04/10/2021

    Read more...
  • Inject a sidecar using KubeMod

    3 min read

    Using a webhook we can mutate Kubernetes objects when they are inserted to the cluster. But using a mutating operator can save us the trouble of having to actually code how the object needs to be patched

    27/09/2021

    Read more...
  • Pod hooks: postStart and preStop

    2 min read

    If we need to execute some actions at container startup of before stopping the container we can me use of the container lifecycle hooks

    24/09/2021

    Read more...
  • Kubernetes: Find deprecated API versions

    2 min read

    On a Kubernetes cluster we might have deprecated versions of the object, so after updating it we might end up with something not properly working:

    $ kubectl api-resources | grep Ingress\$
    ingresses                         ing              extensions/v1beta1                     true         Ingress
    ingresses                         ing              networking.k8s.io/v1                   true         Ingress
    

    23/09/2021

    Read more...

Older content...