raghurps / chaos

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

chaos

ChaosMonkey

ChaosMonkey is losely based on Netflix's project with same name. Its purpose is to bring chaos in kubernetes eco-system by randomly terminating one of the pods. This ensures that application developers are writing code that is resilient enough to recover from such random mishaps.

Installation

Requirements

In order to deploy chaosmonkey, you'll need helm CLI installed. To install helm, run:

curl https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 | bash

You'll also need access to a kubernetes cluster. If you don't have one, you can create it locally using kind and docker.

# install kind binary
go install sigs.k8s.io/kind@v0.14.0 
# create kind cluster of 2 nodes using the config file
kind create cluster --config hack/kindConfig.yaml

or

Use setup script that creates a local registry accessible at localhost:5001 and a kind cluster that can pull images from this local registry

./hack/setupKindCluster.sh

To remove this local registry and kind cluster, run:

./hack/cleanupKindCluster.sh

Steps to install

If you have make utility installed then run:

make install

or

In case you don't have make utility, use shell script install.sh

./install.sh

To provide custom image and tag name, you can provider IMAGE_NAME and IMAGE_TAG variables. e.g. if you have pushed image to you local registry:

# You can provide your own image name and tag
make IMAGE_NAME="localhost:5001/chaosmonkey" IMAGE_TAG="v0.0.1" install

or

# You can provide your own image name and tag
IMAGE_NAME="localhost:5001/chaosmonkey" IMAGE_TAG="v0.0.1" ./install.sh

Default image tag is the latest git commit id and the default image name is rpsingh/chaosmonkey.

The installation happens via helm CLI and this values.yaml file.

Steps to uninstall

# You can provide your own image name and tag
make IMAGE_NAME="localhost:5001/chaosmonkey" IMAGE_TAG="v0.0.1" uninstall

or

# You can provide your own image name and tag
IMAGE_NAME="localhost:5001/chaosmonkey" IMAGE_TAG="v0.0.1" ./uninstall.sh

How to Contribute

In order to contribute to this repo, you need to setup local dev environment.

Dev Environment

To develop and test locally, you must install

Build Image

# You can provide your own image name and tag
make IMAGE_NAME="localhost:5001/chaosmonkey" IMAGE_TAG="v0.0.1" build

or

# You can provide your own image name and tag
IMAGE_NAME="localhost:5001/chaosmonkey" IMAGE_TAG="v0.0.1" ./build.sh

Publish Image

# You can provide your own image name and tag
make IMAGE_NAME="localhost:5001/chaosmonkey" IMAGE_TAG="v0.0.1" release

or

# You can provide your own image name and tag
IMAGE_NAME="localhost:5001/chaosmonkey" IMAGE_TAG="v0.0.1" ./release.sh

Install on kubernetes cluster

# You can provide your own image name and tag
make IMAGE_NAME="localhost:5001/chaosmonkey" IMAGE_TAG="v0.0.1" install

or

# You can provide your own image name and tag
IMAGE_NAME="localhost:5001/chaosmonkey" IMAGE_TAG="v0.0.1" ./install.sh

Uninstall from kubernetes cluster

# You can provide your own image name and tag
make IMAGE_NAME="localhost:5001/chaosmonkey" IMAGE_TAG="v0.0.1" uninstall

or

# You can provide your own image name and tag
IMAGE_NAME="localhost:5001/chaosmonkey" IMAGE_TAG="v0.0.1" ./uninstall.sh

Build locally outside container

go build -o chaosmonkey cmd/chaosmonkey/main.go

For flag details

go run cmd/chaosmonkey/main.go  --help

Run unit tests

go test -v -cover ./...

or

go test -v -cover chaosmonkey.monke/chaos/...

TODO

  • Make Kubernetes client package testable
  • Add more unit tests
  • Refactor function in main package

About


Languages

Language:Go 74.5%Language:Shell 11.9%Language:Smarty 7.8%Language:Makefile 5.8%