Skip to content

Commit a60ffed

Browse files
authored
Merge pull request #595 from trepel/scale-test-policy-updates
Added apikey Auth and v1 updates to scale test policies
2 parents d20f01b + bdf9ecc commit a60ffed

11 files changed

+94
-16
lines changed

scale_test/config.yaml

+19-1
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,12 @@ metricsEndpoints:
1717
type: local
1818
metricsDirectory: ./metrics
1919
{{ end }}
20-
global:
20+
global:
21+
{{ if .SKIP_CLEANUP }}
22+
gc: false
23+
{{ else }}
2124
gc: true
25+
{{ end }}
2226
jobs:
2327
- name: scale-test-preparations
2428
jobIterations: 1
@@ -44,6 +48,16 @@ jobs:
4448
KUADRANT_AWS_ACCESS_KEY_ID: "{{ .KUADRANT_AWS_ACCESS_KEY_ID }}"
4549
KUADRANT_AWS_REGION: "{{ .KUADRANT_AWS_REGION }}"
4650
KUADRANT_AWS_SECRET_ACCESS_KEY: "{{ .KUADRANT_AWS_SECRET_ACCESS_KEY }}"
51+
- objectTemplate: ./person-secret.yaml
52+
kind: Secret
53+
replicas: 1
54+
inputVars:
55+
person: "alice"
56+
- objectTemplate: ./person-secret.yaml
57+
kind: Secret
58+
replicas: 1
59+
inputVars:
60+
person: "bob"
4761
- name: scale-test-main
4862
jobIterations: 1
4963
qps: 1
@@ -122,6 +136,9 @@ jobs:
122136
LISTENER_NUM: "{{$LISTENER_NUM}}"
123137
{{- end }}
124138
{{- end }}
139+
{{ if .SKIP_CLEANUP }}
140+
# nothing to do if cleanup is skipped
141+
{{ else }}
125142
- name: scale-test-safe-dnspolicy-cleanup
126143
jobType: delete
127144
jobIterations: 1
@@ -132,3 +149,4 @@ jobs:
132149
- kind: DNSPolicy
133150
apiVersion: kuadrant.io/v1alpha1
134151
labelSelector: {kube-burner-job: scale-test-main}
152+
{{ end }}

scale_test/gw-auth-policy.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{{- $GW_NUM := .GW_NUM }}
2-
apiVersion: kuadrant.io/v1beta3
2+
apiVersion: kuadrant.io/v1
33
kind: AuthPolicy
44
metadata:
55
name: auth-policy-gw{{$GW_NUM}}-i{{ .Iteration }}

scale_test/gw-dns-policy.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{{- $GW_NUM := .GW_NUM }}
2-
apiVersion: kuadrant.io/v1alpha1
2+
apiVersion: kuadrant.io/v1
33
kind: DNSPolicy
44
metadata:
55
name: dns-policy-gw{{$GW_NUM}}-i{{ .Iteration }}

scale_test/gw-rlp.yaml

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{{- $GW_NUM := .GW_NUM }}
2-
apiVersion: kuadrant.io/v1beta3
2+
apiVersion: kuadrant.io/v1
33
kind: RateLimitPolicy
44
metadata:
55
name: rlp-gw{{$GW_NUM}}-i{{ .Iteration }}
@@ -13,6 +13,5 @@ spec:
1313
limits:
1414
"global":
1515
rates:
16-
- limit: 5
17-
duration: 10
18-
unit: second
16+
- limit: 3
17+
window: "10s"

scale_test/gw-tls-policy.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{{- $GW_NUM := .GW_NUM }}
2-
apiVersion: kuadrant.io/v1alpha1
2+
apiVersion: kuadrant.io/v1
33
kind: TLSPolicy
44
metadata:
55
name: tls-policy-gw{{$GW_NUM}}-i{{ .Iteration }}

scale_test/gw.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ spec:
1616
- allowedRoutes:
1717
namespaces:
1818
from: All
19-
hostname: "*.scale-test-gw{{$GW_NUM}}-l{{ $LISTENER_NUM }}-i{{$Iteration}}.{{ $KUADRANT_ZONE_ROOT_DOMAIN }}"
19+
hostname: "api.scale-test-gw{{$GW_NUM}}-l{{$LISTENER_NUM}}-i{{$Iteration}}.{{$KUADRANT_ZONE_ROOT_DOMAIN}}"
2020
name: api-{{ $LISTENER_NUM }}
2121
port: 443
2222
protocol: HTTPS

scale_test/httproute-auth-policy.yaml

+19-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{{- $GW_NUM := .GW_NUM }}
22
{{- $LISTENER_NUM := .LISTENER_NUM }}
3-
apiVersion: kuadrant.io/v1beta3
3+
apiVersion: kuadrant.io/v1
44
kind: AuthPolicy
55
metadata:
66
name: httproute-auth-policy-gw{{$GW_NUM}}-l{{$LISTENER_NUM}}-i{{ .Iteration }}
@@ -16,3 +16,21 @@ spec:
1616
allow-all:
1717
opa:
1818
rego: "allow = true"
19+
authentication:
20+
"api-key-users":
21+
apiKey:
22+
allNamespaces: true
23+
selector:
24+
matchLabels:
25+
app: scale-test
26+
credentials:
27+
authorizationHeader:
28+
prefix: APIKEY
29+
response:
30+
success:
31+
filters:
32+
"identity":
33+
json:
34+
properties:
35+
"userid":
36+
selector: auth.identity.metadata.annotations.secret\.kuadrant\.io/user-id

