diff --git a/charts/gateway/README.md b/charts/gateway/README.md index 8cb9ffc9..1f1492f8 100644 --- a/charts/gateway/README.md +++ b/charts/gateway/README.md @@ -53,8 +53,9 @@ A Helm chart for Trino Gateway * `command` - list, default: `["java","-XX:MinRAMPercentage=80.0","-XX:MaxRAMPercentage=80.0","-jar","/usr/lib/trino/gateway-ha-jar-with-dependencies.jar","/etc/gateway/config.yaml"]` Startup command for Trino Gateway process. Add additional Java options and other modifications as desired. -* `service.type` - string, default: `"ClusterIP"` -* `service.port` - int, default: `8080` +* `service` - object, default: `{"spec":{"ports":[{"name":"request","protocol":"TCP"}],"type":"ClusterIP"}}` + + service for accessing the gateway. The `port` and `targetPort` of the first element of the ports list will automatically be set to the value of `config.serverConfig."http-server.http.port"`. Additional ports (for JMX or a Java Agent for example) can be configured by adding additional elements to the ports list. The selector is also automatically configured. All other values are passed through as is. * `ingress.enabled` - bool, default: `false` * `ingress.className` - string, default: `""` * `ingress.annotations` - object, default: `{}` diff --git a/charts/gateway/templates/NOTES.txt b/charts/gateway/templates/NOTES.txt index 660b90f9..32eb0d5a 100644 --- a/charts/gateway/templates/NOTES.txt +++ b/charts/gateway/templates/NOTES.txt @@ -5,24 +5,20 @@ You can get the Trino Gateway endpoints by running these commands: http{{ if $.Values.ingress.tls }}s{{ end }}://{{ $host.host }}{{ .path }} {{- end }} {{- end }} -{{- else if contains "NodePort" .Values.service.type }} - export REQUEST_NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath='{.spec.ports[?(@.name == "request")].nodePort}' services {{ include "trino-gateway.fullname" . }}) - export APP_NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath='{.spec.ports[?(@.name == "app")].nodePort}' services {{ include "trino-gateway.fullname" . }}) - export ADMIN_NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath='{.spec.ports[?(@.name == "admin")].nodePort}' services {{ include "trino-gateway.fullname" . }}) +{{- else if contains "NodePort" .Values.service.spec.type }} + export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath='{.spec.ports[0].nodePort}' services {{ include "trino-gateway.fullname" . }}) export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath='{.items[0].status.addresses[0].address}') - echo http://$NODE_IP:$REQUEST_NODE_PORT -{{- else if contains "LoadBalancer" .Values.service.type }} + echo http://$NODE_IP:$NODE_PORT +{{- else if contains "LoadBalancer" .Values.service.spec.type }} NOTE: It may take a few minutes for the LoadBalancer IP to be available. You can watch the status of by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "trino-gateway.fullname" . }}' export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "trino-gateway.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}") - echo http://$SERVICE_IP:{{ .Values.service.port }} -{{- else if contains "ClusterIP" .Values.service.type }} + echo http://$SERVICE_IP:'{{ .Values.service.spec.ports | first | get "port" }}' +{{- else if contains "ClusterIP" .Values.service.spec.type }} export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "trino-gateway.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}") - export REQUEST_PORT=$(kubectl get pod --namespace test $POD_NAME -o jsonpath='{.spec.containers[0].ports[?(@.name == "request")].containerPort}') - export APP_PORT=$(kubectl get pod --namespace test $POD_NAME -o jsonpath='{.spec.containers[0].ports[?(@.name == "app")].containerPort}') - export ADMIN_PORT=$(kubectl get pod --namespace test $POD_NAME -o jsonpath='{.spec.containers[0].ports[?(@.name == "admin")].containerPort}') + export PORT=$(kubectl get pod --namespace test $POD_NAME -o jsonpath='{.spec.containers[0].ports[0].containerPort}') echo "Visit http://127.0.0.1:8080 to use your application" - kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 8080:$REQUEST_PORT + kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 8080:$PORT {{- end }} Happy Helming! diff --git a/charts/gateway/templates/service.yaml b/charts/gateway/templates/service.yaml index 18fc5953..481b205d 100644 --- a/charts/gateway/templates/service.yaml +++ b/charts/gateway/templates/service.yaml @@ -4,11 +4,16 @@ metadata: name: {{ include "trino-gateway.fullname" . }} labels: {{- include "trino-gateway.labels" . | nindent 4 }} -spec: - type: {{ .Values.service.type }} - ports: - - port: {{ index .Values "config" "serverConfig" "http-server.http.port" }} - protocol: TCP - name: request - selector: - {{- include "trino-gateway.selectorLabels" . | nindent 4 }} +{{- $httpPort := index .Values "config" "serverConfig" "http-server.http.port" }} +{{- $portDefault := dict "port" $httpPort "targetPort" $httpPort }} +{{- $portValues := .Values.service.spec.ports | default list | first | default $portDefault}} +{{- $_0 := set $portValues "port" $httpPort}} +{{- $_1 := set $portValues "targetPort" $httpPort}} +{{- $ports := list $portValues }} +{{- $additionalPorts := .Values.service.spec.ports | default list | rest }} +{{- $allPorts := concat $ports $additionalPorts}} +{{- $spec := .Values.service.spec }} +{{- $_2 := set $spec "ports" $allPorts }} +{{- $selectorLabels := include "trino-gateway.selectorLabels" . | fromYaml }} +{{- $_3 := set $spec "selector" $selectorLabels }} +spec: {{ $spec | toYaml | nindent 2}} diff --git a/charts/gateway/values.yaml b/charts/gateway/values.yaml index 1e883b7e..aec6fb82 100644 --- a/charts/gateway/values.yaml +++ b/charts/gateway/values.yaml @@ -68,9 +68,16 @@ command: - "/usr/lib/trino/gateway-ha-jar-with-dependencies.jar" - "/etc/gateway/config.yaml" +# -- service for accessing the gateway. The `port` and `targetPort` of the first element of the ports list will +# automatically be set to the value of `config.serverConfig."http-server.http.port"`. Additional ports (for JMX +# or a Java Agent for example) can be configured by adding additional elements to the ports list. The selector is +# also automatically configured. All other values are passed through as is. service: - type: ClusterIP - port: 8080 + spec: + type: ClusterIP + ports: + - protocol: TCP + name: request ingress: enabled: false