• Rolling updates on Kubernetes deployments

    2 min read

    Deployment pod rolling update

    There are several strategies available for updating a deployment on Kubernetes, by default it will trigger a rolling update: It will deploy the new version before tearing down the old one so there's no downtime associated to it.

    Let's see how we can see this process by applying an update to a deployment:

    $ kubectl apply -f deployment.yaml
    

    17/05/2021

    Read more...
  • How to imperatively change a container's image

    2 min read

    kubernetes set image

    To change a container's image we can:

    • Update the yaml definition and push it using kubectl apply
    • Use kubectl edit to update it using a definition fetched from the Kubernetes cluster itself
    • To use kubectl set image to set the new image

    Let's check how to use kubectl set image

    14/05/2021

    Read more...
  • Forward traffic to kubernetes services

    2 min read

    kubectl port-forward kubernetes

    When we want to access services that run inside a kubernetes cluster that are not supposed to be normally accessed we can temporally run kubectl port-forward to forward traffic to our workstation. To be able to use it, the node must have socat installed.

    13/05/2021

    Read more...
  • Forcefully replace a terraform resource / terraform taint

    3 min read

    terraform taint replace

    With terraform taint we are telling terraform that a particular object has become degraded so it will propose to replace it in the next plan. This command is going to be deprecated on terraform v1.0 since now we have the -replace flag on the apply command

    $ terraform taint kubernetes_namespace.pet2cattle_namespace
    Acquiring state lock. This may take a few moments...
    Resource instance kubernetes_namespace.pet2cattle_namespace has been marked as tainted.
    Releasing state lock. This may take a few moments...
    

    12/05/2021

    Read more...
  • How to add entries to a pod's /etc/hosts file

    2 min read

    hostAliases pod kubernetes

    The /etc/hosts file is a Kubernetes-managed file so we cannot add entries freely to it. If we want to add entries to it we will have to use the hostAliases field in the Pod's spec.

    $ kubectl exec -it demo-pod -- cat /etc/hosts
    # Kubernetes-managed hosts file.
    127.0.0.1 localhost
    ::1 localhost ip6-localhost ip6-loopback
    fe00::0 ip6-localnet
    fe00::0 ip6-mcastprefix
    fe00::1 ip6-allnodes
    fe00::2 ip6-allrouters
    10.103.198.74 demo-pod
    

    11/05/2021

    Read more...
  • AWS EKS: How to resize Persistent Volumes

    3 min read

    AWS EKS resize volume

    On a AWS EKS cluster, at the time of this writing, by default you cannot resize volumes provisioned with the default gp2 StorageClass. This is because on the default StorageClass the allowVolumeExpansion is set to false, preventing the volume expansion:

    $ kubectl get sc
    NAME            PROVISIONER             RECLAIMPOLICY   VOLUMEBINDINGMODE      ALLOWVOLUMEEXPANSION   AGE
    gp2 (default)   kubernetes.io/aws-ebs   Delete          WaitForFirstConsumer   false                  78d
    

    10/05/2021

    Read more...
  • terraform state list: List resources from the terraform state

    1 min read

    terraform state list resources state list

    To be able to get a list of resources managed by terraform we can use terraform state list for listing all the resources on the terraform state:

    07/05/2021

    Read more...
  • formatting Terraform code

    2 min read

    terraform format fmt

    One of the nicest functions terraform has is terraform fmt: Just as go fmt would do with Go code, it will rewrite Terraform configuration files (.tf and .tfvars files) to a canonical format and style. This will improve it's readability, helping making the code more consistent.

    06/05/2021

    Read more...
  • Kubernetes: Image pull policies

    2 min read

    imagePullPolicy pod kubernetes

    On Kubernetes we can configure using the Pod manifest under which conditions we want to query the container registry to pull images by using the imagePullPolicy setting. We can configure the it on several objects like Deployment, StatefulSet, Pod, Job... In fact, we can set it on any object that includes a Pod template

    apiVersion: v1
    kind: Pod
    metadata:
      name: test-pod
      namespace: demo
    spec:
      containers:
      - image: alpine
        imagePullPolicy: IfNotPresent
    (...)
    

    05/05/2021

    Read more...
  • terraform: Import existing resources for terraform to manage them

    3 min read

    terraform import state

    If we have some of the infrastructure that were created manually we can still import it into the terraform state. This ensures you can have a smooth transition from manually created resources to Infrastructure as Code

    To do so we will be using then terraform import command:

    $ terraform import
    The import command expects two arguments.
    Usage: terraform import [options] ADDR ID
    
    (...)
    

    04/05/2021

    Read more...

More recent...

Older content...

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