Skip to content

Commit 3b2ed23

Browse files
authored
Merge pull request #32 from dbazhenov/version_0.1.9
Release version 0.1.9 . Templates improvement. Reorganization of Dock…
2 parents ab10365 + 65dd16b commit 3b2ed23

15 files changed

Lines changed: 446 additions & 112 deletions

README.md

Lines changed: 110 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,6 @@ The application connects to and generates load on MySQL, PostgreSQL, and MongoDB
4646

4747
Open the folder with the repository `cd github-stat/`
4848

49-
<!-- 2. Copy or rename `.env.example` (already provided in this repo) to `.env`. Set the parameters in the `.env` file.
50-
51-
> **Note:** The `.env` file contains essential configuration settings for the application. Adjust these settings based on your environment to ensure proper functionality. -->
52-
5349
2. Run the environment. Two options:
5450

5551
- Demo application only. Suitable for connecting to your own databases e.g. created with Percona Everest, Pecona Operators or other databases in the cloud or locally.
@@ -58,13 +54,13 @@ The application connects to and generates load on MySQL, PostgreSQL, and MongoDB
5854
docker compose up -d
5955
```
6056

61-
- Demo application with test databases (MySQL, MongoDB, Postgres) and PMM.
57+
- Demo application with test databases (MySQL 8.4, MongoDB 8, Postgres 17) and Percona Monitoring and Management (PMM).
6258

6359
```bash
64-
docker compose -f docker-compose-full.yaml up -d
60+
docker-compose -p demo-app -f docker/full.yaml up -d
6561
```
6662

67-
> **Note:** We recommend looking at the docker-compose.yaml files so you can know which containers are running and with what settings. You can always change the settings.
63+
> **Note:** We recommend looking at the docker-compose files so you can know which containers are running and with what settings. You can always change the settings.
6864
6965
> **Note:** PMM server will be available at `localhost:8080`, access `admin` / `admin` . At the first startup, it will offer to change the password, skip it or set the same password (admin).
7066
@@ -80,8 +76,6 @@ The application connects to and generates load on MySQL, PostgreSQL, and MongoDB
8076

8177
- **Postgres**: `user=postgres password='password' dbname=dataset host=postgres port=5432 sslmode=disable`
8278

83-
- **YugabyteDB**: `user=yugabyte password='password' dbname=dataset host=yugabytedb port=5433 sslmode=disable` (YugabyteDB UI is on port 15433)
84-
8579
- **MongoDB**: `mongodb://databaseAdmin:password@mongodb:27017/`
8680

8781
If you connect to your databases, you probably know the settings to connect, if not, write to us.
@@ -104,35 +98,55 @@ The application connects to and generates load on MySQL, PostgreSQL, and MongoDB
10498

10599
> **Note:** You can see the queries running in the QAN section of PMM, and you can also see the source code in the internal/load files for each database type.
106100
107-
## Development Environment
101+
### Additional databases
108102

109-
0. Run the environment:
103+
The application can work with other compatible databases such as YugabyteDB, FerretDB or MariaDB
110104

111-
```bash
112-
docker compose -f docker-compose-dev.yaml up -d
113-
```
105+
To start the databases use docker-compose files from the docker folder or instructions from official sites.
114106

115-
1. Run the Control Panel script:
107+
Start the application if it is not already running
108+
```bash
109+
docker-compose -p demo-app -f docker/app.yaml up -d
110+
```
116111

117-
```go
118-
go run cmd/web/main.go
119-
```
112+
**YugabyteDB**
120113

121-
Launch the control panel at localhost:3000.
114+
Run docker compose with the YugabyteDB database
122115

123-
2. Run the Dataset loader script
116+
```bash
117+
docker-compose -p demo-app -f docker/yugabytedb.yaml up -d
118+
```
124119

125-
```go
126-
go run cmd/dataset/main.go
127-
```
120+
Open the Settings tab in the Control Panel and create a connection
128121

