Skip to content

Commit 706f94c

Browse files
willmostlynineinchnick
authored andcommitted
Add envFrom and remove lookup
1 parent fa1f5a8 commit 706f94c

File tree

6 files changed

+62
-50
lines changed

6 files changed

+62
-50
lines changed

charts/gateway/README.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,15 +28,15 @@ A Helm chart for Trino Gateway
2828
imagePullSecrets:
2929
- name: registry-credentials
3030
```
31-
* `dataStoreSecret` - object, default: `{"key":"","name":""}`
31+
* `envFrom` - list, default: `[]`
3232

33-
Provide configuration for the Trino Gateway `dataStore` in `dataStoreSecret`. This node can be left undefined if `dataStore` is defined under the config node. For production deployments sensitive values should be stored in a Secret
34-
* `backendStateSecret` - object, default: `{"key":"","name":""}`
35-
36-
Provide configuration for the Trino Gateway `backendState` in `backendStateSecret`. This should be used with health check configurations that require backend credentials. This node can be left undefined if `dataStore` is defined under the config node.
37-
* `authenticationSecret` - object, default: `{"key":"","name":""}`
38-
39-
Provide configuration for the Trino Gateway authentication configuration in `authenticationSecret`. This node can be left undefined if `dataStore` is defined under the config node.
33+
A list of secrets and configmaps to mount into the init container as environment variables.
34+
Example:
35+
```yaml
36+
envFrom:
37+
- secretRef:
38+
name: password-secret
39+
```
4040
* `config.serverConfig."node.environment"` - string, default: `"test"`
4141
* `config.serverConfig."http-server.http.port"` - int, default: `8080`
4242
* `config.dataStore.jdbcUrl` - string, default: `"jdbc:postgresql://localhost:5432/gateway"`

charts/gateway/templates/deployment.yaml

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,6 @@ spec:
1414
template:
1515
metadata:
1616
annotations:
17-
# Include the version of trino-gateway-configuration as an input to the
18-
# deployment checksum. This causes pods to restart on helm update
19-
# whether the chart `config` is updated or if one of the configuration
20-
# secrets is updated. Helm template must be run with the
21-
# --dry-run=server option to prevent a nil pointer.
22-
checksum/config: {{ (coalesce (lookup "v1" "Secret" .Release.Namespace "trino-gateway-configuration").metadata (dict "resourceVersion" "0")).resourceVersion | sha256sum}}
2317
{{- with .Values.podAnnotations }}
2418
{{- toYaml . | nindent 8 }}
2519
{{- end }}
@@ -44,6 +38,8 @@ spec:
4438
imagePullPolicy: {{ .Values.image.pullPolicy }}
4539
command:
4640
{{- toYaml .Values.command | nindent 12}}
41+
envFrom:
42+
{{- toYaml .Values.envFrom | nindent 12}}
4743
ports:
4844
- name: request
4945
containerPort: {{ index .Values "config" "serverConfig" "http-server.http.port" }}

charts/gateway/templates/secrets.yaml

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,7 @@
1-
{{ $dataStoreDict := dict}}
2-
{{ if .Values.dataStoreSecret.name }}
3-
{{ $dataStoreDict = (index (lookup "v1" "Secret" .Release.Namespace .Values.dataStoreSecret.name).data .Values.dataStoreSecret.key) | b64dec | fromYaml }}
4-
{{ end }}
5-
{{ $backendStateDict := dict }}
6-
{{ if .Values.backendStateSecret.name }}
7-
{{ $backendStateDict = (index (lookup "v1" "Secret" .Release.Namespace .Values.backendStateSecret.name).data .Values.backendStateSecret.key) | b64dec | fromYaml }}
8-
{{ end }}
9-
{{ $authenticationDict := dict }}
10-
{{ if .Values.authenticationSecret.name }}
11-
# {{.Values.authenticationSecret.name }} #
12-
# {{ index (lookup "v1" "Secret" .Release.Namespace .Values.authenticationSecret.name).data .Values.authenticationSecret.key }} #
13-
{{ $authenticationDict = (index (lookup "v1" "Secret" .Release.Namespace .Values.authenticationSecret.name).data .Values.authenticationSecret.key) | b64dec | fromYaml }}
14-
{{ end }}
15-
161
apiVersion: v1
172
kind: Secret
183
metadata:
194
name: trino-gateway-configuration
205
type: "Opaque"
216
data:
22-
config.yaml: "{{toYaml (merge .Values.config $authenticationDict $dataStoreDict $backendStateDict ) | b64enc}}"
7+
config.yaml: "{{toYaml .Values.config | b64enc}}"

charts/gateway/values.yaml

Lines changed: 9 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -20,25 +20,15 @@ image:
2020
# ```
2121
imagePullSecrets: []
2222

