Skip to content

Commit 0a1953e

Browse files
committed
Add support for Database resource group manager
1 parent 4630167 commit 0a1953e

11 files changed

+352
-120
lines changed

charts/trino/Chart.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ type: application
1515
# This is the chart version. This version number should be incremented each time you make changes
1616
# to the chart and its templates, including the app version.
1717
# Versions are expected to follow Semantic Versioning (https://semver.org/)
18-
version: 0.33.0
18+
version: 0.34.0
1919

2020
# This is the version number of the application being deployed. This version number should be
2121
# incremented each time you make changes to the application. Versions are not expected to

charts/trino/README.md

+72-58
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# trino
22

3-
![Version: 0.33.0](https://img.shields.io/badge/Version-0.33.0-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 464](https://img.shields.io/badge/AppVersion-464-informational?style=flat-square)
3+
![Version: 0.34.0](https://img.shields.io/badge/Version-0.34.0-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: 464](https://img.shields.io/badge/AppVersion-464-informational?style=flat-square)
44

55
Fast distributed SQL query engine for big data analytics that helps you explore your data universe
66

@@ -175,65 +175,79 @@ Fast distributed SQL query engine for big data analytics that helps you explore
175175
```
176176
* `resourceGroups` - object, default: `{}`
177177

178-
Resource groups file is mounted to /etc/trino/resource-groups/resource-groups.json
179-
Example:
178+
[Resource groups control](https://trino.io/docs/current/admin/resource-groups.html)
179+
Set the type property to either:
180+
* `configmap`, and provide the Resource groups file contents in `resourceGroupsConfig`,
181+
* `properties`, and provide configuration properties in `properties`.
182+
Properties example:
183+
```yaml
184+
type: properties
185+
properties: |
186+
resource-groups.configuration-manager=db
187+
resource-groups.config-db-url=jdbc:mysql://trino-mysql.mysql.svc.cluster.local:3306/resource_groups
188+
resource-groups.config-db-user=username
189+
resource-groups.config-db-password=password
190+
```
191+
Config map example:
180192
```yaml
193+
type: configmap
194+
# Resource groups file is mounted to /etc/trino/resource-groups/resource-groups.json
181195
resourceGroupsConfig: |-
182-
{
183-
"rootGroups": [
184-
{
185-
"name": "global",
186-
"softMemoryLimit": "80%",
187-
"hardConcurrencyLimit": 100,
188-
"maxQueued": 100,
189-
"schedulingPolicy": "fair",
190-
"jmxExport": true,
191-
"subGroups": [
192-
{
193-
"name": "admin",
194-
"softMemoryLimit": "30%",
195-
"hardConcurrencyLimit": 20,
196-
"maxQueued": 10
197-
},
198-
{
199-
"name": "finance_human_resources",
200-
"softMemoryLimit": "20%",
201-
"hardConcurrencyLimit": 15,
202-
"maxQueued": 10
203-
},
204-
{
205-
"name": "general",
206-
"softMemoryLimit": "30%",
207-
"hardConcurrencyLimit": 20,
208-
"maxQueued": 10
209-
},
210-
{
211-
"name": "readonly",
212-
"softMemoryLimit": "10%",
213-
"hardConcurrencyLimit": 5,
214-
"maxQueued": 5
215-
}
216-
]
217-
}
218-
],
219-
"selectors": [
220-
{
221-
"user": "admin",
222-
"group": "global.admin"
223-
},
224-
{
225-
"group": "finance|human_resources",
226-
"group": "global.finance_human_resources"
227-
},
228-
{
229-
"user": "alice",
230-
"group": "global.readonly"
231-
},
232-
{
233-
"group": "global.general"
234-
}
235-
]
236-
}
196+
{
197+
"rootGroups": [
198+
{
199+
"name": "global",
200+
"softMemoryLimit": "80%",
201+
"hardConcurrencyLimit": 100,
202+
"maxQueued": 100,
203+
"schedulingPolicy": "fair",
204+
"jmxExport": true,
205+
"subGroups": [
206+
{
207+
"name": "admin",
208+
"softMemoryLimit": "30%",
209+
"hardConcurrencyLimit": 20,
210+
"maxQueued": 10
211+
},
212+
{
213+
"name": "finance_human_resources",
214+
"softMemoryLimit": "20%",
215+
"hardConcurrencyLimit": 15,
216+
"maxQueued": 10
217+
},
218+
{
219+
"name": "general",
220+
"softMemoryLimit": "30%",
221+
"hardConcurrencyLimit": 20,
222+
"maxQueued": 10
223+
},
224+
{
225+
"name": "readonly",
226+
"softMemoryLimit": "10%",
227+
"hardConcurrencyLimit": 5,
228+
"maxQueued": 5
229+
}
230+
]
231+
}
232+
],
233+
"selectors": [
234+
{
235+
"user": "admin",
236+
"group": "global.admin"
237+
},
238+
{
239+
"group": "finance|human_resources",
240+
"group": "global.finance_human_resources"
241+
},
242+
{
243+
"user": "alice",
244+
"group": "global.readonly"
245+
},
246+
{
247+
"group": "global.general"
248+
}
249+
]
250+
}
237251
```
238252
* `additionalNodeProperties` - list, default: `[]`
239253

charts/trino/templates/configmap-coordinator.yaml

+12-1
Original file line numberDiff line numberDiff line change
@@ -105,9 +105,20 @@ data:
105105
{{- end }}
106106

107107
{{- if .Values.resourceGroups }}
108+
{{- if eq .Values.resourceGroups.type "configmap" }}
108109
resource-groups.properties: |
109110
resource-groups.configuration-manager=file
110111
resource-groups.config-file={{ .Values.server.config.path }}/resource-groups/resource-groups.json
112+
{{- else if eq .Values.resourceGroups.type "properties" }}
113+
resource-groups.properties: |
114+
{{- if .Values.resourceGroups.properties }}
115+
{{- .Values.resourceGroups.properties | nindent 4 }}
116+
{{- else}}
117+
{{- fail "resourceGroups.properties is required when resourceGroups.type is 'properties'." }}
118+
{{- end }}
119+
{{- else}}
120+
{{- fail "Invalid resourceGroups.type value. It must be either 'configmap' or 'properties'." }}
121+
{{- end }}
111122
{{- end }}
112123

113124
{{- if .Values.server.exchangeManager }}
@@ -151,7 +162,7 @@ data:
151162
{{ $fileName }}: |
152163
{{- tpl $fileContent $ | nindent 4 }}
153164
{{- end }}
154-
{{- if .Values.resourceGroups }}
165+
{{- if eq .Values.resourceGroups.type "configmap" }}
155166
---
156167
apiVersion: v1
157168
kind: ConfigMap

charts/trino/templates/deployment-coordinator.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ spec:
6767
configMap:
6868
name: {{ template "trino.fullname" . }}-access-control-volume-coordinator
6969
{{- end }}
70-
{{- if .Values.resourceGroups }}
70+
{{- if eq .Values.resourceGroups.type "configmap" }}
7171
- name: resource-groups-volume
7272
configMap:
7373
name: {{ template "trino.fullname" . }}-resource-groups-volume-coordinator
@@ -146,7 +146,7 @@ spec:
146146
- mountPath: {{ .Values.server.config.path }}/access-control
147147
name: access-control-volume
148148
{{- end }}
149-
{{- if .Values.resourceGroups }}
149+
{{- if eq .Values.resourceGroups.type "configmap" }}
150150
- mountPath: {{ .Values.server.config.path }}/resource-groups
151151
name: resource-groups-volume
152152
{{- end }}

charts/trino/templates/tests/test-connection.yaml

+6
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,12 @@ metadata:
88
test: connection
99
annotations:
1010
"helm.sh/hook": test
11+
{{- if .Values.resourceGroups }}
12+
{{- if eq .Values.resourceGroups.type "properties" }}
13+
# Ensures this test runs after the Trino cluster is fully started and configured.
14+
"helm.sh/hook-weight": "99"
15+
{{- end }}
16+
{{- end }}
1117
spec:
1218
containers:
1319
- name: cli
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
{{- if eq .Values.resourceGroups.type "properties" }}
2+
apiVersion: v1
3+
kind: Pod
4+
metadata:
5+
name: {{ include "trino.fullname" . }}-test-add-resourcegroups-data
6+
labels:
7+
{{- include "trino.labels" . | nindent 4 }}
8+
app.kubernetes.io/component: test
9+
test: add-resource-groups-data
10+
annotations:
11+
"helm.sh/hook": test
12+
"helm.sh/hook-weight": "-1"
13+
spec:
14+
containers:
15+
- name: mysql-client
16+
image: bitnami/mysql:8.1
17+
command:
18+
- /bin/sh
19+
- -c
20+
- |
21+
echo "Inserting data into MySQL";
22+
mysql -h trino-resource-groups-db-mysql.mysql.svc.cluster.local -u trino -ppass0000 resource_groups -e "
23+
-- create a root group 'admin' with NULL parent
24+
INSERT INTO resource_groups (name, soft_memory_limit, hard_concurrency_limit, max_queued, scheduling_policy, environment)
25+
VALUES ('admin', '100%', 50, 100, 'query_priority', 'production');
26+
-- use ID of 'admin' resource group for selector
27+
INSERT INTO selectors (resource_group_id, user_regex, priority) VALUES ((SELECT resource_group_id FROM resource_groups WHERE name = 'admin'), 'admin', 6);
28+
-- check data
29+
SELECT * FROM resource_groups;
30+
SELECT * FROM selectors;";
31+
sleep 5
32+
restartPolicy: Never
33+
{{- end }}

charts/trino/values.yaml

+71-57
Original file line numberDiff line numberDiff line change
@@ -183,66 +183,80 @@ accessControl: {}
183183
# ```
184184

185185
resourceGroups: {}
186-
# resourceGroups -- Resource groups file is mounted to /etc/trino/resource-groups/resource-groups.json
186+
# resourceGroups -- [Resource groups control](https://trino.io/docs/current/admin/resource-groups.html)
187187
# @raw
188-
# Example:
188+
# Set the type property to either:
189+
# * `configmap`, and provide the Resource groups file contents in `resourceGroupsConfig`,
190+
# * `properties`, and provide configuration properties in `properties`.
191+
# Properties example:
192+
# ```yaml
193+
# type: properties
194+
# properties: |
195+
# resource-groups.configuration-manager=db
196+
# resource-groups.config-db-url=jdbc:mysql://trino-mysql.mysql.svc.cluster.local:3306/resource_groups
197+
# resource-groups.config-db-user=username
198+
# resource-groups.config-db-password=password
199+
# ```
200+
# Config map example:
189201
# ```yaml
202+
# type: configmap
203+
# # Resource groups file is mounted to /etc/trino/resource-groups/resource-groups.json
190204
# resourceGroupsConfig: |-
191-
# {
192-
# "rootGroups": [
193-
# {
194-
# "name": "global",
195-
# "softMemoryLimit": "80%",
196-
# "hardConcurrencyLimit": 100,
197-
# "maxQueued": 100,
198-
# "schedulingPolicy": "fair",
199-
# "jmxExport": true,
200-
# "subGroups": [
201-
# {
202-
# "name": "admin",
203-
# "softMemoryLimit": "30%",
204-
# "hardConcurrencyLimit": 20,
205-
# "maxQueued": 10
206-
# },
207-
# {
208-
# "name": "finance_human_resources",
209-
# "softMemoryLimit": "20%",
210-
# "hardConcurrencyLimit": 15,
211-
# "maxQueued": 10
212-
# },
213-
# {
214-
# "name": "general",
215-
# "softMemoryLimit": "30%",
216-
# "hardConcurrencyLimit": 20,
217-
# "maxQueued": 10
218-
# },
219-
# {
220-
# "name": "readonly",
221-
# "softMemoryLimit": "10%",
222-
# "hardConcurrencyLimit": 5,
223-
# "maxQueued": 5
224-
# }
225-
# ]
226-
# }
227-
# ],
228-
# "selectors": [
229-
# {
230-
# "user": "admin",
231-
# "group": "global.admin"
232-
# },
233-
# {
234-
# "group": "finance|human_resources",
235-
# "group": "global.finance_human_resources"
236-
# },
237-
# {
238-
# "user": "alice",
239-
# "group": "global.readonly"
240-
# },
241-
# {
242-
# "group": "global.general"
243-
# }
244-
# ]
245-
# }
205+
# {
206+
# "rootGroups": [
207+
# {
208+
# "name": "global",
209+
# "softMemoryLimit": "80%",
210+
# "hardConcurrencyLimit": 100,
211+
# "maxQueued": 100,
212+
# "schedulingPolicy": "fair",
213+
# "jmxExport": true,
214+
# "subGroups": [
215+
# {
216+
# "name": "admin",
217+
# "softMemoryLimit": "30%",
218+
# "hardConcurrencyLimit": 20,
219+
# "maxQueued": 10
220+
# },
221+
# {
222+
# "name": "finance_human_resources",
223+
# "softMemoryLimit": "20%",
224+
# "hardConcurrencyLimit": 15,
225+
# "maxQueued": 10
226+
# },
227+
# {
228+
# "name": "general",
229+
# "softMemoryLimit": "30%",
230+
# "hardConcurrencyLimit": 20,
231+
# "maxQueued": 10
232+
# },
233+
# {
234+
# "name": "readonly",
235+
# "softMemoryLimit": "10%",
236+
# "hardConcurrencyLimit": 5,
237+
# "maxQueued": 5
238+
# }
239+
# ]
240+
# }
241+
# ],
242+
# "selectors": [
243+
# {
244+
# "user": "admin",
245+
# "group": "global.admin"
246+
# },
247+
# {
248+
# "group": "finance|human_resources",
249+
# "group": "global.finance_human_resources"
250+
# },
251+
# {
252+
# "user": "alice",
253+
# "group": "global.readonly"
254+
# },
255+
# {
256+
# "group": "global.general"
257+
# }
258+
# ]
259+
# }
246260
# ```
247261

248262
additionalNodeProperties: []

0 commit comments

Comments
 (0)