Skip to content

Commit c370713

Browse files
committed
Add: build-guide.md using Makefile
1 parent 64ae7c5 commit c370713

File tree

2 files changed

+195
-1
lines changed

2 files changed

+195
-1
lines changed

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ The desired state of a distributed Gatling load testing is described through a K
1919
- Horizontal scaling: number of pods running in parallel during a load testing can be configured
2020
- Vertical scaling: CPU and RAM resource allocation for Gatling runner Pod can be configured
2121
- Allows Gatling load testing to start running at a specific time
22-
- By default, the Gatling load testing starts running as soon as the runner Pod's init container gets ready. By specifing the start time, the Gatling load testing waits to start running until the specified time
22+
- By default, the Gatling load testing starts running as soon as the runner Pod's init container gets ready. By specifying the start time, the Gatling load testing waits to start running until the specified time
2323
- Gatling Pod attributions
2424
- Gatling runtime container image
2525
- [rclone](https://rclone.org/) container image
@@ -43,11 +43,13 @@ The desired state of a distributed Gatling load testing is described through a K
4343
## Quick Start
4444

4545
- [Quick Start Guide](docs/quickstart-guide.md)
46+
4647
## Documentations
4748

4849
- [Architecture](docs/architecture.md)
4950
- [Gatling CRD Reference](docs/api.md)
5051
- [User Guide](docs/user-guide.md)
52+
- [How to build Gatling Operator](docs/user-guide.md)
5153

5254
## Contributing
5355

docs/build-guide.md

Lines changed: 192 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,192 @@
1+
# How to build and run Gatling Operator
2+
3+
<!-- TOC -->
4+
<!-- /TOC -->
5+
6+
This is the guide for how to build Gatling Operator from source code.
7+
And run sample in your local environment.
8+
In this guide, we use makefile to build and run Gatling Operator.
9+
10+
## Pre-requisites
11+
12+
### Get the Source code
13+
14+
The main repository is `st-tech/gatling-operator`.
15+
This contains the Gatling Operator source code and the build scripts.
16+
17+
```
18+
git clone https://github.com/st-tech/gatling-operator
19+
```
20+
21+
### Install the tools
22+
23+
- [kubectl](https://kubernetes.io/docs/tasks/tools/)
24+
- [kind](https://kind.sigs.k8s.io/docs/user/quick-start/#installation)
25+
- [go](https://go.dev/doc/install)
26+
- go version must be 1.17
27+
28+
## Create a Kubernetes cluster
29+
30+
Create a Kubernetes cluster for test Gatling Operator sample using kind.
31+
32+
```bash
33+
make kind-create
34+
```
35+
36+
<details>
37+
<summary>sample output</summary>
38+
39+
```bash
40+
❯ make kind-install
41+
42+
No kind clusters found.
43+
Creating Cluster
44+
kind create cluster --name "gatling-cluster" --image=kindest/node:v1.19.11 --config ~/github/gatling-operator/config/kind/cluster.yaml
45+
Creating cluster "gatling-cluster" ...
46+
✓ Ensuring node image (kindest/node:v1.19.11) 🖼
47+
✓ Preparing nodes 📦 📦 📦
48+
✓ Writing configuration 📜
49+
✓ Starting control-plane 🕹️
50+
✓ Installing CNI 🔌
51+
✓ Installing StorageClass 💾
52+
✓ Joining worker nodes 🚜
53+
Set kubectl context to "kind-gatling-cluster"
54+
You can now use your cluster with:
55+
56+
kubectl cluster-info --context kind-gatling-cluster
57+
```
58+
59+
</details>
60+
61+
`make kind-create` command creates a Kubernetes cluster named `gatling-cluster` using kind.
62+
You can check the cluster details with the following commands.
63+
Get node information with kubectl and check that one control plane and one worker are ready.
64+
65+
```bash
66+
❯ kind get clusters
67+
gatling-cluster
68+
❯ kubectl get node
69+
NAME STATUS ROLES AGE VERSION
70+
gatling-cluster-control-plane Ready master 150m v1.19.11
71+
gatling-cluster-worker Ready <none> 150m v1.19.11
72+
```
73+
74+
If your cluster contexts are not set, you can set the contexts with the following command.
75+
76+
```bash
77+
kubectl config get-contexts
78+
kubectl config use-context kind-gatling-cluster
79+
```
80+
81+
## Build & Deploy Gatling Operator
82+
83+
1. Build Gatling Operator with makefile.
84+
85+
```bash
86+
make build
87+
```
88+
89+
2. Install CRD to your Kubernetes cluster.
90+
91+
```bash
92+
make install-crd
93+
```
94+
95+
You can check the Gatling Operator CRD with the following command.
96+
97+
```bash
98+
❯ kubectl get crd
99+
NAME CREATED AT
100+
gatlings.gatling-operator.tech.zozo.com 2023-08-01T04:43:54Z
101+
```
102+
103+
3. Try to run Controller Manager in local
104+
105+
```bash
106+
make run
107+
```
108+
109+
The commands runs Gatling Operator Controller Manager in your local environment. You can stop in ctrl+c.
110+
111+
```
112+
~/github/gatling-operator/bin/controller-gen "crd:trivialVersions=true,preserveUnknownFields=false" rbac:roleName=manager-role webhook paths="./..." output:crd:artifacts:config=config/crd/bases
113+
~/github/gatling-operator/bin/controller-gen object:headerFile="hack/boilerplate.go.txt" paths="./..."
114+
go fmt ./...
115+
api/v1alpha1/zz_generated.deepcopy.go
116+
go vet ./...
117+
go run ./main.go
118+
2021-10-05T11:26:35.704+0900 INFO controller-runtime.metrics metrics server is starting to listen {"addr": ":8080"}
119+
2021-10-05T11:26:35.705+0900 INFO setup starting manager
120+
2021-10-05T11:26:35.705+0900 INFO controller-runtime.manager starting metrics server {"path": "/metrics"}
121+
2021-10-05T11:26:35.705+0900 INFO controller-runtime.manager.controller.gatling Starting EventSource {"reconciler group": "gatling-operator.tech.zozo.com", "reconciler kind": "Gatling", "source": "kind source: /, Kind="}
122+
2021-10-05T11:26:35.810+0900 INFO controller-runtime.manager.controller.gatling Starting Controller {"reconciler group": "gatling-operator.tech.zozo.com", "reconciler kind": "Gatling"}
123+
2021-10-05T11:26:35.810+0900 INFO controller-runtime.manager.controller.gatling Starting workers {"reconciler group": "gatling-operator.tech.zozo.com", "reconciler kind": "Gatling", "worker count": 1}
124+
... snip...
125+
```
126+
127+
4. Build Docker image
128+
129+
```
130+
: This build command image tag is %Y%m%d-%H%M%S format Timestamp
131+
make docker-build
132+
: You can define Image name and tag in this command
133+
make docker-build IMG=<your-registry>/zozo-gatling-operator:<tag>
134+
```
135+
136+
<details>
137+
<summary>Sample</summary>
138+
139+
```bash
140+
❯ DOCKER_REGISTRY=1234567890.dkr.ecr.ap-northeast-1.amazonaws.com
141+
❯ DOCKER_IMAGE_REPO=zozo-gatling-operator
142+
❯ DOCKER_IMAGE_TAG=v0.0.1
143+
❯ make docker-build IMG=${DOCKER_REGISTRY}/${DOCKER_IMAGE_REPO}:${DOCKER_IMAGE_TAG}
144+
❯ docker images
145+
REPOSITORY TAG IMAGE ID CREATED SIZE
146+
1234567890.dkr.ecr.ap-northeast-1.amazonaws.com/zozo-gatling-operator v0.0.1 c66287dc8dc4 3 hours ago 46.2MB
147+
```
148+
149+
</details>
150+
151+
5. Deploy Controller to Gatling Operator
152+
153+
- Deploy to Local Kind Cluster
154+
155+
```bash
156+
make kind-deploy
157+
```
158+
159+
- Deploy to Remote k8s Cluster
160+
161+
```bash
162+
make deploy IMG=${DOCKER_REGISTRY}/${DOCKER_IMAGE_REPO}:${DOCKER_IMAGE_TAG}
163+
```
164+
165+
- You can check gatling-operator controller forom the following command.
166+
167+
```bash
168+
❯ kubectl get pods -n gatling-system
169+
NAME READY STATUS RESTARTS AGE
170+
gatling-operator-controller-manager-579bd7bc49-h46l2 2/2 Running 0 31m
171+
```
172+
173+
6. Deploy sample scenario and check Gatling Operator works
174+
175+
```bash
176+
kustomize build config/samples | kubectl apply -f -
177+
```
178+
179+
## Create All in One manifest
180+
181+
This command creates all in one manifest for Gatling Operator.
182+
All in One manifest create CRD and Gatling Operator Controller.
183+
184+
```bash
185+
make manifests-release IMG=<your-registry>/zozo-gatling-operator:<tag>
186+
```
187+
188+
You can apply Gatling Operator to your Kubernetes cluster with the following command.
189+
190+
```bash
191+
kubectl apply -f gatling-operator.yaml
192+
```

0 commit comments

Comments
 (0)