Skip to content

Commit

Permalink
trino 0.2.0: Add support for statefulset and persistance on trino hel…
Browse files Browse the repository at this point in the history
…m chart
  • Loading branch information
illomi7 committed Apr 29, 2024
1 parent f0a12dd commit 3560fa4
Show file tree
Hide file tree
Showing 6 changed files with 177 additions and 9 deletions.
4 changes: 2 additions & 2 deletions charts/trino/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ 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.1.44
version: 0.2.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
# follow Semantic Versioning. They should reflect the version the application is using.
appVersion: '444'
appVersion: '445'
8 changes: 8 additions & 0 deletions charts/trino/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,18 @@ Create chart name and version as used by the chart label.
{{ template "trino.fullname" . }}-coordinator
{{- end -}}

{{- define "trino.coordinator.svcName" -}}
{{ template "trino.coordinator" . }}-headless
{{- end -}}

{{- define "trino.worker" -}}
{{ template "trino.fullname" . }}-worker
{{- end -}}

{{- define "trino.worker.svcName" -}}
{{ template "trino.worker" . }}-headless
{{- end -}}

{{- define "trino.connectors" -}}
{{ template "trino.fullname" . }}-connectors
{{- end -}}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
apiVersion: apps/v1
kind: Deployment
kind: {{ .Values.server.kind }}
metadata:
name: {{ template "trino.coordinator" . }}
labels:
Expand All @@ -9,11 +9,15 @@ metadata:
heritage: {{ .Release.Service }}
component: coordinator
spec:

selector:
matchLabels:
app: {{ template "trino.name" . }}
release: {{ .Release.Name }}
component: coordinator
{{ if (eq .Values.server.kind "StatefulSet") }}
serviceName: {{ template "trino.coordinator.svcName" . }}
{{ end }}
template:
metadata:
labels:
Expand All @@ -27,8 +31,7 @@ spec:
{{- end }}
{{- with .Values.securityContext }}
securityContext:
runAsUser: {{ .runAsUser }}
runAsGroup: {{ .runAsGroup }}
fsGroup: {{ .runAsGroup }}
{{- end }}
volumes:
- name: config-volume
Expand All @@ -41,16 +44,33 @@ spec:
- name: config-jmx-exporter
configMap:
name: {{ template "trino.jmx-exporter" . }}
{{ end }}
{{ end }}
{{ if or (not .Values.worker.persistence.enabled) (not (eq .Values.server.kind "StatefulSet")) }}
- name: trino-data
emptyDir: {}
{{ end }}
containers:
- name: {{ .Chart.Name }}-coordinator
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}

{{- with .Values.securityContext }}
securityContext:
runAsUser: {{ .runAsUser }}
runAsGroup: {{ .runAsGroup }}
{{- end }}
volumeMounts:
- mountPath: {{ .Values.server.config.path }}
name: config-volume
- mountPath: {{ .Values.server.config.path }}/catalog
name: connectors-config-volume
- name: trino-data
mountPath: {{ .Values.coordinator.persistence.path }}
{{- if .Values.coordinator.persistence.subPath }}
subPath: {{ .Values.coordinator.persistence.subPath }}
{{- else if .Values.coordinator.persistence.subPathExpr }}
subPathExpr: {{ .Values.coordinator.persistence.subPathExpr }}
{{- end }}
ports:
- name: http
containerPort: {{ .Values.service.port }}
Expand Down Expand Up @@ -123,3 +143,34 @@ spec:
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}

{{ if and (.Values.worker.persistence.enabled ) (eq .Values.server.kind "StatefulSet") }}

{{ if .Values.coordinator.persistentVolumeClaimRetentionPolicy.enabled }}
persistentVolumeClaimRetentionPolicy:
whenDeleted: {{ .Values.coordinator.persistentVolumeClaimRetentionPolicy.whenDeleted }}
whenScaled: {{ .Values.coordinator.persistentVolumeClaimRetentionPolicy.whenScaled }}
{{ end }}

