Skip to content

Instantly share code, notes, and snippets.

@egeneralov
Created February 14, 2021 18:52
Show Gist options
  • Save egeneralov/e1a23b335e62c623421435cfeaf290e9 to your computer and use it in GitHub Desktop.
Save egeneralov/e1a23b335e62c623421435cfeaf290e9 to your computer and use it in GitHub Desktop.

Registry credentials in helm charts

values.yaml

Add:

imageCredentials:
  registry: quay.io
  username: someone
  password: sillyness

deployment.yaml

replace

imagePullSecrets:
{{- toYaml . | nindent 8 }}

with

imagePullSecrets:
- name: {{ include "REPLACE_ME.fullname" . }}

ips.yaml

create new file at templates/

{{- define "imagePullSecret" }}
{{- with .Values.imageCredentials }}
{{- printf "{\"auths\":{\"%s\":{\"username\":\"%s\",\"password\":\"%s\",\"auth\":\"%s\"}}}" .registry .username .password (printf "%s:%s" .username .password | b64enc) | b64enc }}
{{- end }}
{{- end }}
apiVersion: v1
kind: Secret
metadata:
  name: {{ include "REPLACE_ME.fullname" . }}
type: kubernetes.io/dockerconfigjson
data:
  .dockerconfigjson: {{ template "imagePullSecret" . }}
@egeneralov
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment