Skip to content

Commit f3fd560

Browse files
committed
Updateed current version docs fot developer guide
Signed-off-by: DongYoung Kim <[email protected]>
1 parent a21f756 commit f3fd560

File tree

2 files changed

+224
-0
lines changed

2 files changed

+224
-0
lines changed
Lines changed: 219 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,219 @@
1+
---
2+
id: chaoscenter-developer-guide
3+
title: ChaosCenter Developer Guide
4+
sidebar_label: ChaosCenter Developer Guide
5+
---
6+
7+
---
8+
9+
## **Prerequisites**
10+
:::note
11+
This document is ietented to be implemented locally. Please do not use in dev or prod environmentss
12+
:::
13+
14+
- Kubernetes 1.17 or later
15+
- Helm3 or Kubectl
16+
- Node and npm
17+
- Docker
18+
- Golang
19+
- Local Kubernetes Cluster (via minikube, k3s or kind)
20+
21+
## **Control Plane**
22+
Backend components consist of three microservices
23+
1. GraphQL-Server
24+
2. Authentication-Server
25+
3. MongoDB
26+
27+
Frontend component
28+
1. React
29+
30+
## **Steps to run the Control Plane**
31+
32+
### 1. Run MongoDB
33+
34+
Step-1: Pull and run the image
35+
36+
```bash
37+
docker pull mongo:4.2
38+
39+
docker network create mongo-cluster
40+
41+
docker run -d --net mongo-cluster -p 27015:27015 --name m1 mongo:4.2 mongod --replSet rs0 --port 27015
42+
docker run -d --net mongo-cluster -p 27016:27016 --name m2 mongo:4.2 mongod --replSet rs0 --port 27016
43+
docker run -d --net mongo-cluster -p 27017:27017 --name m3 mongo:4.2 mongod --replSet rs0 --port 27017
44+
```
45+
46+
Step-2: Add hosts
47+
48+
Windows
49+
```bash
50+
# add hosts in hosts
51+
notepad C:\Windows\System32\drivers\etc\hosts
52+
53+
# add the below line
54+
127.0.0.1 m1 m2 m3
55+
```
56+
57+
Linux/Mac
58+
```bash
59+
# add hosts in hosts
60+
sudo vim /etc/hosts
61+
62+
# add the below line
63+
127.0.0.1 m1 m2 m3
64+
```
65+
66+
67+
Step-3: Configure the mongoDB replica set
68+
69+
```bash
70+
docker exec -it m1 mongo -port 27015
71+
72+
config={"_id":"rs0","members":[{"_id":0,"host":"m1:27015"},{"_id":1,"host":"m2:27016"},{"_id":2,"host":"m3:27017"}]}
73+
74+
rs.initiate(config)
75+
76+
db.getSiblingDB("admin").createUser({user:"admin",pwd:"1234",roles:[{role:"root",db:"admin"}]});
77+
```
78+
79+
### 2. Run the Authentication Server
80+
81+
:::note
82+
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
83+
:::
84+
85+
```bash
86+
git clone https://github.com/litmuschaos/litmus.git litmus --depth 1
87+
```
88+
89+
90+
Step-1: Export the following environment variables
91+
92+
```bash
93+
export ADMIN_USERNAME=admin
94+
export ADMIN_PASSWORD=litmus
95+
export DB_SERVER="mongodb://m1:27015,m2:27016,m3:27017/?replicaSet=rs0"
96+
export DB_USER=admin
97+
export DB_PASSWORD=1234
98+
export REST_PORT=3000
99+
export GRPC_PORT=3030
100+
```
101+
102+
Windows
103+
Docker or Hyper-V is reserving that port range. You can use 3030 ports by running the command below
104+
105+
```shell
106+
netsh interface ipv4 show excludedportrange protocol=tcp
107+
net stop winnat
108+
netsh int ipv4 add excludedportrange protocol=tcp startport=3030 numberofports=1
109+
net start winnat
110+
```
111+
112+
Step-2: Run the go application
113+
114+
```bash
115+
cd chaoscenter/authentication/api
116+
go run main.go
117+
```
118+
119+
### 3. Run the GraphQL Server
120+
121+
Step-1: Export the following environment variables
122+
123+
```bash
124+
export DB_SERVER="mongodb://m1:27015,m2:27016,m3:27017/?replicaSet=rs0"
125+
export DB_USER=admin
126+
export DB_PASSWORD=1234
127+
export JWT_SECRET=litmus-portal@123
128+
export PORTAL_ENDPOINT=http://localhost:8080
129+
export LITMUS_SVC_ENDPOINT=""
130+
export SELF_AGENT=false
131+
export INFRA_SCOPE=cluster
132+
export INFRA_NAMESPACE=litmus
133+
export LITMUS_PORTAL_NAMESPACE=litmus
134+
export PORTAL_SCOPE=namespace
135+
export SUBSCRIBER_IMAGE=litmuschaos/litmusportal-subscriber:ci
136+
export EVENT_TRACKER_IMAGE=litmuschaos/litmusportal-event-tracker:ci
137+
export CONTAINER_RUNTIME_EXECUTOR=k8sapi
138+
export ARGO_WORKFLOW_CONTROLLER_IMAGE=argoproj/workflow-controller:v2.11.0
139+
export ARGO_WORKFLOW_EXECUTOR_IMAGE=argoproj/argoexec:v2.11.0
140+
export CHAOS_CENTER_SCOPE=cluster
141+
export WORKFLOW_HELPER_IMAGE_VERSION=3.0.0
142+
export LITMUS_CHAOS_OPERATOR_IMAGE=litmuschaos/chaos-operator:3.0.0
143+
export LITMUS_CHAOS_RUNNER_IMAGE=litmuschaos/chaos-runner:3.0.0
144+
export LITMUS_CHAOS_EXPORTER_IMAGE=litmuschaos/chaos-exporter:3.0.0
145+
export ADMIN_USERNAME=admin
146+
export ADMIN_PASSWORD=litmus
147+
export VERSION=ci
148+
export HUB_BRANCH_NAME=v2.0.x
149+
export INFRA_DEPLOYMENTS="[\"app=chaos-exporter\", \"name=chaos-operator\", \"app=event-tracker\",\"app=workflow-controller\"]"
150+
export INFRA_COMPATIBLE_VERSIONS='["0.2.0", "0.1.0","ci"]'
151+
export DEFAULT_HUB_BRANCH_NAME=master
152+
```
153+
154+
Step-2: Run the go application
155+
156+
```bash
157+
cd chaoscenter/graphql/server
158+
go run server.go
159+
```
160+
161+
### 4. Run Frontend
162+
163+
:::note
164+
Make sure to run backend services before the frontend.
165+
:::
166+
167+
Step-1: Install all the dependencies
168+
169+
```bash
170+
cd litmus/chaoscenter/web
171+
yarn
172+
```
173+
174+
Step-2: Generate the ssl certificate
175+
176+
Linux/Mac
177+
```bash
178+
yarn generate-certificate
179+
```
180+
181+
Windows
182+
The command you run is in the script/generate-certificate.sh file, but it doesn't work in a Windows environment, so please run the script below instead
183+
```bash
184+
mkdir -p certificates
185+
186+
openssl req -x509 -newkey rsa:4096 -keyout certificates/localhost-key.pem -out certificates/localhost.pem -days 365 -nodes -subj '//C=US'
187+
```
188+
189+
Step-3: Run the frontend project
190+
191+
```bash
192+
yarn dev
193+
```
194+
195+
> 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.
196+
197+
Once you are able to see the Login Screen of Litmus use the following default credentials
198+
199+
```
200+
Username: admin
201+
Password: litmus
202+
```
203+
204+
<img src={require('../assets/login.png').default} width="800" />
205+
206+
207+
## **Steps to connect Chaos Infrastructure**
208+
### Using Litmusctl
209+
Use [litmusctl](https://github.com/litmuschaos/litmusctl) on the same box/local cluster and connect an ns infrastructure
210+
211+
### Using Chaoscenter
212+
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:
213+
214+
```shell
215+
cd subscriber
216+
217+
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_
218+
SSL_VERIFY="false" go run subscriber.go -kubeconfig ~/.kube/config
219+
```

website/versioned_sidebars/version-3.9.1-sidebars.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,11 @@
115115
"user-guides/uninstall-litmus"
116116
]
117117
},
118+
{
119+
"Developer Guide": [
120+
"developer-guide/chaoscenter-developer-guide"
121+
]
122+
},
118123
{
119124
"Litmusctl": [
120125
"litmusctl/installation",

0 commit comments

Comments
 (0)