129-
3. Run the Dataset Loader script:
122+
```user=yugabyte password='password' dbname=dataset host=yugabytedb port=5433 sslmode=disable```
130123

131-
```go
132-
go run cmd/load/main.go
133-
```
124+
YugabyteDB UI is on port 15433
134125

135-
Start PMM in your browser at `localhost:8080` (admin/admin).
126+
**FerretDB**
127+
128+
Run docker compose with the FerretDB database
129+
130+
```bash
131+
docker-compose -p demo-app -f docker/ferretdb.yaml up -d
132+
```
133+
134+
Open the Settings tab in the Control Panel and create a connection
135+
```
136+
mongodb://username:password@ferretdb/ferretdb?authMechanism=PLAIN
137+
```
138+
139+
**MariaDB**
140+
141+
Run docker compose with the MariaDB database
142+
143+
```bash
144+
docker-compose -p demo-app -f docker/mariadb.yaml up -d
145+
```
146+
147+
Open the Settings tab in the Control Panel and create a connection
148+
149+
```root:password@tcp(mariadb:3306)/dataset```
136150

137151
## Launching in Kubernetes
138152

@@ -283,6 +297,74 @@ The first time you connect to MySQL and Postgres, you will need to create a sche
283297

284298
Have fun experimenting.
285299

300+
## Development Environment
301+
302+
0. Run the environment:
303+
304+
```bash
305+
docker compose -p demo-app -f docker/dev.yaml up -d
306+
```
307+
308+
This will start the Valkey required for the application services and the three databases (MySQL 8.4, MongoDB 8, Postgres 17). Edit docker/dev.yaml if you need other databases or versions.
309+
310+
1. Run the Control Panel script:
311+
312+
```go
313+
go run cmd/web/main.go
314+
```
315+
316+
Launch the control panel at localhost:3000. Open the Settings tab and add connections. The control panel is a web application, the settings are saved in Valkey.
317+
318+
2. Run the Dataset loader script
319+
320+
```go
321+
go run cmd/dataset/main.go
322+
```
323+
324+
This will start the load service. The service reads the configuration from Valkey according to the control panel and generates the load in separate Go routines.
325+
326+
3. Run the Dataset Loader script:
327+
328+
```go
329+
go run cmd/load/main.go
330+
```
331+
332+
Start PMM in your browser at `localhost:8080` (admin/admin).
333+
334+
## Release process of the new version
335+
336+
1. Test the application in a dev environment. Check the logs in the console.
337+
338+
2. Change the image versions for demo_app_dataset, demo_app_load, demo_app_web to the new version number in the files:
339+
340+
* `docker-compose.yaml`
341+
342+
* `docker/app.yaml`
343+
344+
* `docker/full.yaml`
345+
346+
* `k8s/helm/Chart.yaml`
347+
348+
* `k8s/helm/values.yaml` - images section
349+
350+
* `k8s/manual/*` - dataset-deployment.yaml, web-deployment.yaml, load-deployment.yaml files
351+
352+
3. Building and publishing to docker hub is done by GitHub Workflow by tag automatically. Set a new tag with the command:
353+
354+
```
355+
git tag -a 0.1.9 -m "Release 0.1.9"
356+
```
357+
358+
Publish a new tag
359+
360+
```
361+
git push origin 0.1.9
362+
```
363+
364+
4. Check that the GitHub Action is successful and new versions are published on dockerhub.
365+
366+
5. Test the application in docker and k8s
367+
286368
### Useful Commands
287369

288370
- Get Pods:

cmd/load/main.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,7 @@ func runMySQL(ctx context.Context, routineId int, dbConfig map[string]string) {
346346
return
347347
default:
348348
// Update localDBConfig every 2 seconds
349-
if time.Since(lastUpdate) > 2*time.Second {
349+
if time.Since(lastUpdate) > 1*time.Second {
350350
localDBConfig = getDatabaseByID(localDBConfig["id"], "mysql")
351351
if localDBConfig == nil {
352352
log.Printf("MySQL: %s: goroutine: %d: database has been removed, stopping goroutine", dbConfig["id"], routineId)
@@ -415,7 +415,7 @@ func runPostgreSQL(ctx context.Context, routineId int, dbConfig map[string]strin
415415
return
416416
default:
417417

418-
if time.Since(lastUpdate) > 2*time.Second {
418+
if time.Since(lastUpdate) > 1*time.Second {
419419
localDBConfig = getDatabaseByID(dbConfig["id"], "postgres")
420420

421421
if localDBConfig == nil {
@@ -487,7 +487,7 @@ func runMongoDB(ctx context.Context, routineId int, dbConfig map[string]string)
487487
return
488488
default:
489489

490-
if time.Since(lastUpdate) > 2*time.Second {
490+
if time.Since(lastUpdate) > 1*time.Second {
491491
localDBConfig = getDatabaseByID(dbConfig["id"], "mongodb")
492492

493493
if localDBConfig == nil {

docker-compose.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ services:
1515
retries: 5
1616

1717
demo_app_dataset:
18-
image: dbazhenov/demo_app_dataset:0.1.8
18+
image: dbazhenov/demo_app_dataset:0.1.9
1919
depends_on:
2020
valkey:
2121
condition: service_healthy
@@ -31,7 +31,7 @@ services:
3131
- DEBUG=false
3232

3333
demo_app_web:
34-
image: dbazhenov/demo_app_web:0.1.8
34+
image: dbazhenov/demo_app_web:0.1.9
3535
depends_on:
3636
valkey:
3737
condition: service_healthy
@@ -43,7 +43,7 @@ services:
4343
- "3000:3000"
4444

4545
demo_app_load:
46-
image: dbazhenov/demo_app_load:0.1.8
46+
image: dbazhenov/demo_app_load:0.1.9
4747
depends_on:
4848
valkey:
4949
condition: service_healthy

docker/app.yaml

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
version: '3.8'
2+
services:
3+
valkey:
4+
image: valkey/valkey:8
5+
environment:
6+
- ALLOW_EMPTY_PASSWORD=yes
7+
ports:
8+
- "6379:6379"
9+
volumes:
10+
- valkey-data:/data
11+
healthcheck:
12+
test: ["CMD", "redis-cli", "ping"]
13+
interval: 5s
14+
timeout: 3s
15+
retries: 5
16+
17+
demo_app_dataset:
18+
image: dbazhenov/demo_app_dataset:0.1.9
19+
depends_on:
20+
valkey:
21+
condition: service_healthy
22+
environment:
23+
- VALKEY_ADDR=valkey
24+
- VALKEY_PORT=6379
25+
- DATASET_LOAD_TYPE=csv # github or csv
26+
- DATASET_DEMO_CSV_PULLS=data/csv/pulls.csv # https://github.com/dbazhenov/github-stat/raw/refs/heads/main/data/csv/pulls.csv.zip
27+
- DATASET_DEMO_CSV_REPOS=data/csv/repositories.csv # https://github.com/dbazhenov/github-stat/raw/refs/heads/main/data/csv/repositories.csv.zip
28+
- GITHUB_ORG=percona # required for github load type
29+
- GITHUB_TOKEN= # required for github load type
30+
- DELAY_MINUTES=10
31+
- DEBUG=false
32+
33+
demo_app_web:
34+
image: dbazhenov/demo_app_web:0.1.9
35+
depends_on:
36+
valkey:
37+
condition: service_healthy
38+
environment:
39+
- VALKEY_ADDR=valkey
40+
- VALKEY_PORT=6379
41+
- CONTROL_PANEL_PORT=3000
42+
ports:
43+
- "3000:3000"
44+
45+
demo_app_load:
46+
image: dbazhenov/demo_app_load:0.1.9
47+
depends_on:
48+
valkey:
49+
condition: service_healthy
50+
environment:
51+
- VALKEY_ADDR=valkey
52+
- VALKEY_PORT=6379
53+
- LOAD_MYSQL=true
54+
- LOAD_POSTGRES=true
55+
- LOAD_MONGODB=true
56+
57+
volumes:
58+
valkey-data:
Lines changed: 12 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
version: '3.8'
12
services:
23

34
valkey:
@@ -7,23 +8,22 @@ services:
78
ports:
89
- "6379:6379"
910
volumes:
10-
- valkey_data:/data
11+
- valkey-data:/data
1112
healthcheck:
1213
test: ["CMD", "redis-cli", "ping"]
1314
interval: 5s
1415
timeout: 3s
1516
retries: 5
1617

1718
postgres:
18-
image: "percona/percona-distribution-postgresql:16.2-multi"
19+
image: "percona/percona-distribution-postgresql:17-multi"
1920
environment:
2021
POSTGRES_PASSWORD: password
2122
POSTGRES_USER: postgres
2223
LANG: en_US.utf8
2324
PGDATA: /data/db
2425
volumes:
25-
- pgdata:/data/db
26-
- ./data/init/postgresql/init.sql:/docker-entrypoint-initdb.d/init.sql
26+
- pg-data:/data/db
2727
ports:
2828
- "5432:5432"
2929
healthcheck:
@@ -32,32 +32,13 @@ services:
3232
timeout: 10s
3333
retries: 5
3434

35-
yugabytedb:
36-
image: "yugabytedb/yugabyte:2024.2.0.0-b145"
37-
command: yugabyted start --enable_pg_parity_early_access --tserver_flags="ysql_pg_conf_csv={shared_preload_libraries='pg_stat_monitor'}" --initial_scripts_dir=/docker-entrypoint-initial_scripts_dir --background=false
38-
environment:
39-
YSQL_PASSWORD: password
40-
YSQL_USER: yugabyte
41-
volumes:
42-
- ./data/init/postgresql:/docker-entrypoint-initial_scripts_dir
43-
ports:
44-
- "5433:5433"
45-
- "15433:15433"
46-
healthcheck:
47-
test: ["CMD-SHELL", "PGPASSWORD=$$YSQL_PASSWORD yugabyted connect ysql <<<''"]
48-
interval: 30s
49-
timeout: 10s
50-
retries: 5
51-
5235
mongodb:
53-
image: "percona/percona-server-mongodb:7.0-multi"
36+
image: "percona/percona-server-mongodb:8.0-multi"
5437
volumes:
55-
- mongodata:/data/db
56-
- ./data/init/mongodb/init.js:/docker-entrypoint-initdb.d/init.js:ro
38+
- mongo-data:/data/db
5739
environment:
5840
MONGO_INITDB_ROOT_USERNAME: databaseAdmin
5941
MONGO_INITDB_ROOT_PASSWORD: password
60-
MONGO_INITDB_DATABASE: dataset
6142
ports:
6243
- "27017:27017"
6344
healthcheck:
@@ -67,13 +48,11 @@ services:
6748
retries: 5
6849

6950
mysql:
70-
image: "percona/percona-server:8.3.0-1.1-multi"
51+
image: "percona/percona-server:8.4.3-3.1-multi"
7152
volumes:
72-
- mysqldata:/var/lib/mysql
73-
- ./data/init/mysql:/docker-entrypoint-initdb.d
53+
- mysql-data:/var/lib/mysql
7454
environment:
7555
MYSQL_ROOT_PASSWORD: password
76-
MYSQL_DATABASE: dataset
7756
healthcheck:
7857
test: ["CMD", "mysqladmin", "ping", "-h", "localhost", "-uroot", "-proot-password"]
7958
interval: 5s
@@ -131,8 +110,8 @@ services:
131110
pmm-admin add mongodb --username=databaseAdmin --password=password --host=mongodb --port=27017 --query-source=profiler
132111
133112
volumes:
113+
valkey-data:
134114
pmm-data:
135-
mongodata:
136-
pgdata:
137-
mysqldata:
138-
valkey_data:
115+
mongo-data:
116+
pg-data:
117+
mysql-data:

0 commit comments

Comments
 (0)