Skip to content

Latest commit

 

History

History
342 lines (226 loc) · 8.56 KB

SETUP.md

File metadata and controls

342 lines (226 loc) · 8.56 KB

Environment Overview

Cloning Walkthrough Repository

Before we get started setting up the environment, we first need to clone this repository locally for access to the required files

$ git clone https://github.com/chaostoolkit/walkthrough.git

Installation of a Local Kubernetes

The labs run against a Kubernetes cluster, supported by the kubectl package.

Locally, for instance, you can use:

  • minikube - Linux/MacOS/Windows
  • microk8s - Linux

Note: microk8s is a native Linux application and therefore all instructions will be accordingly so. In addition to these, you will need Python 3.6 or above on the client side

Minikube - Linux/MacOS/Windows

Minikube can be installed by following the installation steps on the Minikube Start docs. The minikube cluster requires a docker driver to be initiated and hence docker must be installed. You can install docker from the Docker Hub. The cluster can then be initiated and run

$ minikube start --driver docker --kubernetes-version v1.19.1

Microk8s - Linux

You can install microk8s using:

$ sudo snap install microk8s --classic --channel=1.19

Now you have microk8s installed, you can start your cluster using:

$ microk8s start

After initiating the microk8s cluster, you will need to install a couple of add-ons:

$ microk8s enable dns rbac

Please review the microk8s documentation for further information.

Kubectl

For both minikube and microk8s, kubectl is required. Even if you have kubectl installed, for the purpose of this demonstration, a specific version (v1.19.1) is required so following the installation steps is necessary to replace the current version. You can check the current version, if installed, using:

$ kubectl version --client

Linux

You can install Kubectl v1.19.1 using:

$ curl -LO https://dl.k8s.io/release/v1.19.1/bin/linux/amd64/kubectl
$ sudo install -o root -g root -m 0755 kubectl /usr/local/bin/kubectl

For further instructions, and for information about downloading the latest kubectl version for Linux after completing the demonstration, consult the Kubernetes Installation Documentation

Mac OS

You can install Kubectl v1.19.1 for Intel macOS using:

$ curl -LO "https://dl.k8s.io/release/v1.19.1/bin/darwin/amd64/kubectl"

And for Apple Silicon macOS using:

$ curl -LO "https://dl.k8s.io/release/v1.19.1/bin/darwin/arm64/kubectl"

Once installed, the kubectl binary needs to be made executable and its path rooted:

$ chmod +x ./kubectl
$ sudo mv ./kubectl /usr/local/bin/kubectl
$ sudo chown root: /usr/local/bin/kubectl

For further instructions, and for information about downloading the latest kubectl version for Mac OS after completing the demonstration, consult the Kubernetes Installation Documentation

Windows

You can install Kubectl v1.19.1 by running the Command Prompt as Administrator and using:

$ curl -LO https://dl.k8s.io/release/v1.19.1/bin/windows/amd64/kubectl.exe
$ move kubectl.exe C:\Windows\System32

For further instructions, and for information about downloading the latest kubectl version for Windows after completing the demonstration, consult the Kubernetes Installation Documentation

Prometheus

We use the Prometheus operator which will run in the monitoring namespace by default and expose:

  • Prometheus
  • Grafana
  • Alert Manager

You can install Prometheus in various ways, see below for three of them.

Using the Prometheus Operator via Helm

$ helm repo add prometheus-community https://prometheus-community.github.io/helm-charts
$ helm repo update
$ helm upgrade --install prometheus prometheus-community/kube-prometheus-stack

Minikube Installation - Linux/MacOS/Windows

$ git clone https://github.com/prometheus-operator/kube-prometheus
$ kubectl apply -f kube-prometheus/manifests/setup/
$ kubectl apply -f kube-prometheus/manifests/

Microk8s Installation - Linux

$ microk8s enable prometheus

Prometheus Services

Once installed, you can view the services running

$ kubectl -n monitoring get all

Chaos Mesh

Chaos Mesh is a powerful fault injection tool for Kubernetes which can create turbulences on physical and OS resources.

It is used by the Chaos Toolkit in rich Chaos Engineering experiments. To install and run Chaos Mesh, open a new terminal window and run:

$ curl -sSL https://mirrors.chaos-mesh.org/v1.0.2/install.sh | bash

See all its services running:

$ kubectl -n chaos-testing get all

You can setup the dashboard in a new terminal window as follows:

$ kubectl -n chaos-testing port-forward --address 0.0.0.0 service/chaos-dashboard 2333:2333

You can then access the dashboard by going to http://localhost:2333/

Traefik

We use traefik as an ingress provider to service our application.

$ kubectl apply -f walkthrough/manifests/traefik.yaml

Installation of Chaos Toolkit and its Dependencies

The Chaos Toolkit is the Chaos Engineering automation framework from Reliably. It is an open source project written in Python. Assuming you have a proper Python 3.6 available, you should be able to install it as follows:

$ pip install chaostoolkit

You can verify it is now available by running:

$ chaos info core

In itself, Chaos Toolkit does not have any capabilities to operate systems. You need to installation that target these systems.

$ pip install chaostoolkit-kubernetes chaostoolkit-prometheus chaostoolkit-addons jsonpath2

You can verify they are now available by running:

$ chaos info extensions

Finally, we install a plugin to generate reports of experiment runs:

$ pip install chaostoolkit-reporting

Installation of Experiment Dependencies

Vegeta

Vegeta is a standalone binary that can induce load onto a web application. We often use it for simple load during an experiment to understand how the traffic is impacted by an experiment.

Linux

You will first need to install wget using:

$ apt-get install wget

You can then install Vegeta v12.8.3 for Linux AMD64 using:

$ wget https://github.com/tsenart/vegeta/releases/download/v12.8.3/vegeta-12.8.3-linux-amd64.tar.gz
$ tar -zxf vegeta-12.8.3-linux-amd64.tar.gz

Or for Linux ARM64 using:

$ wget https://github.com/tsenart/vegeta/releases/download/v12.8.3/vegeta-12.8.3-linux-arm64.tar.gz
$ tar -zxf vegeta-12.8.3-linux-arm64.tar.gz

Once installed, the vegeta binary needs to be moved and rooted

$ sudo mv ./vegeta /usr/local/bin/
$ sudo chmod +x /usr/local/bin/vegeta

MacOS

For macOS, you can install Vegeta via the Homebrew package manager:

$ brew install vegeta

Windows

You will first need to install wget by running the Command Prompt as Administrator and using:

$ curl -LO https://eternallybored.org/misc/wget/1.21.1/64.wget.exe
$ move wget.exe C:\Windows\System32

You will also need to install unzip by running the Command Prompt as Administrator and using:

$ curl -LO www.stahlworks.com/dev/unzip.exe
$ move unzip.exe C:\Windows\System32

You can then install Vegeta v12.8.3 into a temporary directory by running the Command Prompt as Administrator and using:

$ mkdir vegeta && cd vegeta
$ wget https://github.com/tsenart/vegeta/releases/download/v12.8.3/vegeta-12.8.3-windows-amd64.zip
$ unzip vegeta-12.8.3-windows-amd64.zip
$ move vegeta.exe C:\Windows\System32

The temporary directory can then be deleted which will ask for a confirmation:

$ cd .. && rmdir /s vegeta

Installation of the Applications

You can now install the application services:

$ kubectl apply -f walkthrough/manifests/all.yaml