23-
# -- Provide configuration for the Trino Gateway `dataStore` in `dataStoreSecret`. This node can
24-
# be left undefined if `dataStore` is defined under the config node. For production deployments
25-
# sensitive values should be stored in a Secret
26-
dataStoreSecret:
27-
name: ""
28-
key: ""
29-
30-
# -- Provide configuration for the Trino Gateway `backendState` in `backendStateSecret`. This should
31-
# be used with health check configurations that require backend credentials. This node can
32-
# be left undefined if `dataStore` is defined under the config node.
33-
backendStateSecret:
34-
name: ""
35-
key: ""
36-
37-
# -- Provide configuration for the Trino Gateway authentication configuration in `authenticationSecret`.
38-
# This node can be left undefined if `dataStore` is defined under the config node.
39-
authenticationSecret:
40-
name: ""
41-
key: ""
23+
# -- A list of secrets and configmaps to mount into the init container as environment variables.
24+
# @raw
25+
# Example:
26+
# ```yaml
27+
# envFrom:
28+
# - secretRef:
29+
# name: password-secret
30+
# ```
31+
envFrom: []
4232

4333
config:
4434
serverConfig:
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
replicaCount: 1
2+
3+
image:
4+
# -- Repository location of the Trino Gateway image, typically `organization/imagename`
5+
repository: "trinodb/trino-gateway"
6+
pullPolicy: IfNotPresent
7+
8+
config:
9+
serverConfig:
10+
node.environment: test
11+
http-server.http.port: 8080
12+
dataStore:
13+
# The connection details for the backend database for Trino Gateway and Trino query history
14+
jdbcUrl: jdbc:postgresql://gateway-backend-db-postgresql.postgres-gateway.svc.cluster.local:5432/gateway
15+
user: "${ENV:PG_USER}"
16+
password: "${ENV:PG_PASSWORD}"
17+
driver: org.postgresql.Driver
18+
clusterStatsConfiguration:
19+
monitorType: INFO_API
20+
modules:
21+
- io.trino.gateway.ha.module.HaGatewayProviderModule
22+
- io.trino.gateway.ha.module.ClusterStateListenerModule
23+
- io.trino.gateway.ha.module.ClusterStatsMonitorModule
24+
managedApps:
25+
- io.trino.gateway.ha.clustermonitor.ActiveClusterMonitor
26+
27+
envFrom:
28+
- secretRef:
29+
name: db-credentials
30+
31+
resources:
32+
limits:
33+
cpu: 500m
34+
memory: 256Mi
35+
requests:
36+
cpu: 250m
37+
memory: 256Mi

tests/gateway/test.sh

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,12 @@ set -euo pipefail
44

55
declare -A testCases=(
66
[complete_values]="--values test-values.yaml"
7+
[env_from]="--values test-values-with-env.yaml"
78
)
89

910
declare -A testCaseCharts=(
1011
[complete_values]="../../charts/gateway"
12+
[env_from]="../../charts/gateway"
1113
)
1214

1315
function join_by {
@@ -28,7 +30,7 @@ CT_ARGS=(
2830
--helm-extra-args="--timeout 2m"
2931
)
3032
CLEANUP_NAMESPACE=true
31-
TEST_NAMES=(complete_values)
33+
TEST_NAMES=(complete_values env_from)
3234

3335
usage() {
3436
cat <<EOF 1>&2
@@ -87,6 +89,8 @@ helm upgrade --install ${DB_INSTALLATION_NAME} oci://registry-1.docker.io/bitnam
8789
--set primary.persistence.enabled=false
8890
kubectl wait --for=condition=ready pod -l app.kubernetes.io/name=postgresql --timeout=300s -n "$DB_NAMESPACE"
8991

92+
kubectl --namespace "$NAMESPACE" create secret generic db-credentials --from-literal=PG_USER='gateway' --from-literal=PG_PASSWORD='pass0000'
93+
9094
result=0
9195
for test_name in "${TEST_NAMES[@]}"; do
9296
echo 1>&2 ""

0 commit comments

Comments
 (0)