Skip to content

Support LB spec & coordinator-only annotations #369

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions charts/trino/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -491,6 +491,20 @@ Fast distributed SQL query engine for big data analytics that helps you explore
path: /secrets/sample.json
subPath: sample.json
```
* `coordinator.service` - object, default: `{}`

Service overrides just for the coordinator service. It is merged with the root-level service specification. Beware that specifying spec.ports will override the dynamically generated ports for JMX exporter as well as the additionalExposedPorts.
Example:
```yaml
annotations:
external-dns.alpha.kubernetes.io/hostname: trino.example.com
spec:
type: LoadBalancer
externalTrafficPolicy: Local
loadBalancerSourceRanges:
- 1.2.3.4/32
- 10.0.0.0/8
```
* `coordinator.deployment.annotations` - object, default: `{}`
* `coordinator.deployment.progressDeadlineSeconds` - int, default: `600`

Expand Down Expand Up @@ -629,6 +643,20 @@ Fast distributed SQL query engine for big data analytics that helps you explore
path: /secrets/sample.json
subPath: sample.json
```
* `worker.service` - object, default: `{}`

Service overrides just for the worker service. It is merged with the root-level service specification. Beware that specifying spec.ports will override the dynamically generated ports for JMX exporter as well as the additionalExposedPorts.
Example:
```yaml
annotations:
external-dns.alpha.kubernetes.io/hostname: trino-workers.example.com
spec:
type: LoadBalancer
externalTrafficPolicy: Local
loadBalancerSourceRanges:
- 1.2.3.4/32
- 10.0.0.0/8
```
* `worker.deployment.annotations` - object, default: `{}`
* `worker.deployment.progressDeadlineSeconds` - int, default: `600`

Expand Down
18 changes: 16 additions & 2 deletions charts/trino/templates/service-coordinator.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
{{- $coordinatorJmx := merge .Values.jmx.coordinator (omit .Values.jmx "coordinator" "worker") -}}
{{- $coordinatorSvcSpecOverride := index .Values.coordinator.service "spec" | default dict -}}
{{- $coordinatorSvcAnnotations := deepCopy .Values.service.annotations | merge (index .Values.coordinator.service "annotations" | default dict) -}}
apiVersion: v1
kind: Service
metadata:
Expand All @@ -8,9 +10,17 @@ metadata:
{{- include "trino.labels" . | nindent 4 }}
app.kubernetes.io/component: coordinator
annotations:
{{- toYaml .Values.service.annotations | nindent 4 }}
{{- toYaml $coordinatorSvcAnnotations | nindent 4 }}
spec:
type: {{ .Values.service.type }}
{{- if gt (len $coordinatorSvcSpecOverride) 0 }}
{{- toYaml $coordinatorSvcSpecOverride | nindent 2 }}
{{- end }}

{{- if not (hasKey $coordinatorSvcSpecOverride "type") }}
type: {{ default .Values.service.type }}
{{- end }}

{{- if not (hasKey $coordinatorSvcSpecOverride "ports") }}
ports:
- port: {{ .Values.service.port }}
targetPort: http
Expand Down Expand Up @@ -43,6 +53,10 @@ spec:
nodePort: {{ $value.nodePort }}
{{- end }}
{{- end }}
{{- end }}

{{- if not (hasKey $coordinatorSvcSpecOverride "selector") }}
selector:
{{- include "trino.selectorLabels" . | nindent 4 }}
app.kubernetes.io/component: coordinator
{{- end }}
17 changes: 16 additions & 1 deletion charts/trino/templates/service-worker.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
{{- $workerJmx := merge .Values.jmx.worker (omit .Values.jmx "coordinator" "worker") -}}
{{- $workerSvcSpecOverride := index .Values.worker.service "spec" | default dict -}}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This template gets pretty complicated, and we need to update tests to cover at least parts of the new use cases supported. See if you could update tests/trino/test-values.yaml. If not, create a new test.

{{- $workerSvcAnnotations := deepCopy .Values.service.annotations | merge (index .Values.worker.service "annotations" | default dict) -}}
{{- $workerSvcIsLoadBalancer := eq (index $workerSvcSpecOverride "type" | default "") "LoadBalancer" -}}
apiVersion: v1
kind: Service
metadata:
Expand All @@ -8,9 +11,17 @@ metadata:
{{- include "trino.labels" . | nindent 4 }}
app.kubernetes.io/component: worker
annotations:
{{- toYaml .Values.service.annotations | nindent 4 }}
{{- toYaml $workerSvcAnnotations | nindent 4 }}
spec:
{{- if gt (len $workerSvcSpecOverride) 0 }}
{{- toYaml $workerSvcSpecOverride | nindent 2 }}
{{- end }}

{{- if not $workerSvcIsLoadBalancer }}
clusterIP: None
{{- end }}

{{- if not (hasKey $workerSvcSpecOverride "ports") }}
ports:
- port: {{ .Values.service.port }}
targetPort: http
Expand All @@ -31,6 +42,10 @@ spec:
nodePort: {{ $value.nodePort }}
{{- end }}
{{- end }}
{{- end }}

{{- if not (hasKey $workerSvcSpecOverride "selector") }}
selector:
{{- include "trino.selectorLabels" . | nindent 4 }}
app.kubernetes.io/component: worker
{{- end }}
29 changes: 29 additions & 0 deletions charts/trino/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -550,6 +550,21 @@ secretMounts: []
# ```

coordinator:
service: {}
# coordinator.service -- Service overrides just for the coordinator service. It is merged with the root-level service specification. Beware that specifying spec.ports will override the dynamically generated ports for JMX exporter as well as the additionalExposedPorts.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO, we should not allow specifying both the top-level service and coordinator or worker services. It's too easy to make a mistake, like specifying the wrong type, and one will be ignored.

There's a similar PR #360 and we had this discussion there: #360 (comment)

# @raw
# Example:
# ```yaml
# annotations:
# external-dns.alpha.kubernetes.io/hostname: trino.example.com
# spec:
# type: LoadBalancer
# externalTrafficPolicy: Local
# loadBalancerSourceRanges:
# - 1.2.3.4/32
# - 10.0.0.0/8
# ```

deployment:
annotations: {}
progressDeadlineSeconds: 600
Expand Down Expand Up @@ -735,6 +750,20 @@ coordinator:
# ```

worker:
service: {}
# worker.service -- Service overrides just for the worker service. It is merged with the root-level service specification. Beware that specifying spec.ports will override the dynamically generated ports for JMX exporter as well as the additionalExposedPorts.
# @raw
# Example:
# ```yaml
# annotations:
# external-dns.alpha.kubernetes.io/hostname: trino-workers.example.com
# spec:
# type: LoadBalancer
# externalTrafficPolicy: Local
# loadBalancerSourceRanges:
# - 1.2.3.4/32
# - 10.0.0.0/8
# ```
deployment:
annotations: {}
progressDeadlineSeconds: 600
Expand Down