Skip to content

Commit 71714f6

Browse files
authored
Horizontal pod autoscaler (#286)
* Load test DEVOPS-428 * horizontal pod autoscaler DEVOPS-392 * Load test workflow DEVOPS-428 * Prevent parallel deployment DEVOPS-429 Co-authored-by: Tero Virtanen <tero.virtanen@mavericks.fi>
1 parent d577277 commit 71714f6

5 files changed

Lines changed: 86 additions & 2 deletions

File tree

.github/workflows/load_tests.yml

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: k6 Load Tests
2+
3+
# Only trigger when the staging workflow succeeded
4+
on:
5+
workflow_run:
6+
workflows: ["Build & Staging"]
7+
types:
8+
- completed
9+
10+
# allow only one run at a time
11+
concurrency: ${{ github.workflow }}
12+
13+
jobs:
14+
k6_load_test:
15+
name: k6 Load Tests
16+
runs-on: ubuntu-latest
17+
18+
steps:
19+
- name: Checkout
20+
uses: actions/checkout@v2
21+
22+
- name: Run k6 tests
23+
uses: k6io/action@v0.1
24+
with:
25+
filename: k6LoadTests.js
26+
- name: k6 Load Tests failed notifications
27+
uses: rtCamp/action-slack-notify@v2
28+
env:
29+
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
30+
SLACK_USERNAME: K6LoadTest
31+
SLACK_ICON: https://a.slack-edge.com/80588/img/services/outgoing-webhook_48.png
32+
SLACK_TITLE: K6 Load Tests has failed.
33+
SLACK_MESSAGE: Some of the k6 load tests has failed.
34+
if: failure()

.github/workflows/production.yml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ on:
44
tags:
55
- 'release-*'
66

7+
# allow only one run at a time
8+
concurrency: ${{ github.workflow }}
9+
710
env:
811
CONTAINER_REGISTRY: ghcr.io
912
CONTAINER_REGISTRY_USER: ${{ secrets.GHCR_CONTAINER_REGISTRY_USER }}
@@ -19,7 +22,12 @@ env:
1922
K8S_REQUEST_RAM: 400Mi
2023
K8S_LIMIT_CPU: 800m
2124
K8S_LIMIT_RAM: 800Mi
22-
K8S_REPLICACOUNT: 2
25+
# horizontal pod autoscaler
26+
K8S_HPA_ENABLED: true
27+
K8S_HPA_MAX_REPLICAS: 8
28+
K8S_HPA_MIN_REPLICAS: 2
29+
K8S_HPA_MAX_CPU_AVG: 80 # 80% from request
30+
# K8S_HPA_MAX_RAM_AVG: 80 # 80% from request
2331

2432
jobs:
2533
build:

.github/workflows/review.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,12 @@ env:
1919
K8S_REQUEST_RAM: 250Mi
2020
K8S_LIMIT_CPU: 100m
2121
K8S_LIMIT_RAM: 350Mi
22+
# horizontal pod autoscaler
23+
K8S_HPA_ENABLED: true
24+
K8S_HPA_MAX_REPLICAS: 2
25+
K8S_HPA_MIN_REPLICAS: 1
26+
K8S_HPA_MAX_CPU_AVG: 80 # 80% from request
27+
# K8S_HPA_MAX_RAM_AVG: 80 # 80% from request
2228

2329
jobs:
2430
build:
@@ -33,6 +39,9 @@ jobs:
3339
runs-on: ubuntu-latest
3440
needs: build
3541
name: Review
42+
# allow only one deployment at a time
43+
concurrency: ${{ github.workflow }}-${{ github.head_ref }}
44+
3645
steps:
3746
- uses: actions/checkout@v2
3847
- uses: andersinno/kolga-setup-action@v2

.github/workflows/staging.yml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,12 @@ env:
2020
K8S_REQUEST_RAM: 250Mi
2121
K8S_LIMIT_CPU: 100m
2222
K8S_LIMIT_RAM: 350Mi
23-
K8S_REPLICACOUNT: 2
23+
# horizontal pod autoscaler
24+
K8S_HPA_ENABLED: true
25+
K8S_HPA_MAX_REPLICAS: 3
26+
K8S_HPA_MIN_REPLICAS: 1
27+
K8S_HPA_MAX_CPU_AVG: 80 # 80% from request
28+
# K8S_HPA_MAX_RAM_AVG: 80 # 80% from request
2429

2530
jobs:
2631
build:
@@ -35,6 +40,10 @@ jobs:
3540
runs-on: ubuntu-latest
3641
needs: build
3742
name: Staging
43+
44+
# allow only one deployment at a time
45+
concurrency: ${{ github.workflow }}-${{ github.ref }}
46+
3847
steps:
3948
- uses: actions/checkout@v2
4049
- uses: andersinno/kolga-setup-action@v2

k6LoadTests.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/* eslint-disable */
2+
import { sleep } from 'k6';
3+
import http from 'k6/http';
4+
5+
export const options = {
6+
duration: '10m',
7+
vus: 100,
8+
// vus: 1,
9+
thresholds: {
10+
//avg is around ?100ms? on https://kukkuu.test.kuva.hel.ninja
11+
http_req_duration: ['p(95)<5000'],
12+
},
13+
};
14+
15+
export default () => {
16+
const url = 'https://kukkuu.test.kuva.hel.ninja/graphql';
17+
const data = 'query=query Organisations {organisations {edges {node {id } } } }';
18+
const res = http.post(url, data, {
19+
headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
20+
});
21+
22+
//10 loads per minute
23+
sleep(6);
24+
};

0 commit comments

Comments
 (0)