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

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

Ansible: for each loop

March 29, 2019

Example of how to do a for each (foreach) loop in a task with a predefined dictionary.

Example on Python

for key, value in dictionary.items():
    # do stuff

Example on PHP

foreach ($dictionary as $key => $value) {
    # do stuff
}
Read more