Skip to content

Split out image specification in Helm charts #67

@rjaduthie

Description

@rjaduthie

Related thread on SKAO Slack:
https://skao.slack.com/archives/C04RSSADLF2/p1755189725297479

Related ticket in SKAO Jira:
https://jira.skatelescope.org/browse/DAAC-731?focusedId=449476&page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#comment-449476

Summary

I'd like to discuss some potential tweaks to the structure of the Helm charts for the Canfar components.

Selfishly, I'm after an update to these charts:

  • cavern
  • posixmapper
  • scienceportal
  • skaha
  • storageui

... but in general any Helm chart provided by OpenCADC can benefit.

These chart have a values structure that specifies the image to use as a single string. This string is defines the registry, the repository and the tag in one. It would be great to be able to patch parts of this specification in our configuration (e.g. just the registry or just the tag) so we can use different versions or registries in different deployments, without having to patch the full registry/repo:tag string.

For example, a good example chart from the wild would be Bitnami's Nginx Helm chart (ref https://artifacthub.io/packages/helm/bitnami/nginx):

Image

Current PosixMapper by comparison:

Image

A potential issue with changing the Helm Charts is that there may be backward incompatibility. This could be mitigated in the Helm templating language using a type check:

{{ $img := .Values.deployment.myApp.image }}
{{- if eq (kindOf $img) "string" }}
  image: {{ .Values.deployment.posixMapper.image }}
{{- else if eq (kindOf $img) "map" }}
  image: {{ printf "%s/%s:%s" $img.registry $img.repository $img.tag }}
{{- else }}
  {{- fail "image must be either a string or a map" }}
{{- end }}

We could even use digests, which is suggested to be a better way than tags - see https://cloud.google.com/kubernetes-engine/docs/concepts/about-container-images

{{- $img := .Values.deployment.myApp.image }}
{{- if eq (typeOf $img) "string" }}
image: {{ $img }}
{{- else if eq (kindOf $img) "map" }}
  {{- $imgName := printf "%s/%s" $img.registry $img.repository }}
  {{- if $img.digest }}
image: {{ printf "%s@%s" $imgName $img.digest }}
  {{- else if $img.tag }}
image: {{ printf "%s:%s" $imgName $img.tag }}
  {{- else }}
    {{- fail "image map must specify either digest or tag" }}
  {{- end }}
{{- else }}
  {{- fail "image must be either a string or a map" }}
{{- end }}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions