-
Notifications
You must be signed in to change notification settings - Fork 700
ChaosCenter Development Guide
NOTE: This setup has been written on Ubuntu 20.04 LTS as the setup environment, Based on your version of Linux Distribution, some commands may vary, please find the alternative commands accordingly in case there is some syntactical difference that was missed in this guide.
Here are a few things you need to make sure are already present in your system before running Litmus locally
- Kubernetes 1.17 or later
- Helm3 or Kubectl
- Node and npm
- Docker
- Golang
- Local Kubernetes Cluster (via minikube, k3s or kind)
Backend components consist of three microservices
- GraphQL-Server
- Authentication-Server
- MongoDB
docker pull mongo:4.2
docker network create mongo-cluster
docker run -d --net mongo-cluster -p 27015:27015 --name m1 mongo:4.2 mongod --replSet rs0 --port 27015
docker run -d --net mongo-cluster -p 27016:27016 --name m2 mongo:4.2 mongod --replSet rs0 --port 27016
docker run -d --net mongo-cluster -p 27017:27017 --name m3 mongo:4.2 mongod --replSet rs0 --port 27017
# add hosts in /etc/hosts
sudo vim /etc/hosts
# add the below line
127.0.0.1 m1 m2 m3
docker exec -it m1 mongo -port 27015
config={"_id":"rs0","members":[{"_id":0,"host":"m1:27015"},{"_id":1,"host":"m2:27016"},{"_id":2,"host":"m3:27017"}]}
rs.initiate(config)
db.getSiblingDB("admin").createUser({user:"admin",pwd:"1234",roles:[{role:"root",db:"admin"}]});
NOTE: Make sure to run backend services before the frontend. If you haven’t already cloned the litmus project do so from the
litmuschaos/litmus
repository
git clone https://github.com/litmuschaos/litmus.git litmus --depth 1
a. Export the following environment variables
export DB_SERVER="mongodb://m1:27015,m2:27016,m3:27017/?replicaSet=rs0"
export DB_USER=admin
export DB_PASSWORD=1234
export JWT_SECRET=litmus-portal@123
export PORTAL_ENDPOINT=http://localhost:8080
export LITMUS_SVC_ENDPOINT=""
export SELF_AGENT=false
export INFRA_SCOPE=cluster
export INFRA_NAMESPACE=litmus
export LITMUS_PORTAL_NAMESPACE=litmus
export PORTAL_SCOPE=namespace
export SUBSCRIBER_IMAGE=litmuschaos/litmusportal-subscriber:ci
export EVENT_TRACKER_IMAGE=litmuschaos/litmusportal-event-tracker:ci
export CONTAINER_RUNTIME_EXECUTOR=k8sapi
export ARGO_WORKFLOW_CONTROLLER_IMAGE=argoproj/workflow-controller:v2.11.0
export ARGO_WORKFLOW_EXECUTOR_IMAGE=argoproj/argoexec:v2.11.0
export CHAOS_CENTER_SCOPE=cluster
export WORKFLOW_HELPER_IMAGE_VERSION=3.0.0
export LITMUS_CHAOS_OPERATOR_IMAGE=litmuschaos/chaos-operator:3.0.0
export LITMUS_CHAOS_RUNNER_IMAGE=litmuschaos/chaos-runner:3.0.0
export LITMUS_CHAOS_EXPORTER_IMAGE=litmuschaos/chaos-exporter:3.0.0
export ADMIN_USERNAME=admin
export ADMIN_PASSWORD=litmus
export VERSION=ci
export HUB_BRANCH_NAME=v2.0.x
export INFRA_DEPLOYMENTS="[\"app=chaos-exporter\", \"name=chaos-operator\", \"app=event-tracker\",\"app=workflow-controller\"]"
export INFRA_COMPATIBLE_VERSIONS='["0.2.0", "0.1.0","ci"]'
export DEFAULT_HUB_BRANCH_NAME=master
export ENABLE_INTERNAL_TLS=false
export REST_PORT=3000
export GRPC_PORT=3030
b. Run the go application
cd chaoscenter/authentication/api
go run main.go
a. Export the following environment variables
export DB_SERVER="mongodb://m1:27015,m2:27016,m3:27017/?replicaSet=rs0"
export DB_USER=admin
export DB_PASSWORD=1234
export JWT_SECRET=litmus-portal@123
export PORTAL_ENDPOINT=http://localhost:8080
export LITMUS_SVC_ENDPOINT=""
export SELF_AGENT=false
export INFRA_SCOPE=cluster
export INFRA_NAMESPACE=litmus
export LITMUS_PORTAL_NAMESPACE=litmus
export PORTAL_SCOPE=namespace
export SUBSCRIBER_IMAGE=litmuschaos/litmusportal-subscriber:ci
export EVENT_TRACKER_IMAGE=litmuschaos/litmusportal-event-tracker:ci
export CONTAINER_RUNTIME_EXECUTOR=k8sapi
export ARGO_WORKFLOW_CONTROLLER_IMAGE=argoproj/workflow-controller:v2.11.0
export ARGO_WORKFLOW_EXECUTOR_IMAGE=argoproj/argoexec:v2.11.0
export CHAOS_CENTER_SCOPE=cluster
export WORKFLOW_HELPER_IMAGE_VERSION=3.0.0
export LITMUS_CHAOS_OPERATOR_IMAGE=litmuschaos/chaos-operator:3.0.0
export LITMUS_CHAOS_RUNNER_IMAGE=litmuschaos/chaos-runner:3.0.0
export LITMUS_CHAOS_EXPORTER_IMAGE=litmuschaos/chaos-exporter:3.0.0
export ADMIN_USERNAME=admin
export ADMIN_PASSWORD=litmus
export VERSION=ci
export HUB_BRANCH_NAME=v2.0.x
export INFRA_DEPLOYMENTS="[\"app=chaos-exporter\", \"name=chaos-operator\", \"app=event-tracker\",\"app=workflow-controller\"]"
export INFRA_COMPATIBLE_VERSIONS='["0.2.0", "0.1.0","ci"]'
export DEFAULT_HUB_BRANCH_NAME=master
b. Run the go application
cd chaoscenter/graphql/server
go run server.go
NOTE: Make sure to run backend services before the frontend.
Once cloned, navigate to the web
directory inside the chaoscenter
folder
cd litmus/chaoscenter/web
When you are inside the frontend directory, install all the dependencies and run the project locally.
yarn
yarn generate-certificate
yarn dev
It’ll prompt you to start the development server at port
8185
or any other port than 3000 since it is already being used by the auth server.
Once you are able to see the Login Screen of Litmus use the following default credentials
Username: admin
Password: litmus
Use litmusctl on the same box/local cluster and connect an ns infrastructure
Use Chaoscenter to connect an Infrastructure, download the manifest and apply it on k3d/minikube. Once the pods are up(except the subscriber), run the following command:
cd subscriber
INFRA_ID=<INFRA_ID> ACCESS_KEY=<ACCESS_KEY> INFRA_SCOPE=cluster SERVER_ADDR=http://localhost:8080/query INFRA_NAMESPACE=litmus IS_INFRA_CONFIRMED="false" COMPONENTS="DEPLOYMENTS: ["app=chaos-exporter", "name=chaos-operator", "app=workflow-controller"]" START_TIME=1631089756 VERSION="ci" AGENT_POD="subscriber-78f6bd4db5-ck5d9" SKIP_
SSL_VERIFY="false" go run subscriber.go -kubeconfig ~/.kube/config