• kubernetes services: externalName

    2 min read

    externalName service kubernetes

    One of kind of Service objects on kubernetes is extenalName. It creates a CNAME DNS entry to point to an external DNS service. For exemple:

    kind: Service
    apiVersion: v1
    metadata:
      name: ensvc
    spec:
      type: ExternalName
      externalName: pet2cattle.com
    

    29/01/2021

    Read more...
  • Getting a terraform plan in json format

    2 min read

    terraform plan json terraform show

    Starting terraform v0.12 we can get the terraform plan in json format. To do so, first we will need to save the plan to a file:

    $ terraform plan -out demo.plan
    

    28/01/2021

    Read more...
  • How to conditionally include a resource in terraform

    1 min read

    terraform conditionally include resource HCL

    On terraform modules sometimes it make sense to completely get rid of some resources using some condition. Since we don't have an if statement, we can use count instead

    27/01/2021

    Read more...
  • Ansible: Test a task by applying it locally

    2 min read

    If you need to test a set of ansible tasks without having to go into much trouble, you can use ansible-playbook to do a quick local test. To do so you just need ansible installed and create a yaml file with the playbook to execute using the following format:

    ---
    - hosts: 127.0.0.1
      tasks:
      - name: mkdir /tmp/test
        command: 
          cmd: mkdir -p /tmp/test
    

    26/01/2021

    Read more...
  • kubectl: set a given namespace as your default

    2 min read

    kubernetes default namespace

    When you need to work on some specific namespace it is quite annoying yo have to specify at each kubectl command the same namespace over and over again. It's much easier to change the current context to use another namespace by default.

    25/01/2021

    Read more...
  • mkdit: Yet another cure for your mistyping

    3 min read

    mkdit typo

    It is quite anoying when you keep typing mkdit instead of mkdir for creating a directory just as it is to type sl instead of ls. At least, for sl there's an actual Debian package that, the Steam Locomotive. Having this in mind I created another tool called mkdir:

    https://github.com/jordiprats/bash-mkdit

    Using this as an example we will configure a github action to build .deb and .rpm packages for this tool.

    22/01/2021

    Read more...
  • How to trigger a Kubernetes cronjob

    2 min read

    kubernetes cronjob trigger

    If you deploy a Cronjob on Kubernetes it can be useful to test it out by manually triggering a run rather than to wait until it is run according by it's schedule.

    Let's assume we have the following Cronjob that we want to run:

    $ kubectl get cronjob
    NAME                    SCHEDULE    SUSPEND   ACTIVE   LAST SCHEDULE   AGE
    pet2cattle-sitemapgen   0 5 * * *   False     0        <none>          13m
    

    21/01/2021

    Read more...
  • Create a cronjob on a kubernetes cluster

    3 min read

    kubectl cronjob create

    The cronjob object haven't been GA until Kubernetes v1.21, even though the Job object have been GA for a long time. Let's take a look how it works:

    $ kubectl create job demo --image nginx --dry-run=client -o yaml  | head -n1
    apiVersion: batch/v1
    $ kubectl create cronjob demo --image nginx --schedule="*/1 * * * *" -o yaml --dry-run=client | head -n1
    apiVersion: batch/v1beta1
    

    20/01/2021

    Read more...
  • Creating a kubernetes cluster with multiple nodes using minkube

    6 min read

    minikube multinode cluster docker

    Minikube is very useful for creating mockup environments for testing purposes, but it can be also use for studying yout CKA certification. Some topics, like node affinity or node failure will require you to have a multinode cluster but you can still use minikube

    19/01/2021

    Read more...
  • Rollback an upgrade using helm

    3 min read

    helm upgrade rollback

    When we upgrade an application using helm it can always go something wrong so instead of upgrading to another version or uninstall / install the application, we can rollback to a previous version that we know it is working

    Previously we already talked about the helm history command

    $ helm history pet2cattle
    REVISION  UPDATED                   STATUS      CHART           APP VERSION DESCRIPTION     
    60        Wed Dec 30 16:17:58 2020  superseded  pet2cattle-1.7  2.8         Upgrade complete
    61        Fri Jan  1 21:45:07 2021  superseded  pet2cattle-2    3           Upgrade complete
    62        Sat Jan  2 11:57:26 2021  superseded  pet2cattle-2    3.1         Upgrade complete
    63        Sat Jan  2 22:09:24 2021  superseded  pet2cattle-2    3.2         Upgrade complete
    64        Mon Jan  4 09:33:53 2021  superseded  pet2cattle-2    3.3         Upgrade complete
    65        Tue Jan  5 07:57:53 2021  superseded  pet2cattle-2    3.4         Upgrade complete
    66        Wed Jan  6 15:25:30 2021  superseded  pet2cattle-2    3.5         Upgrade complete
    67        Thu Jan  7 09:10:07 2021  superseded  pet2cattle-2    3.6         Upgrade complete
    68        Fri Jan  8 08:17:56 2021  superseded  pet2cattle-2    3.7         Upgrade complete
    69        Sat Jan  9 19:23:25 2021  deployed    pet2cattle-2    3.8         Upgrade complete
    

    Let's assume that the latest deployed versions is not working.

    18/01/2021

    Read more...

Older content...

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