Kubernetes API by examples

February 11, 2020

I been playing with the Kubernetes API and I woud like to post and update with the time some examples.

For my case I have a service account which has complete access to a particular namespace, the service account is called demo-user.

To do some test I created a pod and I configured the service account to the pod, so I can get the credentials inside the container and query the API with the service account.

Read more

Bludit: How to install and configure Gris

January 29, 2020

I have been working on a different UI for the editor, fully integrated with the Bludit API + AJAX, also has some particular integration with tags, full Markdown support, and a color full dark mode.

I started the project for my technical blog but I would like to share the steps to install and configure the themes on your Bludit installation. I recommend to start from scratch Bludit installation and do not overwrite a current configuration until you understand how this is working.

Features:

  • Markdown support.
  • Markdown editor, thanks to EasyMDE.
  • Integrated with highlight.js.
  • Quick view for edit and change properties of the page.
  • UI with AJAX and base on tags.
  • Dark mode.
  • Public and private pages, in the end, the private is just a draft type on Bludit.
  • Ideal for technical people who want to post some code or just add embed code to the pages.
Read more

Kops: Kubernetes cluster with Autoscaling on AWS

November 13, 2019

The autoscaling groups created by Kops is only to keep a number of nodes up without any scaling policy; The idea of the following article is create a dynamic Kubernetes cluster, measure the load of the nodes and scale up or down. To do that we need to set up some tags to the worker nodes, give permission to the worker nodes to reach the AWS service autoscaling and deploy the tool Kubernetes autoscaler.

The cluster will be scale when:

  • There are pods that failed to run in the cluster due to insufficient resources.
  • There are nodes in the cluster that have been underutilized for an extended period of time and their pods can be placed on other existing nodes.

The environment:

The version of "Kubernetes autoscaler" need to be the same as your Kubernetes cluster version.

Read more

Airflow: Kubernetes Operator

November 4, 2019

DAG example using KubernetesPodOperator, the idea is run a Docker container in Kubernetes from Airflow every 30 minutes.

Features:

  • Scheduled every 30 minutes.
  • Set environment variable for the pod RULES.
  • Run the pods in the namespace default.
  • Mount a volume to the container. It's just an example mounting the /tmp from host.
  • Set imagePullSecrets for private Docker registry.
Read more

Git: Copy a file between branches

October 30, 2019

Let's assume we have a two branches (A, B), and we want to move the file test.xt from branch A to branch B.

git checkout B
git checkout A -- test.txt
git status
git commit -m "Copy file test.txt
git push

Git: Delete commits history

May 16, 2019

You can not delete the commit history from a branch, but you can create a new branch (without history because is new), push the files to the new branch and then delete the old branch.

The next example shows how to recreate the master branch.

# Create temporary branch
$ git checkout --orphan temp

# Add and commit all the files
$ git add -A
$ git commit -m "init"

# Delete current branch
$ git branch -D master

# Rename current branch to master
$ git branch -m master

# Push all the files to the new master branch
$ git push -f origin master