• Kubernetes Pod: Share a temporal Volume across containers

    2 min read

    kubernetes volume pod

    If we need to be able to share some data across containers (one generates the data and the other one consumes it) we can use an emptyDir to create a Volume to mount on both containers.

    30/06/2021

    Read more...
  • What's the meaning of the sections of a kubeconfig file?

    2 min read

    kubernetes kubeconfig format

    The configuration file kubeconfig (~/.kube/config) is used to get access to a Kubernetes cluster. It looks like a Kubernetes object that defines the cluster, the user and the context to use:

    apiVersion: v1
    kind: Config
    preferences: {}
    
    clusters:
    (...)
    
    users:
    (...)
    
    contexts:
    (...)
    

    Let's take a minikube kubeconfig as an example

    29/06/2021

    Read more...
  • How to use ConfigMap on Kubernetes

    2 min read

    kubernetes ConfigMap

    A ConfigMap an object intended to store configuration for other objects to use. To create a config map we just need to add the data we want to store on the configmap as keys on the data section:

    apiVersion: v1
    kind: ConfigMap
    metadata:
      name: demo-configmap
    data:
      file1.txt: |
        this is an example
    
      file2.txt: |
        this is another example
    

    28/06/2021

    Read more...
  • git: Get a diff between branches

    1 min read

    If you want to compare the differences between two branches on git, it's quite straightforward: We just need to tell from which branch to witch one we want to do the diff

    25/06/2021

    Read more...
  • terraform resource time_sleep: Waiting for resources to be ready before using them

    2 min read

    terraform resource time_sleep depends_on sleep

    Some times we need to wait some time before using some of the resources to give some time to the previous resources to be ready. For this kind of situations we can use the resource time_sleep combined with depends_on to achieve this functionality on terraform

    23/06/2021

    Read more...
  • terraform: Using for_each over tuples

    2 min read

    terraform for_each tuple

    Let's imagine we have the following data structure:

    locals {
      queries = [
        {
          query  = "SELECT version()"
          engine = "postgresql"
        },
        {
          query  = "SELECT * FROM v$version"
          engine = "oracle"
        },
        (...)
      ]
    }
    

    If we want to use just some of the items on a resource we can use for_each through the resulting array of filtering the objects using a for:

    for_each = [ for item in local.queries: item if item.engine == "postgresql" ]
    

    22/06/2021

    Read more...
  • Kubernetes init containers

    2 min read

    kubernetes initContainers

    Kubernetes init containers are a special container that runs before the main containers on the Pod. They are usually used used for setting up the environment and populate some shared storage to be used for the actual containers.

    21/06/2021

    Read more...
  • Pod and Service DNS naming schema

    2 min read

    kubernetes DNS name resolution

    Kubernetes provides a DNS to be used to locate other pods or services instead of using it's IP address. The default cluster domain is cluster.local but we can change it if we like.

    18/06/2021

    Read more...
  • How to list installed applications on a kubernetes cluster using helm

    2 min read

    helm list

    Helm intends to be a package manager for kubernetes, as such it provides a way to list all the installed applicacions on the cluster

    17/06/2021

    Read more...
  • terraform setproduct: combine list of objects to generate all the possible combinations

    4 min read

    terraform setproduct

    Let's imagine we want to create a security group with the following ingress rules:

    ingress_rules = [
        {
            protocol = "tcp"
            cidr_blocks = [ "1.1.1.1/32", "2.2.2.2/32" ]
        },
        {
            protocol = "tcp"
            cidr_blocks = [ "1.2.3.4/32" ]
        }
    ]
    

    For each of the following ports:

    services = ["80", "443", "8080"]
    

    We can use the terraform function setproduct() to calculate all the combinations of elements from the given sets. That's also called the Cartesian product. For this example it's going to be 2x3.

    16/06/2021

    Read more...

Older content...

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