Skip to content

Commit be32ed8

Browse files
committed
Add developer guide docs for 3.10.0
Signed-off-by: DongYoung Kim <[email protected]>
1 parent a300dfb commit be32ed8

File tree

2 files changed

+272
-0
lines changed

2 files changed

+272
-0
lines changed
Lines changed: 267 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,267 @@
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 intended to be implemented locally. Please do not use in dev or prod environments.
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:5
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+
import Tabs from '@theme/Tabs';
49+
import TabItem from '@theme/TabItem';
50+
51+
<Tabs groupId="operating-systems">
52+
<TabItem value="win" label="Windows">
53+
54+
```bash
55+
# add hosts in hosts
56+
notepad C:\Windows\System32\drivers\etc\hosts
57+
58+
# add the below line
59+
127.0.0.1 m1 m2 m3
60+
```
61+
62+
</TabItem>
63+
<TabItem value="linux" label="macOS/Linux">
64+
65+
```bash
66+
# add hosts in hosts
67+
sudo vim /etc/hosts
68+
69+
# add the below line
70+
127.0.0.1 m1 m2 m3
71+
```
72+
73+
</TabItem>
74+
</Tabs>
75+
76+
77+
Step-3: Configure the mongoDB replica set
78+
79+
```bash
80+
docker exec -it m1 mongo -port 27015
81+
82+
config={"_id":"rs0","members":[{"_id":0,"host":"m1:27015"},{"_id":1,"host":"m2:27016"},{"_id":2,"host":"m3:27017"}]}
83+
84+
rs.initiate(config)
85+
86+
db.getSiblingDB("admin").createUser({user:"admin",pwd:"1234",roles:[{role:"root",db:"admin"}]});
87+
```
88+
89+
### 2. Run the Authentication Server
90+
91+
:::note
92+
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
93+
:::
94+
95+
```bash
96+
git clone https://github.com/litmuschaos/litmus.git litmus --depth 1
97+
```
98+
99+
100+
Step-1: Export the following environment variables
101+
102+
```bash
103+
export ADMIN_USERNAME=admin
104+
export ADMIN_PASSWORD=litmus
105+
export DB_SERVER="mongodb://m1:27015,m2:27016,m3:27017/?replicaSet=rs0"
106+
export DB_USER=admin
107+
export DB_PASSWORD=1234
108+
export JWT_SECRET=litmus-portal@123
109+
export PORTAL_ENDPOINT=http://localhost:8080
110+
export LITMUS_SVC_ENDPOINT=""
111+
export SELF_AGENT=false
112+
export INFRA_SCOPE=cluster
113+
export INFRA_NAMESPACE=litmus
114+
export LITMUS_PORTAL_NAMESPACE=litmus
115+
export PORTAL_SCOPE=namespace
116+
export SUBSCRIBER_IMAGE=litmuschaos/litmusportal-subscriber:ci
117+
export EVENT_TRACKER_IMAGE=litmuschaos/litmusportal-event-tracker:ci
118+
export CONTAINER_RUNTIME_EXECUTOR=k8sapi
119+
export ARGO_WORKFLOW_CONTROLLER_IMAGE=argoproj/workflow-controller:v2.11.0
120+
export ARGO_WORKFLOW_EXECUTOR_IMAGE=argoproj/argoexec:v2.11.0
121+
export CHAOS_CENTER_SCOPE=cluster
122+
export WORKFLOW_HELPER_IMAGE_VERSION=3.0.0
123+
export LITMUS_CHAOS_OPERATOR_IMAGE=litmuschaos/chaos-operator:3.0.0
124+
export LITMUS_CHAOS_RUNNER_IMAGE=litmuschaos/chaos-runner:3.0.0
125+
export LITMUS_CHAOS_EXPORTER_IMAGE=litmuschaos/chaos-exporter:3.0.0
126+
export ADMIN_USERNAME=admin
127+
export ADMIN_PASSWORD=litmus
128+
export VERSION=ci
129+
export HUB_BRANCH_NAME=v2.0.x
130+
export INFRA_DEPLOYMENTS="[\"app=chaos-exporter\", \"name=chaos-operator\", \"app=event-tracker\",\"app=workflow-controller\"]"
131+
export INFRA_COMPATIBLE_VERSIONS='["0.2.0", "0.1.0","ci"]'
132+
export DEFAULT_HUB_BRANCH_NAME=master
133+
export ENABLE_INTERNAL_TLS=false
134+
export REST_PORT=3000
135+
export GRPC_PORT=3030
136+
```
137+
138+
<Tabs groupId="operating-systems">
139+
<TabItem value="win" label="Windows">
140+
141+
Docker or Hyper-V is reserving that port range. You can use 3030 ports by running the command below
142+
143+
```bash
144+
netsh interface ipv4 show excludedportrange protocol=tcp
145+
net stop winnat
146+
netsh int ipv4 add excludedportrange protocol=tcp startport=3030 numberofports=1
147+
net start winnat
148+
```
149+
150+
</TabItem>
151+
</Tabs>
152+
153+
Step-2: Run the go application
154+
155+
```bash
156+
cd chaoscenter/authentication/api
157+
go run main.go
158+
```
159+
160+
### 3. Run the GraphQL Server
161+
162+
Step-1: Export the following environment variables
163+
164+
```bash
165+
export DB_SERVER="mongodb://m1:27015,m2:27016,m3:27017/?replicaSet=rs0"
166+
export DB_USER=admin
167+
export DB_PASSWORD=1234
168+
export JWT_SECRET=litmus-portal@123
169+
export PORTAL_ENDPOINT=http://localhost:8080
170+
export LITMUS_SVC_ENDPOINT=""
171+
export SELF_AGENT=false
172+
export INFRA_SCOPE=cluster
173+
export INFRA_NAMESPACE=litmus
174+
export LITMUS_PORTAL_NAMESPACE=litmus
175+
export PORTAL_SCOPE=namespace
176+
export SUBSCRIBER_IMAGE=litmuschaos/litmusportal-subscriber:ci
177+
export EVENT_TRACKER_IMAGE=litmuschaos/litmusportal-event-tracker:ci
178+
export CONTAINER_RUNTIME_EXECUTOR=k8sapi
179+
export ARGO_WORKFLOW_CONTROLLER_IMAGE=argoproj/workflow-controller:v2.11.0
180+
export ARGO_WORKFLOW_EXECUTOR_IMAGE=argoproj/argoexec:v2.11.0
181+
export CHAOS_CENTER_SCOPE=cluster
182+
export WORKFLOW_HELPER_IMAGE_VERSION=3.0.0
183+
export LITMUS_CHAOS_OPERATOR_IMAGE=litmuschaos/chaos-operator:3.0.0
184+
export LITMUS_CHAOS_RUNNER_IMAGE=litmuschaos/chaos-runner:3.0.0
185+
export LITMUS_CHAOS_EXPORTER_IMAGE=litmuschaos/chaos-exporter:3.0.0
186+
export ADMIN_USERNAME=admin
187+
export ADMIN_PASSWORD=litmus
188+
export VERSION=ci
189+
export HUB_BRANCH_NAME=v2.0.x
190+
export INFRA_DEPLOYMENTS="[\"app=chaos-exporter\", \"name=chaos-operator\", \"app=event-tracker\",\"app=workflow-controller\"]"
191+
export INFRA_COMPATIBLE_VERSIONS='["0.2.0", "0.1.0","ci"]'
192+
export DEFAULT_HUB_BRANCH_NAME=master
193+
```
194+
195+
Step-2: Run the go application
196+
197+
```bash
198+
cd chaoscenter/graphql/server
199+
go run server.go
200+
```
201+
202+
### 4. Run Frontend
203+
204+
:::note
205+
Make sure to run backend services before the frontend.
206+
:::
207+
208+
Step-1: Install all the dependencies
209+
210+
```bash
211+
cd litmus/chaoscenter/web
212+
yarn
213+
```
214+
215+
Step-2: Generate the ssl certificate
216+
<Tabs groupId="operating-systems">
217+
<TabItem value="win" label="Windows">
218+
219+
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
220+
221+
```bash
222+
mkdir -p certificates
223+
224+
openssl req -x509 -newkey rsa:4096 -keyout certificates/localhost-key.pem -out certificates/localhost.pem -days 365 -nodes -subj '//C=US'
225+
```
226+
227+
</TabItem>
228+
<TabItem value="linux" label="macOS/Linux">
229+
230+
```bash
231+
yarn generate-certificate
232+
```
233+
234+
</TabItem>
235+
</Tabs>
236+
237+
Step-3: Run the frontend project
238+
239+
```bash
240+
yarn dev
241+
```
242+
243+
> 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.
244+
245+
Once you are able to see the Login Screen of Litmus use the following default credentials
246+
247+
```
248+
Username: admin
249+
Password: litmus
250+
```
251+
252+
<img src={require('../assets/login.png').default} width="800" />
253+
254+
255+
## **Steps to connect Chaos Infrastructure**
256+
### Using Litmusctl
257+
Use [litmusctl](https://github.com/litmuschaos/litmusctl) on the same box/local cluster and connect an ns infrastructure
258+
259+
### Using Chaoscenter
260+
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:
261+
262+
```bash
263+
cd subscriber
264+
265+
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_
266+
SSL_VERIFY="false" go run subscriber.go -kubeconfig ~/.kube/config
267+
```

website/versioned_sidebars/version-3.10.0-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)