Local Kubernetes
First encounter with the pilot

If you are wondering for a while what Kubernetes and how I get it locally, this could be a good place to start.

Kubernetes logo

Well, no really, if you want to start with Kubernetes, I would recommend reading a bit about it before getting to your local single-node cluster. Here are some free resources to get you started:

After reviewing some material, you are ready to start creating your local cluster, and, basically, you don’t need the rest of this page, but there are always some tweaks here and there that could be useful. We have at least two options to install a local single-node Kubernetes cluster:

As an example, I will be describing here the steps to set up a TICK stack on your local single-node Kubernetes cluster on a Mac with Homebrew.

Prerequisites

You need to have installed on your Mac:

Step 1: Install minikube and kubectl

In addition to minikube, you need kubectl to send commands to the cluster. This is how you brew it:

$ brew update

$ brew install kubectl

$ brew cask install minikube

To check the installation:

$ minikube version
minikube version: v0.25.0

$ kubectl version --client
Client Version: version.Info{Major:"1", Minor:"9", GitVersion:"v1.9.3", GitCommit:"d2835416544f298c919e2ead3be3d0864b52323b",
GitTreeState:"clean", BuildDate:"2018-02-09T21:51:54Z", GoVersion:"go1.9.4", Compiler:"gc", Platform:"darwin/amd64"}

Start minikube with the following command:

$ minikube start --vm-driver=virtualbox

You need to be connected to the Internet as it will be downloading the iso needed to create the VM. It will take a while. Especially, if you are at the office. When it is done, you can check the cluster status with:

$ minikube status
minikube: Running
cluster: Running
kubectl: Correctly Configured: pointing to minikube-vm at 192.168.99.100

The cluster is ok, now run the dashboard for the first time:

minikube dashboard

Step 2: Install helm and some charts

Why install this when we can configure everything with kubectl? Sure, we can do that, but it is a long road. Helm is a package manager for Kubernetes, and it will make our life easier. We just brew it like this:

brew install kubernetes-helm

Helms “packages” or application are called charts. We can get some charts from a Github repo until we have our own:

git clone https://github.com/kubernetes/charts.git

Change directory to charts/stable. Each directory there is a chart for us to use.

Step 3: Installing the TICK

We need to install four pods to have the TICK stack running: Influxdb, Telegraf, Chronograf, and Kapacitor.

TICK [Source: https://www.influxdata.com/time-series-platform/]

We have the charts on the repo we just clone, but we need some adjustment to them first:

-# influxURL: http://influxdb-influxdb.tick:8086
+influxURL: http://data-influxdb.tick:8086
-        urls: []
-          # - "http://data-influxdb.tick:8086"
+        urls:
+          - "http://data-influxdb.tick:8086"

Now we are ready to create the pods with helm.

$ pwd
<WHERE_YOU_PUT_IT>/charts/stable
$ helm install --name data --namespace tick ./influxdb/
$ helm install --name polling --namespace tick ./telegraf
$ helm install --name alerts --namespace tick ./kapacitor/
$ helm install --name dash --namespace tick ./chronograf/

Check the pods are running:

$ kubectl get pods -n tick -w
NAME                                READY     STATUS    RESTARTS   AGE
alerts-kapacitor-5d948b499f-pdcd5   1/1       Running   0          26s
dash-chronograf-65bff774dd-lhpzn    1/1       Running   0          20s
data-influxdb-5596c9b8b4-tghr5      1/1       Running   0          1m
polling-telegraf-ds-zg7zs           1/1       Running   0          36s

If something goes wrong with some of them, you can delete the pods with the following commands:

$ helm del --purge polling
$ helm del --purge dash
$ helm del --purge alerts
$ helm del --purge data

All the pods are created, but they are not accessible from you host because there is no ingress or port forward. It is better to try a port forwarding at this point with this command:

kubectl port-forward dash-chronograf-65bff774dd-lhpzn 8888:8888 -n tick

The exact name of the pod won’t be the same. You should see what is the real name on your system for the pod dash-chronograf-****.

You can get the IP address of your minikube with:

minikube ip

Open a browser to that IP and the port 8888 and you should see the dashboard.

Congratulations! You have your very own Kubernetes running…. ok… sort of… (wink)

*****
Written by Darien Martinez Torres on 22 February 2018