Skip to content

Commit

Permalink
Add more options for specifying the container image
Browse files Browse the repository at this point in the history
* Add support for image registry and digest
* Add option useRepositoryAsSoleImageReference...

Co-authored-by: Manfred Moser <[email protected]>
  • Loading branch information
zltyfsh and mosabua authored Mar 14, 2024
1 parent 2117df8 commit c7c652c
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 8 deletions.
7 changes: 5 additions & 2 deletions charts/trino/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,12 @@ The following table lists the configurable parameters of the Trino chart and the

| Parameter | Description | Default |
| ------------------------ | ----------------------- | -------------- |
| `image.repository` | | `"trinodb/trino"` |
| `image.registry` | Image registry, defaults to empty, which results in DockerHub usage | `""` |
| `image.repository` | Repository location of the Trino image, typically `organization/imagename` | `"trinodb/trino"` |
| `image.tag` | Image tag, defaults to the Trino release version specified as `appVersion` from Chart.yaml | `""` |
| `image.digest` | Optional digest value of the image specified as `sha256:abcd...`. A specified value overrides `tag`. | `""` |
| `image.useRepositoryAsSoleImageReference` | When true, only the content in `repository` is used as image reference | `false` |
| `image.pullPolicy` | | `"IfNotPresent"` |
| `image.tag` | | `432` |
| `imagePullSecrets` | | `[{"name": "registry-credentials"}]` |
| `server.workers` | | `2` |
| `server.node.environment` | | `"production"` |
Expand Down
28 changes: 28 additions & 0 deletions charts/trino/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -92,3 +92,31 @@ Create the name of the service account to use
{{- default "default" .Values.serviceAccount.name }}
{{- end }}
{{- end }}

{{/*
Return the proper image name
{{ include "trino.image" . }}

Code is inspired from bitnami/common

*/}}
{{- define "trino.image" -}}
{{- $repositoryName := .Values.image.repository -}}
{{- if .Values.image.useRepositoryAsSoleImageReference -}}
{{- printf "%s" $repositoryName -}}
{{- else -}}
{{- $repositoryName := .Values.image.repository -}}
{{- $registryName := .Values.image.registry -}}
{{- $separator := ":" -}}
{{- $termination := (default .Chart.AppVersion .Values.image.tag) | toString -}}
{{- if .Values.image.digest }}
{{- $separator = "@" -}}
{{- $termination = .Values.image.digest | toString -}}
{{- end -}}
{{- if $registryName }}
{{- printf "%s/%s%s%s" $registryName $repositoryName $separator $termination -}}
{{- else -}}
{{- printf "%s%s%s" $repositoryName $separator $termination -}}
{{- end -}}
{{- end -}}
{{- end -}}
2 changes: 1 addition & 1 deletion charts/trino/templates/deployment-coordinator.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ spec:
{{- toYaml .Values.imagePullSecrets | nindent 8 }}
containers:
- name: {{ .Chart.Name }}-coordinator
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
image: {{ include "trino.image" . }}
imagePullPolicy: {{ .Values.image.pullPolicy }}
env:
{{- toYaml .Values.env | nindent 12 }}
Expand Down
2 changes: 1 addition & 1 deletion charts/trino/templates/deployment-worker.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ spec:
{{- toYaml .Values.imagePullSecrets | nindent 8 }}
containers:
- name: {{ .Chart.Name }}-worker
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
image: {{ include "trino.image" . }}
imagePullPolicy: {{ .Values.image.pullPolicy }}
env:
{{- toYaml .Values.env | nindent 12 }}
Expand Down
9 changes: 5 additions & 4 deletions charts/trino/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@
# Declare variables to be passed into your templates.

image:
repository: trinodb/trino
registry: "" # Image registry, defaults to empty, which results in DockerHub usage
repository: trinodb/trino # Repository location of the Trino image, typically `organization/imagename`
tag: "" # Image tag, defaults to the Trino release version specified as `appVersion` from Chart.yaml
digest: "" # Optional digest value of the image specified as `sha256:abcd...`. A specified value overrides `tag`.
useRepositoryAsSoleImageReference: false # When true, only the content in `repository` is used as image reference
pullPolicy: IfNotPresent
# Overrides the image tag whose default is the chart version.
# Same value as Chart.yaml#appVersion
tag: 432

imagePullSecrets:
- name: registry-credentials
Expand Down

0 comments on commit c7c652c

Please sign in to comment.