From 2438f796e0e5bdc30785070291fab043e97796c6 Mon Sep 17 00:00:00 2001 From: dragonslayer27 Date: Mon, 4 Apr 2022 23:28:31 -0400 Subject: [PATCH] Access control support --- charts/trino/README.md | 1 + .../templates/configmap-coordinator.yaml | 25 +++++++++ .../templates/deployment-coordinator.yaml | 9 ++++ charts/trino/values.yaml | 51 +++++++++++++++++++ 4 files changed, 86 insertions(+) diff --git a/charts/trino/README.md b/charts/trino/README.md index 10b17df9..1d301601 100644 --- a/charts/trino/README.md +++ b/charts/trino/README.md @@ -36,6 +36,7 @@ The following table lists the configurable parameters of the Trino chart and the | `server.autoscaling.enabled` | | `false` | | `server.autoscaling.maxReplicas` | | `5` | | `server.autoscaling.targetCPUUtilizationPercentage` | | `50` | +| `accessControl` | | `{}` | | `additionalNodeProperties` | | `{}` | | `additionalConfigProperties` | | `{}` | | `additionalLogProperties` | | `{}` | diff --git a/charts/trino/templates/configmap-coordinator.yaml b/charts/trino/templates/configmap-coordinator.yaml index 6cf4d5e7..90eb6a3a 100644 --- a/charts/trino/templates/configmap-coordinator.yaml +++ b/charts/trino/templates/configmap-coordinator.yaml @@ -62,6 +62,15 @@ data: {{- end }} {{ .Values.server.coordinatorExtraConfig | indent 4 }} +{{- if .Values.accessControl }}{{- if eq .Values.accessControl.type "configmap" }} + access-control.properties: | + access-control.name=file + {{- if .Values.accessControl.refreshPeriod }} + security.refresh-period={{ .Values.accessControl.refreshPeriod }} + {{- end }} + security.config-file={{ .Values.server.config.path }}/access-control/{{ .Values.accessControl.configFile | default "rules.json" }} +{{- end }}{{- end }} + exchange-manager.properties: | exchange-manager.name={{ .Values.server.exchangeManager.name }} exchange.base-directory={{ .Values.server.exchangeManager.baseDir }} @@ -89,3 +98,19 @@ data: {{ end }} --- + +{{- if .Values.accessControl }}{{- if eq .Values.accessControl.type "configmap" }} +apiVersion: v1 +kind: ConfigMap +metadata: + name: trino-access-control-volume-coordinator + labels: + {{- include "trino.labels" . | nindent 4 }} + app.kubernetes.io/component: coordinator +data: + {{- range $key, $val := .Values.accessControl.rules }} + {{ $key }}: {{ $val | quote }} + {{- end }} +{{- end }}{{- end }} + +--- \ No newline at end of file diff --git a/charts/trino/templates/deployment-coordinator.yaml b/charts/trino/templates/deployment-coordinator.yaml index d73401ca..3ffef9ad 100644 --- a/charts/trino/templates/deployment-coordinator.yaml +++ b/charts/trino/templates/deployment-coordinator.yaml @@ -34,6 +34,11 @@ spec: - name: catalog-volume configMap: name: {{ template "trino.catalog" . }} + {{- if .Values.accessControl }}{{- if eq .Values.accessControl.type "configmap" }} + - name: access-control-volume + configMap: + name: trino-access-control-volume-coordinator + {{- end }}{{- end }} {{- if eq .Values.server.config.authenticationType "PASSWORD" }} - name: password-volume secret: @@ -61,6 +66,10 @@ spec: name: config-volume - mountPath: {{ .Values.server.config.path }}/catalog name: catalog-volume + {{- if .Values.accessControl }}{{- if eq .Values.accessControl.type "configmap" }} + - mountPath: {{ .Values.server.config.path }}/access-control + name: access-control-volume + {{- end }}{{- end }} {{- range .Values.secretMounts }} - name: {{ .name }} mountPath: {{ .path }} diff --git a/charts/trino/values.yaml b/charts/trino/values.yaml index b421a860..56479a3e 100644 --- a/charts/trino/values.yaml +++ b/charts/trino/values.yaml @@ -47,6 +47,57 @@ server: maxReplicas: 5 targetCPUUtilizationPercentage: 50 +accessControl: {} + # type: configmap + # refreshPeriod: 60s + # # Rules file is mounted to /etc/trino/access-control + # configFile: "rules.json" + # rules: + # rules.json: |- + # { + # "catalogs": [ + # { + # "user": "admin", + # "catalog": "(mysql|system)", + # "allow": "all" + # }, + # { + # "group": "finance|human_resources", + # "catalog": "postgres", + # "allow": true + # }, + # { + # "catalog": "hive", + # "allow": "all" + # }, + # { + # "user": "alice", + # "catalog": "postgresql", + # "allow": "read-only" + # }, + # { + # "catalog": "system", + # "allow": "none" + # } + # ], + # "schemas": [ + # { + # "user": "admin", + # "schema": ".*", + # "owner": true + # }, + # { + # "user": "guest", + # "owner": false + # }, + # { + # "catalog": "default", + # "schema": "default", + # "owner": true + # } + # ] + # } + additionalNodeProperties: {} additionalConfigProperties: {}