diff --git a/charts/trino/Chart.yaml b/charts/trino/Chart.yaml index df47ac62..05956db6 100644 --- a/charts/trino/Chart.yaml +++ b/charts/trino/Chart.yaml @@ -15,7 +15,7 @@ type: application # This is the chart version. This version number should be incremented each time you make changes # to the chart and its templates, including the app version. # Versions are expected to follow Semantic Versioning (https://semver.org/) -version: 0.33.0 +version: 0.34.0 # This is the version number of the application being deployed. This version number should be # incremented each time you make changes to the application. Versions are not expected to diff --git a/charts/trino/README.md b/charts/trino/README.md index 6bc07bda..97e03c6c 100644 --- a/charts/trino/README.md +++ b/charts/trino/README.md @@ -1,6 +1,6 @@ # trino -![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) +![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) Fast distributed SQL query engine for big data analytics that helps you explore your data universe @@ -175,65 +175,79 @@ Fast distributed SQL query engine for big data analytics that helps you explore ``` * `resourceGroups` - object, default: `{}` - Resource groups file is mounted to /etc/trino/resource-groups/resource-groups.json - Example: + [Resource groups control](https://trino.io/docs/current/admin/resource-groups.html) + Set the type property to either: + * `configmap`, and provide the Resource groups file contents in `resourceGroupsConfig`, + * `properties`, and provide configuration properties in `properties`. + Properties example: + ```yaml + type: properties + properties: | + resource-groups.configuration-manager=db + resource-groups.config-db-url=jdbc:mysql://trino-mysql.mysql.svc.cluster.local:3306/resource_groups + resource-groups.config-db-user=username + resource-groups.config-db-password=password + ``` + Config map example: ```yaml + type: configmap + # Resource groups file is mounted to /etc/trino/resource-groups/resource-groups.json resourceGroupsConfig: |- - { - "rootGroups": [ - { - "name": "global", - "softMemoryLimit": "80%", - "hardConcurrencyLimit": 100, - "maxQueued": 100, - "schedulingPolicy": "fair", - "jmxExport": true, - "subGroups": [ - { - "name": "admin", - "softMemoryLimit": "30%", - "hardConcurrencyLimit": 20, - "maxQueued": 10 - }, - { - "name": "finance_human_resources", - "softMemoryLimit": "20%", - "hardConcurrencyLimit": 15, - "maxQueued": 10 - }, - { - "name": "general", - "softMemoryLimit": "30%", - "hardConcurrencyLimit": 20, - "maxQueued": 10 - }, - { - "name": "readonly", - "softMemoryLimit": "10%", - "hardConcurrencyLimit": 5, - "maxQueued": 5 - } - ] - } - ], - "selectors": [ - { - "user": "admin", - "group": "global.admin" - }, - { - "group": "finance|human_resources", - "group": "global.finance_human_resources" - }, - { - "user": "alice", - "group": "global.readonly" - }, - { - "group": "global.general" - } - ] - } + { + "rootGroups": [ + { + "name": "global", + "softMemoryLimit": "80%", + "hardConcurrencyLimit": 100, + "maxQueued": 100, + "schedulingPolicy": "fair", + "jmxExport": true, + "subGroups": [ + { + "name": "admin", + "softMemoryLimit": "30%", + "hardConcurrencyLimit": 20, + "maxQueued": 10 + }, + { + "name": "finance_human_resources", + "softMemoryLimit": "20%", + "hardConcurrencyLimit": 15, + "maxQueued": 10 + }, + { + "name": "general", + "softMemoryLimit": "30%", + "hardConcurrencyLimit": 20, + "maxQueued": 10 + }, + { + "name": "readonly", + "softMemoryLimit": "10%", + "hardConcurrencyLimit": 5, + "maxQueued": 5 + } + ] + } + ], + "selectors": [ + { + "user": "admin", + "group": "global.admin" + }, + { + "group": "finance|human_resources", + "group": "global.finance_human_resources" + }, + { + "user": "alice", + "group": "global.readonly" + }, + { + "group": "global.general" + } + ] + } ``` * `additionalNodeProperties` - list, default: `[]` diff --git a/charts/trino/templates/configmap-coordinator.yaml b/charts/trino/templates/configmap-coordinator.yaml index 75f62acd..6e27519a 100644 --- a/charts/trino/templates/configmap-coordinator.yaml +++ b/charts/trino/templates/configmap-coordinator.yaml @@ -105,9 +105,20 @@ data: {{- end }} {{- if .Values.resourceGroups }} + {{- if eq .Values.resourceGroups.type "configmap" }} resource-groups.properties: | resource-groups.configuration-manager=file resource-groups.config-file={{ .Values.server.config.path }}/resource-groups/resource-groups.json + {{- else if eq .Values.resourceGroups.type "properties" }} + resource-groups.properties: | + {{- if .Values.resourceGroups.properties }} + {{- .Values.resourceGroups.properties | nindent 4 }} + {{- else}} + {{- fail "resourceGroups.properties is required when resourceGroups.type is 'properties'." }} + {{- end }} + {{- else}} + {{- fail "Invalid resourceGroups.type value. It must be either 'configmap' or 'properties'." }} + {{- end }} {{- end }} {{- if .Values.server.exchangeManager }} @@ -151,7 +162,7 @@ data: {{ $fileName }}: | {{- tpl $fileContent $ | nindent 4 }} {{- end }} -{{- if .Values.resourceGroups }} +{{- if eq .Values.resourceGroups.type "configmap" }} --- apiVersion: v1 kind: ConfigMap diff --git a/charts/trino/templates/deployment-coordinator.yaml b/charts/trino/templates/deployment-coordinator.yaml index 297d16ca..c89d76b0 100644 --- a/charts/trino/templates/deployment-coordinator.yaml +++ b/charts/trino/templates/deployment-coordinator.yaml @@ -67,7 +67,7 @@ spec: configMap: name: {{ template "trino.fullname" . }}-access-control-volume-coordinator {{- end }} - {{- if .Values.resourceGroups }} + {{- if eq .Values.resourceGroups.type "configmap" }} - name: resource-groups-volume configMap: name: {{ template "trino.fullname" . }}-resource-groups-volume-coordinator @@ -146,7 +146,7 @@ spec: - mountPath: {{ .Values.server.config.path }}/access-control name: access-control-volume {{- end }} - {{- if .Values.resourceGroups }} + {{- if eq .Values.resourceGroups.type "configmap" }} - mountPath: {{ .Values.server.config.path }}/resource-groups name: resource-groups-volume {{- end }} diff --git a/charts/trino/templates/tests/test-resource-groups-db.yaml b/charts/trino/templates/tests/test-resource-groups-db.yaml new file mode 100644 index 00000000..e04f4d94 --- /dev/null +++ b/charts/trino/templates/tests/test-resource-groups-db.yaml @@ -0,0 +1,33 @@ +{{- if eq .Values.resourceGroups.type "properties" }} +apiVersion: v1 +kind: Pod +metadata: + name: {{ include "trino.fullname" . }}-test-add-resourcegroups-data + labels: + {{- include "trino.labels" . | nindent 4 }} + app.kubernetes.io/component: test + test: add-resource-groups-data + annotations: + "helm.sh/hook": test + "helm.sh/hook-weight": "-1" +spec: + containers: + - name: mysql-client + image: bitnami/mysql:8.1 + command: + - /bin/sh + - -c + - | + echo "Inserting data into MySQL"; + mysql -h trino-resource-groups-db-mysql.mysql.svc.cluster.local -u trino -ppass0000 resource_groups -e " + -- create a root group 'admin' with NULL parent + INSERT INTO resource_groups (name, soft_memory_limit, hard_concurrency_limit, max_queued, scheduling_policy, environment) + VALUES ('admin', '100%', 50, 100, 'query_priority', 'production'); + -- use ID of 'admin' resource group for selector + INSERT INTO selectors (resource_group_id, user_regex, priority) VALUES ((SELECT resource_group_id FROM resource_groups WHERE name = 'admin'), 'admin', 6); + -- check data + SELECT * FROM resource_groups; + SELECT * FROM selectors;"; + sleep 5 + restartPolicy: Never +{{- end }} diff --git a/charts/trino/values.yaml b/charts/trino/values.yaml index 2fb187c7..9081f4ca 100644 --- a/charts/trino/values.yaml +++ b/charts/trino/values.yaml @@ -183,66 +183,80 @@ accessControl: {} # ``` resourceGroups: {} -# resourceGroups -- Resource groups file is mounted to /etc/trino/resource-groups/resource-groups.json +# resourceGroups -- [Resource groups control](https://trino.io/docs/current/admin/resource-groups.html) # @raw -# Example: +# Set the type property to either: +# * `configmap`, and provide the Resource groups file contents in `resourceGroupsConfig`, +# * `properties`, and provide configuration properties in `properties`. +# Properties example: +# ```yaml +# type: properties +# properties: | +# resource-groups.configuration-manager=db +# resource-groups.config-db-url=jdbc:mysql://trino-mysql.mysql.svc.cluster.local:3306/resource_groups +# resource-groups.config-db-user=username +# resource-groups.config-db-password=password +# ``` +# Config map example: # ```yaml +# type: configmap +# # Resource groups file is mounted to /etc/trino/resource-groups/resource-groups.json # resourceGroupsConfig: |- -# { -# "rootGroups": [ -# { -# "name": "global", -# "softMemoryLimit": "80%", -# "hardConcurrencyLimit": 100, -# "maxQueued": 100, -# "schedulingPolicy": "fair", -# "jmxExport": true, -# "subGroups": [ -# { -# "name": "admin", -# "softMemoryLimit": "30%", -# "hardConcurrencyLimit": 20, -# "maxQueued": 10 -# }, -# { -# "name": "finance_human_resources", -# "softMemoryLimit": "20%", -# "hardConcurrencyLimit": 15, -# "maxQueued": 10 -# }, -# { -# "name": "general", -# "softMemoryLimit": "30%", -# "hardConcurrencyLimit": 20, -# "maxQueued": 10 -# }, -# { -# "name": "readonly", -# "softMemoryLimit": "10%", -# "hardConcurrencyLimit": 5, -# "maxQueued": 5 -# } -# ] -# } -# ], -# "selectors": [ -# { -# "user": "admin", -# "group": "global.admin" -# }, -# { -# "group": "finance|human_resources", -# "group": "global.finance_human_resources" -# }, -# { -# "user": "alice", -# "group": "global.readonly" -# }, -# { -# "group": "global.general" -# } -# ] -# } +# { +# "rootGroups": [ +# { +# "name": "global", +# "softMemoryLimit": "80%", +# "hardConcurrencyLimit": 100, +# "maxQueued": 100, +# "schedulingPolicy": "fair", +# "jmxExport": true, +# "subGroups": [ +# { +# "name": "admin", +# "softMemoryLimit": "30%", +# "hardConcurrencyLimit": 20, +# "maxQueued": 10 +# }, +# { +# "name": "finance_human_resources", +# "softMemoryLimit": "20%", +# "hardConcurrencyLimit": 15, +# "maxQueued": 10 +# }, +# { +# "name": "general", +# "softMemoryLimit": "30%", +# "hardConcurrencyLimit": 20, +# "maxQueued": 10 +# }, +# { +# "name": "readonly", +# "softMemoryLimit": "10%", +# "hardConcurrencyLimit": 5, +# "maxQueued": 5 +# } +# ] +# } +# ], +# "selectors": [ +# { +# "user": "admin", +# "group": "global.admin" +# }, +# { +# "group": "finance|human_resources", +# "group": "global.finance_human_resources" +# }, +# { +# "user": "alice", +# "group": "global.readonly" +# }, +# { +# "group": "global.general" +# } +# ] +# } # ``` additionalNodeProperties: [] diff --git a/test-resource-groups-properties-values.yaml b/test-resource-groups-properties-values.yaml new file mode 100644 index 00000000..6cbaccce --- /dev/null +++ b/test-resource-groups-properties-values.yaml @@ -0,0 +1,15 @@ +# Resource Groups 'properties' values to test. +# This is a YAML-formatted file. + +server: + log: + trino: + level: INFO + +resourceGroups: + type: properties + properties: | + resource-groups.configuration-manager=db + resource-groups.config-db-url=jdbc:mysql://trino-resource-groups-db-mysql.mysql.svc.cluster.local:3306/resource_groups + resource-groups.config-db-user=trino + resource-groups.config-db-password=pass0000 diff --git a/test-values.yaml b/test-values.yaml index 0133f249..e12299e5 100644 --- a/test-values.yaml +++ b/test-values.yaml @@ -162,6 +162,66 @@ accessControl: ] } +resourceGroups: + type: configmap + resourceGroupsConfig: |- + { + "rootGroups": [ + { + "name": "global", + "softMemoryLimit": "80%", + "hardConcurrencyLimit": 100, + "maxQueued": 100, + "schedulingPolicy": "fair", + "jmxExport": true, + "subGroups": [ + { + "name": "admin", + "softMemoryLimit": "30%", + "hardConcurrencyLimit": 20, + "maxQueued": 10 + }, + { + "name": "finance_human_resources", + "softMemoryLimit": "20%", + "hardConcurrencyLimit": 15, + "maxQueued": 10 + }, + { + "name": "general", + "softMemoryLimit": "30%", + "hardConcurrencyLimit": 20, + "maxQueued": 10 + }, + { + "name": "readonly", + "softMemoryLimit": "10%", + "hardConcurrencyLimit": 5, + "maxQueued": 5 + } + ] + } + ], + "selectors": [ + { + "user": "admin", + "group": "global.admin" + }, + { + "group": "finance|human_resources", + "group": "global.finance_human_resources" + }, + { + "user": "alice", + "group": "global.readonly" + }, + { + "group": "global.general" + } + ] + } + + jmx: enabled: true registryPort: 9080 diff --git a/test.sh b/test.sh index 0b208033..2dd2efad 100755 --- a/test.sh +++ b/test.sh @@ -10,6 +10,7 @@ declare -A testCases=( [access_control_properties_values]="--values test-access-control-properties-values.yaml" [exchange_manager_values]="--values test-exchange-manager-values.yaml" [graceful_shutdown]="--values test-graceful-shutdown-values.yaml" + [resource_groups_properties_values]="--values test-resource-groups-properties-values.yaml" ) function join_by { @@ -24,7 +25,7 @@ NAMESPACE=trino-$(LC_ALL=C tr -dc 'a-z0-9' &2 @@ -100,6 +101,21 @@ if printf '%s\0' "${TEST_NAMES[@]}" | grep -qwz complete_values; then kubectl rollout status --watch deployments -l release=prometheus-operator -n "$NAMESPACE" fi +# only install the MySQL Helm chart when running the `resource_groups_properties_values` test +if printf '%s\0' "${TEST_NAMES[@]}" | grep -qwz resource_groups_properties_values; then + helm repo add bitnami https://charts.bitnami.com/bitnami + helm upgrade --install trino-resource-groups-db bitnami/mysql -n mysql \ + --create-namespace \ + --version "11.1.19" \ + --set image.tag=8.1 \ + --set auth.username=trino \ + --set auth.password=pass0000 \ + --set auth.database=resource_groups \ + --set primary.persistence.enabled=false \ + --set primary.extraFlags="--character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci" + kubectl wait --for=condition=ready pod -l app.kubernetes.io/name=mysql --timeout=300s -n mysql +fi + CT_ARGS+=(--namespace "$NAMESPACE") result=0 @@ -126,6 +142,8 @@ done if [ "$CLEANUP_NAMESPACE" == "true" ]; then helm -n "$NAMESPACE" uninstall prometheus-operator --ignore-not-found kubectl delete namespace "$NAMESPACE" + helm -n mysql uninstall trino-resource-groups-db --ignore-not-found + kubectl delete namespace mysql --ignore-not-found mapfile -t crds < <(kubectl api-resources --api-group=monitoring.coreos.com --output name) if [ ${#crds[@]} -ne 0 ]; then kubectl delete crd "${crds[@]}"