paritytech / helm-charts

Parity & Polkadot Helm charts collection
GNU General Public License v3.0
27 stars 22 forks source link

Allow developing on ARM machines with image digest #350

Closed antonioarenzanapulido closed 2 months ago

antonioarenzanapulido commented 2 months ago

Hello!

I found that if you have an ARM machine like a Mac M series you are not able to develop/test with this Helm chart.

The main reason is polkadot/node image not being arm compatible, you get a ErrImagePull. Failed to pull image "parity/polkadot:latest": rpc error: code = Unknown desc = no matching manifest for linux/arm64/v8 in the manifest list entries

To avoid this you can use the digest of the manifest: Ex: sha256:80be82c79349c5f40ddfc81f0ed43cf61cefaf273a22eb2e52498a2e215ea5de

### Tasks
- [ ] Modify `app.kubernetes.io/version` label at `_helpers.tpl`
- [ ] Add `image.digest` to values.yml
- [ ] Modify `image` key for those based on parity/polkadot in `statefulset.yaml`
- [ ] README.md with helm-docs

As pushes to the repo are not open here is the code:

values.yaml

image:
  # -- Image repository
  repository: parity/polkadot
  # -- Image tag
  tag: latest
  # -- Image digest, if set invalidates tag value
  digest: ""
  # -- Image pull policy
  pullPolicy: Always
  # -- Adds `-x` shell option to container.
  # Note: passwords and keys used in container may appear in logs
  debug: false

statefulset.yaml Lines 294, 318, 355, 388, 475

image: {{ .Values.image.repository }}{{ empty .Values.image.digest | ternary (printf ":%s" .Values.image.tag) (printf "@%s" .Values.image.digest) }}

_helpers.tpl

{{- if empty .Values.image.digest }}
app.kubernetes.io/version: {{ .Values.image.tag | quote }}
{{- else }}
app.kubernetes.io/version: {{ .Values.image.digest | substr 7 19 | quote }}
{{- end }}

You need to truncate the digest because the max length of K8's labels is 63 chars while SHA256 is 64 chars, this 12 characters can also act as ID for the image.


Thank you in advance

BulatSaif commented 2 months ago

@antonioarenzanapulido Thank you for reporting this bug. Your suggestion to use digest is interesting; however, it is not the conventional format used in most Helm charts, as outlined in the Renovatebot Documentation.

To address this, digest can be added as a postfix to the tag, like this: tag: latest@sha256:80be82c79349c5f40ddfc81f0ed43cf61cefaf273a22eb2e52498a2e215ea5de.

I have also fixed the labels format in PR #352 to allow setting digest or a long tag name.