• 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...
  • How to override a provider with a local version

    2 min read

    terraform provider development

    If we are modifying a provider, to be able to properly test it we might want to run a terraform plan or apply using this provider. To be able to override a given provider using this method (dev_overrides) we will need to use terraform v0.14 or later

    14/10/2021

    Read more...
  • Terrafrom: Ignore changes on some of the managed resources

    2 min read

    Some of the resources we create using terraform might be externally changed, for example an AutoScalingGroup desired_capacity can be changed externally (not modifying terraform's state) in order to handle more traffic. That's the case for the worker's ASG on an EKS cluster, which will be usually modified by the cluster autoscaler

    (...)
    
    Note: Objects have changed outside of Terraform
    
    Terraform detected the following changes made outside of Terraform since the last "terraform apply":
    
      # module.eks.aws_autoscaling_group.workers["pet2cattle_eu-west-1a"] has been changed
      ~ resource "aws_autoscaling_group" "workers" {
          ~ desired_capacity          = 7 -> 6
            id                        = "pet2cattle_eu-west-1a2021082509502468370000000a"
            name                      = "pet2cattle_eu-west-1a2021082509502468370000000a"
            # (22 unchanged attributes hidden)
    
    
            # (16 unchanged blocks hidden)
        }
    
    Unless you have made equivalent changes to your configuration, or ignored the relevant attributes using ignore_changes, the following plan may include actions to undo or respond to these changes.
    
    (...)
    

    13/10/2021

    Read more...
  • How to write a string replacement browser plugin

    2 min read

    browser plugin javascript Firefox Chrome

    If you want to write a browser plugin that replaces strings on webpages the easiest method is by doing it using Javascript. So, to replace a in a webpage a string for another we can use the following Javascript code:

    document.body.innerHTML = document.body.innerHTML.replace(/\bA\b/g, "B");
    

    12/10/2021

    Read more...
  • How to use terraform's nonsensitive() function

    2 min read

    terraform sensitive

    Starting terraform 0.15 variables can be marked as sensitive, so it won't appear in plain text as a terraform output unless we explicitly request them. But we can also make the variable as non sensitive using the nonsensitive() function

    07/10/2021

    Read more...

More recent...

Older content...