• How to sort Kubernetes objects using kubectl

    3 min read

    kubectl sort

    kubectl get has an option to be able to sort it's output by any numeric or string field using it's JSON path. Let's take a look on how to do so:

    31/12/2020

    Read more...
  • minikube addons: NGINX Ingress Controller

    4 min read

    minikube addons ingress nginx controller

    minikube has many built-in applications and services that may be easily deployed by just enabling them. We can get a list using minikube addons list

    30/12/2020

    Read more...
  • kubernetes: List available objects using kubectl

    4 min read

    kubernetes list objects version minikube k3s

    Using kubectl api-resources we will get a list of available objects in out kubernetes cluster including:

    • It's shortname if available
    • Whether it is namespaced. For example, a ClusterRole is a global object (namespaced=false) but on the other hand, every Role belongs to a namespace this namespaced=true

    29/12/2020

    Read more...
  • git: merge changes to a branch on a different remote

    2 min read

    It is quite common to have have several remote repositories, let's see how to merge a change to a branch on a remote that collides with one of our local branches.

    28/12/2020

    Read more...
  • terraform: Append to a list using concat

    2 min read

    terraform append list concat HCL conditionally append

    To be able to conditionally append objects (or strings) to a list in terraform we must put it in another way: How do we dynamically generate a list of objects?

    The answer is using we can use the concat() function

    result = concat(["A"], ["B"])
    

    24/12/2020

    Read more...
  • Managing a secret on kubernetes

    3 min read

    secret password kubernetes kubectl k8s

    Most of the services we will be deploying on kubernetes are going to rely on having access to secrets to retrieve or push data to another service: Let's check how to work with the secrets on kubernetes

    $ kubectl create secret
    Create a secret using specified subcommand.
    
    Available Commands:
      docker-registry Create a secret for use with a Docker registry
      generic         Create a secret from a local file, directory or literal value
      tls             Create a TLS secret
    
    Usage:
      kubectl create secret [flags] [options]
    
    Use "kubectl <command> --help" for more information about a given command.
    Use "kubectl options" for a list of global command-line options (applies to all commands).
    

    23/12/2020

    Read more...
  • Change kubectl context to use another k8s cluster

    2 min read

    kubernetes kubectl context

    When you have on your .kube/config several clusters, you can choose to which cluster you want to connect by setting the appropriate context.

    22/12/2020

    Read more...
  • Unlocking remote terraform state

    2 min read

    terraform S3 bucket unlock tfstate force-unlock

    When you are working with the terraform state on a S3 bucket if you cancel an operation you might end up with the lock not being released so you won't be able to perform any more changes (not even plan a new change!)

    $ terraform plan
    Acquiring state lock. This may take a few moments...
    
    Error: Error locking state: Error acquiring the state lock: ConditionalCheckFailedException: The conditional request failed
    Lock Info:
      ID:        **6dec3c3f-dea3-4232-60f5-5fe0647a41f6**
      Path:      demo/terraform.tfstate
      Operation: OperationTypePlan
      Who:       jordi.prats@pet2cattle.com
      Version:   0.12.29
      Created:   2020-12-21 21:26:08.295375151 +0000 UTC
      Info:      
    
    
    Terraform acquires a state lock to protect the state from being written
    by multiple users at the same time. Please resolve the issue above and try
    again. For most commands, you can disable locking with the "-lock=false"
    flag, but this is not recommended.
    

    21/12/2020

    Read more...
  • K3s installation on a Raspberry Pi

    4 min read

    k3s raspberry raspberry pi cgroups

    To install k3s on a Raspberry Pi looks quite straight forward but it has it's nuisances.

    Installing k3s should be a single line command:

    # curl -sfL https://get.k3s.io | sh -
    [INFO]  Finding release for channel stable
    [INFO]  Using v1.18.9+k3s1 as release
    [INFO]  Downloading hash https://github.com/rancher/k3s/releases/download/v1.18.9+k3s1/sha256sum-arm.txt
    [INFO]  Downloading binary https://github.com/rancher/k3s/releases/download/v1.18.9+k3s1/k3s-armhf
    [INFO]  Verifying binary download
    [INFO]  Installing k3s to /usr/local/bin/k3s
    [INFO]  Creating /usr/local/bin/kubectl symlink to k3s
    [INFO]  Creating /usr/local/bin/crictl symlink to k3s
    [INFO]  Skipping /usr/local/bin/ctr symlink to k3s, command exists in PATH at /usr/bin/ctr
    [INFO]  Creating killall script /usr/local/bin/k3s-killall.sh
    [INFO]  Creating uninstall script /usr/local/bin/k3s-uninstall.sh
    [INFO]  env: Creating environment file /etc/systemd/system/k3s.service.env
    [INFO]  systemd: Creating service file /etc/systemd/system/k3s.service
    [INFO]  systemd: Enabling k3s unit
    Created symlink /etc/systemd/system/multi-user.target.wants/k3s.service → /etc/systemd/system/k3s.service.
    [INFO]  systemd: Starting k3s
    

    20/12/2020

    Read more...

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