volumeClaimTemplates:
- apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: trino-data
labels:
app: {{ template "trino.name" . }}
chart: {{ template "trino.chart" . }}
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
component: coordinator
spec:
storageClassName: {{ .Values.worker.persistence.storageClass | quote }}
accessModes:
{{ range .Values.coordinator.persistence.accessModes }}
- {{ . | quote }}
{{ end }}
resources:
requests:
storage: {{ .Values.coordinator.persistence.size | quote }}
{{ end }}

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{{- if gt (int .Values.server.workers) 0 }}
apiVersion: apps/v1
kind: Deployment
kind: {{ .Values.server.kind }}
metadata:
name: {{ template "trino.worker" . }}
labels:
Expand All @@ -11,6 +11,9 @@ metadata:
component: worker
spec:
replicas: {{ .Values.server.workers }}
{{ if (eq .Values.server.kind "StatefulSet") }}
serviceName: {{ template "trino.worker.svcName" . }}
{{ end }}
selector:
matchLabels:
app: {{ template "trino.name" . }}
Expand All @@ -27,6 +30,10 @@ spec:
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.securityContext }}
securityContext:
fsGroup: {{ .runAsGroup }}
{{- end }}
volumes:
- name: config-volume
configMap:
Expand All @@ -39,16 +46,32 @@ spec:
configMap:
name: {{ template "trino.jmx-exporter" . }}
{{ end }}
{{ if or (not .Values.worker.persistence.enabled) (not (eq .Values.server.kind "StatefulSet")) }}
- name: trino-data
emptyDir: {}
{{ end }}
terminationGracePeriodSeconds: {{ .Values.server.gracefulShutdown.gracePeriodSeconds }}
containers:
- name: {{ .Chart.Name }}-worker
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
{{- with .Values.securityContext }}
securityContext:
runAsUser: {{ .runAsUser }}
runAsGroup: {{ .runAsGroup }}
{{- end }}
volumeMounts:
- mountPath: {{ .Values.server.config.path }}
name: config-volume
- mountPath: {{ .Values.server.config.path }}/catalog
name: connectors-config-volume
- name: trino-data
mountPath: {{ .Values.worker.persistence.path }}
{{- if .Values.worker.persistence.subPath }}
subPath: {{ .Values.worker.persistence.subPath }}
{{- else if .Values.worker.persistence.subPathExpr }}
subPathExpr: {{ .Values.worker.persistence.subPathExpr }}
{{- end }}
ports:
- name: http
containerPort: {{ .Values.service.port }}
Expand Down Expand Up @@ -129,4 +152,35 @@ spec:
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}


{{ if and (.Values.worker.persistence.enabled ) (eq .Values.server.kind "StatefulSet") }}

{{ if .Values.worker.persistentVolumeClaimRetentionPolicy.enabled }}
persistentVolumeClaimRetentionPolicy:
whenDeleted: { { .Values.worker.persistentVolumeClaimRetentionPolicy.whenDeleted } }
whenScaled: { { .Values.worker.persistentVolumeClaimRetentionPolicy.whenScaled } }
{{ end }}

volumeClaimTemplates:
- apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: trino-data
labels:
app: {{ template "trino.name" . }}
chart: {{ template "trino.chart" . }}
release: {{ .Release.Name }}
heritage: {{ .Release.Service }}
component: worker
spec:
storageClassName: {{ .Values.worker.persistence.storageClass | quote }}
accessModes:
{{ range .Values.worker.persistence.accessModes }}
- {{ . | quote }}
{{ end }}
resources:
requests:
storage: {{ .Values.worker.persistence.size | quote }}
{{ end }}
{{- end }}
23 changes: 23 additions & 0 deletions charts/trino/values.schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"$schema": "http://json-schema.org/schema#",
"type": "object",
"properties": {
"server": {
"type": "object",
"title": "Server settings",
"form": true,
"properties": {
"kind": {
"type": "string",
"title": "Workload Kind",
"form": true,
"description": "Allowed values: `Deployment`or `StatefulSet`",
"enum": [
"Deployment",
"StatefulSet"
]
}
}
}
}
}
36 changes: 34 additions & 2 deletions charts/trino/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@
# Declare variables to be passed into your templates.

image:
repository: trinodb/trino
repository: trinodb/trino
pullPolicy: IfNotPresent
tag: 444
tag: 445
imagePullSecrets: []

server:
kind: Deployment
workers: 2
node:
environment: production
Expand Down Expand Up @@ -64,12 +65,43 @@ coordinator:
tolerations: []
affinity: {}
resources: {}
persistence:
enabled: false
path: /data
subPath: ""
subPathExpr: ""
storageClass: ""
accessModes:
- ReadWriteOnce
size: 8Gi
dataSource: { }
existingClaim: ""
persistentVolumeClaimRetentionPolicy:
enabled: false
whenScaled: Retain
whenDeleted: Retain

worker:
nodeSelector: {}
tolerations: []
affinity: {}
resources: {}
persistence:
enabled: false
path: /data
subPath: ""
subPathExpr: ""
storageClass: ""
accessModes:
- ReadWriteOnce
size: 8Gi
selector: { }
dataSource: { }
existingClaim: ""
persistentVolumeClaimRetentionPolicy:
enabled: false
whenScaled: Retain
whenDeleted: Retain

exporters:
jmx:
Expand Down

0 comments on commit 3560fa4

Please sign in to comment.