scale_test/httproute-rlp.yaml

+3-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{{- $GW_NUM := .GW_NUM }}
22
{{- $LISTENER_NUM := .LISTENER_NUM }}
3-
apiVersion: kuadrant.io/v1beta3
3+
apiVersion: kuadrant.io/v1
44
kind: RateLimitPolicy
55
metadata:
66
name: httproute-rlp-gw{{$GW_NUM}}-l{{$LISTENER_NUM}}-i{{ .Iteration }}
@@ -14,6 +14,5 @@ spec:
1414
limits:
1515
"httproute-level":
1616
rates:
17-
- limit: 10
18-
duration: 10
19-
unit: second
17+
- limit: 5
18+
window: "10s"

scale_test/httproute.yaml

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
{{- $Iteration := .Iteration }}
2+
{{- $KUADRANT_ZONE_ROOT_DOMAIN := .KUADRANT_ZONE_ROOT_DOMAIN }}
13
{{- $GW_NUM := .GW_NUM }}
24
{{- $LISTENER_NUM := .LISTENER_NUM }}
35
apiVersion: gateway.networking.k8s.io/v1
@@ -12,7 +14,7 @@ spec:
1214
kind: Gateway
1315
name: gw{{$GW_NUM}}-i{{ .Iteration }}
1416
hostnames:
15-
- "api.scale-test-gw{{$GW_NUM}}-l{{$LISTENER_NUM}}-i{{.Iteration}}.{{ .KUADRANT_ZONE_ROOT_DOMAIN }}"
17+
- "api.scale-test-gw{{$GW_NUM}}-l{{$LISTENER_NUM}}-i{{$Iteration}}.{{$KUADRANT_ZONE_ROOT_DOMAIN}}"
1618
rules:
1719
- backendRefs:
1820
- group: ''

scale_test/person-secret.yaml

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
apiVersion: v1
2+
kind: Secret
3+
metadata:
4+
name: {{.person}}-key
5+
labels:
6+
authorino.kuadrant.io/managed-by: authorino
7+
app: scale-test
8+
annotations:
9+
secret.kuadrant.io/user-id: {{.person}}
10+
stringData:
11+
api_key: iam{{.person}}
12+
type: Opaque

scale_test/readme.md

+31-1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ export NUM_LISTENERS=1
2323
```
2424

2525
If you want to disable indexing you need to explicitly set related environment variables to an empty string:
26+
2627
```
2728
export OS_INDEXING= # to disable indexing
2829
export ES_SERVER= # to disable indexing
@@ -32,7 +33,36 @@ export ES_SERVER= # to disable indexing
3233

3334
`kube-burner init -c ./config.yaml --timeout 5m --uuid scale-test-$(openssl rand -hex 3)`
3435

35-
Don't forget to increase the timeout if larger number of CRs are to be created.
36+
Don't forget to increase the timeout if a larger number of CRs are to be created. You might also modify policy templates based on your needs, e.g. increase limits in RateLimitPolicy CR templates etc.
37+
38+
## Cleanup
39+
40+
Automatic cleanup can be skipped:
41+
42+
```
43+
export SKIP_CLEANUP=true
44+
```
45+
46+
If so then note the UUID of your scale test run so that you can perform manual cleanup. The DNSPolicy CR needs to be removed manually first. That triggers corresponding DNSRecord CR removal. It is not handled gracefully by Kube Burner cleanup so better to remove it manually beforehand:
47+
48+
```
49+
kubectl delete dnspolicy [:dns_policy_name] -n scale-test-0
50+
kube-burner destroy --uuid [:uuid]
51+
```
52+
53+
## Quick Sanity Check
54+
55+
If cleanup is skipped then quick sanity check that everything works can be done:
56+
57+
```
58+
curl -k -s -o /dev/null -w "%{http_code}\n" -H "Authorization: APIKEY iamalice" https://api.scale-test-gw1-l1-i0.aws.kua.app-services-dev.net/get # expected result: 200
59+
60+
curl -k -s -o /dev/null -w "%{http_code}\n" -H "Authorization: APIKEY iambob" https://api.scale-test-gw1-l1-i0.aws.kua.app-services-dev.net/get # expected result: 200
61+
62+
curl -k -s -o /dev/null -w "%{http_code}\n" -H "Authorization: APIKEY iamX" https://api.scale-test-gw1-l1-i0.aws.kua.app-services-dev.net/get # expected result: 401
63+
```
64+
65+
Based on limits configured in RateLimitPolicy CRs these commands can be repeated until `HTTP 429 Too Many Requests` is returned. Omit `-k` if valid certificates are used.
3666

3767
## Setting up a local cluster for execution
3868

0 commit comments

Comments
 (0)