Posts in Category: tutorials

Bootstrapping the Kubernetes Control Plane

In this lab you will bootstrap the Kubernetes control plane across three compute instances and configure it for high availability. You will also create an external load balancer that exposes the Kubernetes API Servers to remote clients. The following components will be installed on each node: Kubernetes API Server, Scheduler, and Controller Manager.


The commands in this lab must be run on each controller instance: controller-0, controller-1, and controller-2. Login to each controller instance using the gcloud command. Example:

gcloud compute ssh controller-0

Running commands in parallel with tmux

tmux can be used to run commands on multiple compute instances at the same time. See the Running commands in parallel with tmux section in the Prerequisites lab.

Provision the Kubernetes Control Plane

Create the Kubernetes configuration directory:

sudo mkdir -p /etc/kubernetes/config

Download and Install the Kubernetes

Comparison between Ansible and Puppet

Key differences between Ansible and Puppet:

  • No single master server. You can simply install ansible on any server and that can then act as the muster. In Puppet, that’s not possible because the puppetmasters url is hardcoded into each puppet agent’s puppet.conf file.
  • Orchestration is done via the “push” system rather than the “pull” system. I.e. you don’t need to log into ansible client and then trigger a ansible run.
  • The code  in a playbook is executed in the order that they are specified. Where that is not the case with puppet, where if you want you can specify ordering using the before/require metaparameters
  • Puppet is based on ruby. However Ansible is based on python, and you can write python code right into your ansible code. Python comes with a huge amount of

Golang – Organise your code using functions

Functions are a block of code that can call in your code. Functions and Packages are the 2 main ways used for organising code in Golang. You can feed parameters to functions and functions can also return values. You can call one function from inside another function.

Setup a Workspace for Go

Before you can start writing Golang code. You first need to set up a Workspace. A workspace is just a folder that will store all your Golang related stuff. In my case I’ll create a workspace called ‘go_project’:

$ mkdir /root/go_project

A workspace needs to have 3 top level folders called pkg, bin, and src:

$ mkdir /root/go_project/{bin,pkg,src}
$ tree /root/go_project
├── bin
├── pkg
└── src

Next, you need to tell Go to use this workspace. That’s done by setting an environment variable called ‘GOPATH’. Let’s first see what GOPATH is currently set to:

$ go env
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build207657744=/tmp/go-build -gno-record-gcc-switches"

I’m using bash, so I’ll set this using the .bash_profile approach.

You may want to have several workspaces for your various Go projects. If so, then you’ll need to

Installing Golang

Installing Golang is really easy, just following the instructions in the official guide. For example, for RHEL/CentOSm we would do something like:

curl -o ${golang_archive_filename}${golang_archive_filename}
tar -C /usr/local -xzf ${golang_archive_filename}
cd /usr/local/go/bin 
cp -rfp /usr/local/go/bin/* /usr/bin/

However here are a few other ways to install Golang:

RHEL/CentOS install tips

A quick way to install Golang is via yum:

yum install golang

But note that there’s a good chance the Go version yum installs could be at least several versions behind.

MacOS install tips

You can install golang using brew. With brew it’s as simple as:

$ brew install go

Then when new version of golang comes out, you can just do:

$ brew upgrade golang

Windows Install tips

You can install Golang using chocolatey:

c:\ choco install golang

Then when new version of golang comes out, you can just do:

c:\ choco upgrade															

Golang Tutorial

What is Golang?

Golang (aka G0) is a relatively new programming language Google that has taken the IT world by storm. It was released in 2009 and already some of the biggest applications are written in Go, including Docker, Terraform, and Kubernetes.

This is a series of bitesize tutorials that’ll help you get comfortable with using Golang. This course also requires you to have some experience with Linux, especially using the Bash terminal.

What makes Golang so great?

There’s a lot to like about Golang, here are some of the main reasons why Golang has become so popular:

  1. It’s a general purpose language – meaning that it can can be used for writing low level OS level components, which is usually done in C or C++. It’s also create for developing high level

Golang – A ‘hello world’ example

Once you’ve installed Golang and set up your workspace, you’re now ready to write your hello world go program. Your Go code has to be written in the src folder, and the file needs to have the ‘.go’ extension. So I created the following file:

$ cat hello.go
package main

// this is a comment. 
import "fmt"

func main() {
    fmt.Println("hello world")

There are 2 types of Go projects you can create. One is a shared library project which is code that’s used as part of other Golang projects. The other is where the end product of a Golang project is a standalone executable binary.

The package main tells Golang that this project will be creating a standalone executable binary. Next, we declared a function called ‘main’. You

AWS Cost Explorer CLI demo – filtering costs by cost allocation tags

Here’s a quick example:

$ cat filter.json
  "Tags": {
    "Key": "role",
    "Values": ["webserver"]

$ aws ce get-cost-and-usage --time-period Start=$(date +"%Y-%m-%d" --date="-24 hours"),End=$(date +"%Y-%m-%d") --granularity=DAILY  --metrics BlendedCost --filter file://filter.json

TIMEPERIOD	2018-08-09	2018-08-08


RHCE – rough notes

page 4:

systemctl –type=service

list all running services:

systemctl –list-units –type=service

list all services, running and not running:

systemctl –list-units –type=service

page 6:

lists the units that this unit depends on:

systemctl list-dependencies UNIT

shows what other services depends on the following unit:
systemctl list-dependencies UNIT –reverse

this forcefully disables a unit, so that it doesn’t start up at boot time or manually started. this
is so to prevent accidentally starting a unit. e.g. don’t accidentally start chronyd if already using ntpd
systemctl mask unit

Opposite of umask:

systemctl umask unit

page 26

the following command is best practice because it is persistent:

nmcli dev dis device

and don’t use (because it isn’t persistent):

nmcli connection down device

page 27:

The following set’s static ip address as well as default gateway address of

nmcli con mod static-eth0 ipv4.addresses “”

note: you can omit the default gateway address.

AWS CLI with jq examples

Let’s say I have an EC2 instance with the instance id of ‘i-08725957c043b6acd’ and it has the ec2 tag: env=preprod. To pull this info out using the aws cli and jq, we run:

$ aws ec2 describe-tags --output json --filters "Name=resource-id,Values=i-08725987c041b6acd" | jq --raw-output '.Tags[]|select(.Key=="env")|.Value'

Note, you can obtain the instance_id locally like this:

$ instance_id=$(curl -s