update helm charts for helm-dashboard (#490)

* update helm charts for helm-dashboard

1. fix `imagePullSecrets` bug in deployment.yaml
2. add `global` config
3. optimize image field with global registry config

* doc: update doc for charts
This commit is contained in:
warjiang
2023-11-07 19:07:25 +08:00
committed by GitHub
parent 4c84b795a0
commit d78e0c5866
6 changed files with 137 additions and 33 deletions

View File

@@ -51,9 +51,12 @@ For instance, you can place authentication proxy in front of Helm Dashboard, lik
The following table lists the configurable parameters of the chart and their default values. The following table lists the configurable parameters of the chart and their default values.
| Parameter | Description | Default | | Parameter | Description | Default |
| ------------------------------------ | ---------------------------------------------------------------------------------------------- | ------------------------------------ | |---------------------------------------|------------------------------------------------------------------------------------------------|----------------------------------|
| `image.repository` | Image registry/name | `docker.io/komodorio/helm-dashboard` | | `global.imageRegistry` | Registry for all images, useful for private registry | `""` |
| `global.imagePullSecrets` | Specify Docker-registry secret names as an array | `[]` |
| `image.repository` | Image registry/name | `komodorio/helm-dashboard` |
| `image.tag` | Image tag | | | `image.tag` | Image tag | |
| `image.imagePullSecrets` | Specify Docker-registry secret names as an array | `[]` |
| `image.pullPolicy` | Image pull policy | `IfNotPresent` | | `image.pullPolicy` | Image pull policy | `IfNotPresent` |
| `replicaCount` | Number of dashboard Pods to run | `1` | | `replicaCount` | Number of dashboard Pods to run | `1` |
| `dashboard.allowWriteActions` | Enables write actions. Allow modifying, deleting and creating charts and kubernetes resources. | `true` | | `dashboard.allowWriteActions` | Enables write actions. Allow modifying, deleting and creating charts and kubernetes resources. | `true` |
@@ -72,10 +75,13 @@ The following table lists the configurable parameters of the chart and their def
| `dashboard.persistence.accessModes` | Persistent Volume access modes | `["ReadWriteOnce"]` | | `dashboard.persistence.accessModes` | Persistent Volume access modes | `["ReadWriteOnce"]` |
| `dashboard.persistence.storageClass` | Persistent Volume storage class | `""` | | `dashboard.persistence.storageClass` | Persistent Volume storage class | `""` |
| `dashboard.persistence.size` | Persistent Volume size | `100M` | | `dashboard.persistence.size` | Persistent Volume size | `100M` |
| `dashboard.persistence.hostPath` | Set path in case you want to use local host path volumes (not recommended in production) | `""` | `dashboard.persistence.hostPath` | Set path in case you want to use local host path volumes (not recommended in production) | `""` |
| `updateStrategy.type` | Set up update strategy for helm-dashboard installation. | `RollingUpdate` | | `updateStrategy.type` | Set up update strategy for helm-dashboard installation. | `RollingUpdate` |
| `extraArgs` | Set the arguments to be supplied to the helm-dashboard binary | `[--no-browser, --bind=0.0.0.0]` | `extraArgs` | Set the arguments to be supplied to the helm-dashboard binary | `[--no-browser, --bind=0.0.0.0]` |
| `testImage.repository` | Test image registry/name | `busybox` |
| `testImage.tag` | Test image tag | `lastest` |
| `testImage.imagePullSecrets` | Specify Docker-registry secret names as an array | `[]` |
| `testImage.pullPolicy` | Test image pull policy | `IfNotPresent` |
Specify each parameter using the `--set key=value[,key=value]` argument to `helm install`. Specify each parameter using the `--set key=value[,key=value]` argument to `helm install`.
```bash ```bash

View File

@@ -0,0 +1,51 @@
{{/*
Return the proper image name
{{ include "common.images.image" ( dict "imageRoot" .Values.path.to.the.image "global" .Values.global ) }}
*/}}
{{- define "common.images.image" -}}
{{- $registryName := .imageRoot.registry -}}
{{- $repositoryName := .imageRoot.repository -}}
{{- $separator := ":" -}}
{{- $termination := .imageRoot.tag | toString -}}
{{- if .global }}
{{- if .global.imageRegistry }}
{{- $registryName = .global.imageRegistry -}}
{{- end -}}
{{- end -}}
{{- if .imageRoot.digest }}
{{- $separator = "@" -}}
{{- $termination = .imageRoot.digest | toString -}}
{{- end -}}
{{- if $registryName }}
{{- printf "%s/%s%s%s" $registryName $repositoryName $separator $termination -}}
{{- else -}}
{{- printf "%s%s%s" $repositoryName $separator $termination -}}
{{- end -}}
{{- end -}}
{{/*
Return the proper Docker Image Registry Secret Names (deprecated: use common.images.renderPullSecrets instead)
{{ include "common.images.pullSecrets" ( dict "images" (list .Values.path.to.the.image1, .Values.path.to.the.image2) "global" .Values.global) }}
*/}}
{{- define "common.images.pullSecrets" -}}
{{- $pullSecrets := list }}
{{- if .global }}
{{- range .global.imagePullSecrets -}}
{{- $pullSecrets = append $pullSecrets . -}}
{{- end -}}
{{- end -}}
{{- range .images -}}
{{- range .pullSecrets -}}
{{- $pullSecrets = append $pullSecrets . -}}
{{- end -}}
{{- end -}}
{{- if (not (empty $pullSecrets)) }}
imagePullSecrets:
{{- range $pullSecrets }}
- name: {{ . }}
{{- end }}
{{- end }}
{{- end -}}

View File

@@ -60,3 +60,31 @@ Create the name of the service account to use
{{- default "default" .Values.serviceAccount.name }} {{- default "default" .Values.serviceAccount.name }}
{{- end }} {{- end }}
{{- end }} {{- end }}
{{/*
Return the proper image Registry Secret Names
*/}}
{{- define "helm-dashboard.imagePullSecrets" -}}
{{ include "common.images.pullSecrets" (dict "images" (list .Values.image) "global" .Values.global) }}
{{- end -}}
{{/*
Return the proper image name
*/}}
{{- define "helm-dashboard.image" -}}
{{- $image := .Values.image -}}
{{- $tag := .Chart.AppVersion -}}
{{- if $image.tag -}}
{{- $tag = $image.tag -}}
{{- end -}}
{{- $_ := set $image "tag" $tag -}}
{{ include "common.images.image" (dict "imageRoot" $_ "global" .Values.global) }}
{{- end -}}
{{/*
Return the proper image name
*/}}
{{- define "test.image" -}}
{{ include "common.images.image" (dict "imageRoot" .Values.testImage "global" .Values.global) }}
{{- end -}}

View File

@@ -21,10 +21,7 @@ spec:
labels: labels:
{{- include "helm-dashboard.selectorLabels" . | nindent 8 }} {{- include "helm-dashboard.selectorLabels" . | nindent 8 }}
spec: spec:
{{- with .Values.imagePullSecrets }} {{- include "helm-dashboard.imagePullSecrets" . | nindent 6 }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
serviceAccountName: {{ include "helm-dashboard.serviceAccountName" . }} serviceAccountName: {{ include "helm-dashboard.serviceAccountName" . }}
securityContext: securityContext:
{{- toYaml .Values.podSecurityContext | nindent 8 }} {{- toYaml .Values.podSecurityContext | nindent 8 }}
@@ -38,7 +35,7 @@ spec:
{{- end }} {{- end }}
securityContext: securityContext:
{{- toYaml .Values.securityContext | nindent 12 }} {{- toYaml .Values.securityContext | nindent 12 }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}" image: "{{ include "helm-dashboard.image" . }}"
imagePullPolicy: {{ .Values.image.pullPolicy }} imagePullPolicy: {{ .Values.image.pullPolicy }}
env: env:
- name: HELM_CACHE_HOME - name: HELM_CACHE_HOME

View File

@@ -7,9 +7,10 @@ metadata:
annotations: annotations:
"helm.sh/hook": test "helm.sh/hook": test
spec: spec:
{{- include "helm-dashboard.imagePullSecrets" . | nindent 2 }}
containers: containers:
- name: wget - name: wget
image: busybox image: {{ include "test.image" . }}
command: ['wget'] command: ['wget']
args: ['--timeout=5', '{{ include "helm-dashboard.fullname" . }}:{{ .Values.service.port }}'] args: ['--timeout=5', '{{ include "helm-dashboard.fullname" . }}:{{ .Values.service.port }}']
restartPolicy: Never restartPolicy: Never

View File

@@ -3,13 +3,22 @@ replicaCount: 1
# Flag for setting environment to debug mode # Flag for setting environment to debug mode
debug: false debug: false
global:
## @param global.imageRegistry Global Docker image registry
imageRegistry: ""
## Optionally specify an array of imagePullSecrets.
## Example:
## imagePullSecrets:
## - myRegistryKeySecretName
imagePullSecrets: []
image: image:
repository: komodorio/helm-dashboard repository: komodorio/helm-dashboard
pullPolicy: IfNotPresent pullPolicy: IfNotPresent
# Overrides the image tag whose default is the chart appVersion. # Overrides the image tag whose default is the chart appVersion.
tag: "" tag: ""
imagePullSecrets: []
imagePullSecrets: []
nameOverride: "" nameOverride: ""
fullnameOverride: "" fullnameOverride: ""
@@ -119,3 +128,15 @@ tolerations: []
affinity: {} affinity: {}
testImage:
repository: busybox
tag: latest
pullPolicy: IfNotPresent
# Overrides the image tag whose default is the chart appVersion.
# tag: ""
## Optionally specify an array of imagePullSecrets.
## Example:
## imagePullSecrets:
## - myRegistryKeySecretName
imagePullSecrets: []