chart: Remove some redundancy for the chart

1. Remove the redundancy rule in clusterrole.yaml
2. Simplify the chart private registry setting.

Longhorn #1818

Signed-off-by: Shuo Wu <shuo@rancher.com>
This commit is contained in:
Shuo Wu 2020-09-29 17:16:09 +08:00 committed by Sheng Yang
parent 3918638dda
commit 9cbb93d10c
9 changed files with 98 additions and 130 deletions

View File

@ -10,97 +10,97 @@ questions:
show_subquestion_if: false
group: "Longhorn Images"
subquestions:
- variable: image.longhorn.manager
- variable: image.longhorn.manager.repository
default: longhornio/longhorn-manager
description: "Specify Longhorn Manager Image Name"
description: "Specify Longhorn Manager Image Repository"
type: string
label: Longhorn Manager Image Name
label: Longhorn Manager Image Repository
group: "Longhorn Images Settings"
- variable: image.longhorn.managerTag
- variable: image.longhorn.manager.tag
default: v1.0.2
description: "Specify Longhorn Manager Image Tag"
type: string
label: Longhorn Manager Image Tag
group: "Longhorn Images Settings"
- variable: image.longhorn.engine
- variable: image.longhorn.engine.repository
default: longhornio/longhorn-engine
description: "Specify Longhorn Engine Image Name"
description: "Specify Longhorn Engine Image Repository"
type: string
label: Longhorn Engine Image Name
label: Longhorn Engine Image Repository
group: "Longhorn Images Settings"
- variable: image.longhorn.engineTag
- variable: image.longhorn.engine.tag
default: v1.0.2
description: "Specify Longhorn Engine Image Tag"
type: string
label: Longhorn Engine Image Tag
group: "Longhorn Images Settings"
- variable: image.longhorn.ui
- variable: image.longhorn.ui.repository
default: longhornio/longhorn-ui
description: "Specify Longhorn UI Image Name"
description: "Specify Longhorn UI Image Repository"
type: string
label: Longhorn UI Image Name
label: Longhorn UI Image Repository
group: "Longhorn Images Settings"
- variable: image.longhorn.uiTag
- variable: image.longhorn.ui.tag
default: v1.0.2
description: "Specify Longhorn UI Image Tag"
type: string
label: Longhorn UI Image Tag
group: "Longhorn Images Settings"
- variable: image.longhorn.instanceManager
- variable: image.longhorn.instanceManager.repository
default: longhornio/longhorn-instance-manager
description: "Specify Longhorn Instance Manager Image Name"
description: "Specify Longhorn Instance Manager Image Repository"
type: string
label: Longhorn Instance Manager Image Name
label: Longhorn Instance Manager Image Repository
group: "Longhorn Images Settings"
- variable: image.longhorn.instanceManagerTag
- variable: image.longhorn.instanceManager.tag
default: v1_20200514
description: "Specify Longhorn Instance Manager Image Tag"
type: string
label: Longhorn Instance Manager Image Tag
group: "Longhorn Images Settings"
- variable: csi.attacherImage
- variable: image.csi.attacher.repository
default: longhornio/csi-attacher
description: "Specify CSI attacher image. Leave blank to autodetect."
description: "Specify CSI attacher image repository. Leave blank to autodetect."
type: string
label: Longhorn CSI Attacher Image
label: Longhorn CSI Attacher Image Repository
group: "Longhorn CSI Driver Images"
- variable: csi.attacherImageTag
- variable: image.csi.attacher.tag
default: v2.0.0
description: "Specify CSI attacher image tag. Leave blank to autodetect."
type: string
label: Longhorn CSI Attacher Image Tag
group: "Longhorn CSI Driver Images"
- variable: csi.provisionerImage
- variable: image.csi.provisioner.repository
default: longhornio/csi-provisioner
description: "Specify CSI provisioner image. Leave blank to autodetect."
description: "Specify CSI provisioner image repository. Leave blank to autodetect."
type: string
label: Longhorn CSI Provisioner Image
label: Longhorn CSI Provisioner Image Repository
group: "Longhorn CSI Driver Images"
- variable: csi.provisionerImageTag
- variable: image.csi.provisioner.tag
default: v1.4.0
description: "Specify CSI provisioner image tag. Leave blank to autodetect."
type: string
label: Longhorn CSI Provisioner Image Tag
group: "Longhorn CSI Driver Images"
- variable: csi.nodeDriverRegistrarImage
- variable: image.csi.nodeDriverRegistrar.repository
default: longhornio/csi-node-driver-registrar
description: "Specify CSI Node Driver Registrar image. Leave blank to autodetect."
description: "Specify CSI Node Driver Registrar image repository. Leave blank to autodetect."
type: string
label: Longhorn CSI Node Driver Registrar Image
label: Longhorn CSI Node Driver Registrar Image Repository
group: "Longhorn CSI Driver Images"
- variable: csi.nodeDriverRegistrarImageTag
- variable: image.csi.nodeDriverRegistrar.tag
default: v1.2.0
description: "Specify CSI Node Driver Registrar image tag. Leave blank to autodetect."
type: string
label: Longhorn CSI Node Driver Registrar Image Tag
group: "Longhorn CSI Driver Images"
- variable: csi.resizerImage
- variable: image.csi.resizer.repository
default: longhornio/csi-resizer
description: "Specify CSI Driver Resizer image. Leave blank to autodetect."
description: "Specify CSI Driver Resizer image repository. Leave blank to autodetect."
type: string
label: Longhorn CSI Driver Resizer Image
label: Longhorn CSI Driver Resizer Image Repository
group: "Longhorn CSI Driver Images"
- variable: csi.resizerImageTag
- variable: image.csi.resizer.tag
default: v0.3.0
description: "Specify CSI Driver Resizer image tag. Leave blank to autodetect."
type: string
@ -108,7 +108,7 @@ questions:
group: "Longhorn CSI Driver Images"
- variable: privateRegistry.registryUrl
label: Private registry URL
description: "URL of private registry"
description: "URL of private registry. Leave blank to apply system default registry."
group: "Private Registry Settings"
type: string
default: ""

View File

@ -36,3 +36,20 @@ app.kubernetes.io/managed-by: {{ .Release.Service }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/version: {{ .Chart.AppVersion }}
{{- end -}}
{{- define "system_default_registry" -}}
{{- if .Values.global.cattle.systemDefaultRegistry -}}
{{- printf "%s/" .Values.global.cattle.systemDefaultRegistry -}}
{{- else -}}
{{- "" -}}
{{- end -}}
{{- end -}}
{{- define "registry_url" -}}
{{- if .Values.privateRegistry.registryUrl -}}
{{- printf "%s/" .Values.privateRegistry.registryUrl -}}
{{- else -}}
{{ include "system_default_registry" . }}
{{- end -}}
{{- end -}}

View File

@ -30,11 +30,8 @@ rules:
verbs: ["*"]
- apiGroups: ["coordination.k8s.io"]
resources: ["leases"]
verbs: ["get", "watch", "list", "delete", "update", "create"]
verbs: ["*"]
- apiGroups: ["longhorn.io"]
resources: ["volumes", "volumes/status", "engines", "engines/status", "replicas", "replicas/status", "settings",
"engineimages", "engineimages/status", "nodes", "nodes/status", "instancemanagers", "instancemanagers/status"]
verbs: ["*"]
- apiGroups: ["coordination.k8s.io"]
resources: ["leases"]
verbs: ["*"]

View File

@ -16,11 +16,7 @@ spec:
spec:
containers:
- name: longhorn-manager
{{- if .Values.privateRegistry.registryUrl }}
image: "{{ .Values.privateRegistry.registryUrl }}/{{ .Values.image.longhorn.manager }}:{{ .Values.image.longhorn.managerTag }}"
{{- else }}
image: "{{ .Values.image.longhorn.manager }}:{{ .Values.image.longhorn.managerTag }}"
{{- end }}
image: {{ template "registry_url" . }}{{ .Values.image.longhorn.manager.repository }}:{{ .Values.image.longhorn.manager.tag }}
imagePullPolicy: IfNotPresent
securityContext:
privileged: true
@ -29,23 +25,11 @@ spec:
- -d
- daemon
- --engine-image
{{- if .Values.privateRegistry.registryUrl }}
- "{{ .Values.privateRegistry.registryUrl }}/{{ .Values.image.longhorn.engine }}:{{ .Values.image.longhorn.engineTag }}"
{{- else }}
- "{{ .Values.image.longhorn.engine }}:{{ .Values.image.longhorn.engineTag }}"
{{- end }}
- "{{ template "registry_url" . }}{{ .Values.image.longhorn.engine.repository }}:{{ .Values.image.longhorn.engine.tag }}"
- --instance-manager-image
{{- if .Values.privateRegistry.registryUrl }}
- "{{ .Values.privateRegistry.registryUrl }}/{{ .Values.image.longhorn.instanceManager }}:{{ .Values.image.longhorn.instanceManagerTag }}"
{{- else }}
- "{{ .Values.image.longhorn.instanceManager }}:{{ .Values.image.longhorn.instanceManagerTag }}"
{{- end }}
- "{{ template "registry_url" . }}{{ .Values.image.longhorn.instanceManager.repository }}:{{ .Values.image.longhorn.instanceManager.tag }}"
- --manager-image
{{- if .Values.privateRegistry.registryUrl }}
- "{{ .Values.privateRegistry.registryUrl }}/{{ .Values.image.longhorn.manager }}:{{ .Values.image.longhorn.managerTag }}"
{{- else }}
- "{{ .Values.image.longhorn.manager }}:{{ .Values.image.longhorn.managerTag }}"
{{- end }}
- "{{ template "registry_url" . }}{{ .Values.image.longhorn.manager.repository }}:{{ .Values.image.longhorn.manager.tag }}"
- --service-account
- longhorn-service-account
ports:

View File

@ -16,30 +16,18 @@ spec:
spec:
initContainers:
- name: wait-longhorn-manager
{{- if .Values.privateRegistry.registryUrl }}
image: {{ printf "%s/%s:%s" .Values.privateRegistry.registryUrl .Values.image.longhorn.manager .Values.image.longhorn.managerTag | quote }}
{{- else }}
image: {{ printf "%s:%s" .Values.image.longhorn.manager .Values.image.longhorn.managerTag | quote }}
{{- end }}
image: {{ template "registry_url" . }}{{ .Values.image.longhorn.manager.repository }}:{{ .Values.image.longhorn.manager.tag }}
command: ['sh', '-c', 'while [ $(curl -m 1 -s -o /dev/null -w "%{http_code}" http://longhorn-backend:9500/v1) != "200" ]; do echo waiting; sleep 2; done']
containers:
- name: longhorn-driver-deployer
{{- if .Values.privateRegistry.registryUrl }}
image: {{ printf "%s/%s:%s" .Values.privateRegistry.registryUrl .Values.image.longhorn.manager .Values.image.longhorn.managerTag | quote }}
{{- else }}
image: {{ printf "%s:%s" .Values.image.longhorn.manager .Values.image.longhorn.managerTag | quote }}
{{- end }}
image: {{ template "registry_url" . }}{{ .Values.image.longhorn.manager.repository }}:{{ .Values.image.longhorn.manager.tag }}
imagePullPolicy: IfNotPresent
command:
- longhorn-manager
- -d
- deploy-driver
- --manager-image
{{- if .Values.privateRegistry.registryUrl }}
- {{ printf "%s/%s:%s" .Values.privateRegistry.registryUrl .Values.image.longhorn.manager .Values.image.longhorn.managerTag | quote }}
{{- else }}
- {{ printf "%s:%s" .Values.image.longhorn.manager .Values.image.longhorn.managerTag | quote }}
{{- end }}
- "{{ template "registry_url" . }}{{ .Values.image.longhorn.manager.repository }}:{{ .Values.image.longhorn.manager.tag }}"
- --manager-url
- http://longhorn-backend:9500/v1
env:
@ -59,41 +47,22 @@ spec:
- name: KUBELET_ROOT_DIR
value: {{ .Values.csi.kubeletRootDir }}
{{- end }}
{{- if .Values.privateRegistry.registryUrl }}
{{- if and .Values.csi.attacherImage .Values.csi.attacherImageTag }}
{{- if and .Values.image.csi.attacher.repository .Values.image.csi.attacher.tag }}
- name: CSI_ATTACHER_IMAGE
value: {{ printf "%s/%s:%s" .Values.privateRegistry.registryUrl .Values.csi.attacherImage .Values.csi.attacherImageTag | quote }}
value: "{{ template "registry_url" . }}{{ .Values.image.csi.attacher.repository }}:{{ .Values.image.csi.attacher.tag }}"
{{- end }}
{{- if and .Values.csi.provisionerImage .Values.csi.provisionerImageTag }}
{{- if and .Values.image.csi.provisioner.repository .Values.image.csi.provisioner.tag }}
- name: CSI_PROVISIONER_IMAGE
value: {{ printf "%s/%s:%s" .Values.privateRegistry.registryUrl .Values.csi.provisionerImage .Values.csi.provisionerImageTag | quote }}
value: "{{ template "registry_url" . }}{{ .Values.image.csi.provisioner.repository }}:{{ .Values.image.csi.provisioner.tag }}"
{{- end }}
{{- if and .Values.csi.nodeDriverRegistrarImage .Values.csi.nodeDriverRegistrarImageTag }}
{{- if and .Values.image.csi.nodeDriverRegistrar.repository .Values.image.csi.nodeDriverRegistrar.tag }}
- name: CSI_NODE_DRIVER_REGISTRAR_IMAGE
value: {{ printf "%s/%s:%s" .Values.privateRegistry.registryUrl .Values.csi.nodeDriverRegistrarImage .Values.csi.nodeDriverRegistrarImageTag | quote }}
value: "{{ template "registry_url" . }}{{ .Values.image.csi.nodeDriverRegistrar.repository }}:{{ .Values.image.csi.nodeDriverRegistrar.tag }}"
{{- end }}
{{- if and .Values.csi.resizerImage .Values.csi.resizerImageTag }}
{{- if and .Values.image.csi.resizer.repository .Values.image.csi.resizer.tag }}
- name: CSI_RESIZER_IMAGE
value: {{ printf "%s/%s:%s" .Values.privateRegistry.registryUrl .Values.csi.resizerImage .Values.csi.resizerImageTag | quote }}
value: "{{ template "registry_url" . }}{{ .Values.image.csi.resizer.repository }}:{{ .Values.image.csi.resizer.tag }}"
{{- end }}
{{- else }}
{{- if and .Values.csi.attacherImage .Values.csi.attacherImageTag }}
- name: CSI_ATTACHER_IMAGE
value: {{ printf "%s:%s" .Values.csi.attacherImage .Values.csi.attacherImageTag | quote }}
{{- end }}
{{- if and .Values.csi.provisionerImage .Values.csi.provisionerImageTag }}
- name: CSI_PROVISIONER_IMAGE
value: {{ printf "%s:%s" .Values.csi.provisionerImage .Values.csi.provisionerImageTag | quote }}
{{- end }}
{{- if and .Values.csi.nodeDriverRegistrarImage .Values.csi.nodeDriverRegistrarImageTag }}
- name: CSI_NODE_DRIVER_REGISTRAR_IMAGE
value: {{ printf "%s:%s" .Values.csi.nodeDriverRegistrarImage .Values.csi.nodeDriverRegistrarImageTag | quote }}
{{- end }}
{{- if and .Values.csi.resizerImage .Values.csi.resizerImageTag }}
- name: CSI_RESIZER_IMAGE
value: {{ printf "%s:%s" .Values.csi.resizerImage .Values.csi.resizerImageTag | quote }}
{{- end }}
{{- end }}
{{- if .Values.csi.attacherReplicaCount }}
- name: CSI_ATTACHER_REPLICA_COUNT
value: {{ .Values.csi.attacherReplicaCount | quote }}

View File

@ -17,11 +17,7 @@ spec:
spec:
containers:
- name: longhorn-ui
{{- if .Values.privateRegistry.registryUrl }}
image: "{{ .Values.privateRegistry.registryUrl }}/{{ .Values.image.longhorn.ui }}:{{ .Values.image.longhorn.uiTag }}"
{{- else }}
image: "{{ .Values.image.longhorn.ui }}:{{ .Values.image.longhorn.uiTag }}"
{{- end }}
image: {{ template "registry_url" . }}{{ .Values.image.longhorn.ui.repository }}:{{ .Values.image.longhorn.ui.tag }}
imagePullPolicy: IfNotPresent
securityContext:
runAsUser: 0

View File

@ -17,11 +17,7 @@ spec:
spec:
containers:
- name: longhorn-post-upgrade
{{- if .Values.privateRegistry.registryUrl }}
image: "{{ .Values.privateRegistry.registryUrl }}/{{ .Values.image.longhorn.manager }}:{{ .Values.image.longhorn.managerTag }}"
{{- else }}
image: "{{ .Values.image.longhorn.manager }}:{{ .Values.image.longhorn.managerTag }}"
{{- end }}
image: {{ template "registry_url" . }}{{ .Values.image.longhorn.manager.repository }}:{{ .Values.image.longhorn.manager.tag }}
imagePullPolicy: Always
command:
- longhorn-manager

View File

@ -17,11 +17,7 @@ spec:
spec:
containers:
- name: longhorn-uninstall
{{- if .Values.privateRegistry.registryUrl }}
image: "{{ .Values.privateRegistry.registryUrl }}/{{ .Values.image.longhorn.manager }}:{{ .Values.image.longhorn.managerTag }}"
{{- else }}
image: "{{ .Values.image.longhorn.manager }}:{{ .Values.image.longhorn.managerTag }}"
{{- end }}
image: {{ template "registry_url" . }}{{ .Values.image.longhorn.manager.repository }}:{{ .Values.image.longhorn.manager.tag }}
imagePullPolicy: Always
command:
- longhorn-manager

View File

@ -1,16 +1,37 @@
# Default values for longhorn.
# This is a YAML-formatted file.
# Declare variables to be passed into your templates.
global:
cattle:
systemDefaultRegistry: ""
image:
longhorn:
engine: longhornio/longhorn-engine
engineTag: v1.0.2
manager: longhornio/longhorn-manager
managerTag: v1.0.2
ui: longhornio/longhorn-ui
uiTag: v1.0.2
instanceManager: longhornio/longhorn-instance-manager
instanceManagerTag: v1_20200514
engine:
repository: longhornio/longhorn-engine
tag: v1.0.2
manager:
repository: longhornio/longhorn-manager
tag: v1.0.2
ui:
repository: longhornio/longhorn-ui
tag: v1.0.2
instanceManager:
repository: longhornio/longhorn-instance-manager
tag: v1_20200514
csi:
attacher:
repository: longhornio/csi-attacher
tag: v2.0.0
provisioner:
repository: longhornio/csi-provisioner
tag: v1.4.0
nodeDriverRegistrar:
repository: longhornio/csi-node-driver-registrar
tag: v1.2.0
resizer:
repository: longhornio/csi-resizer
tag: v0.3.0
pullPolicy: IfNotPresent
service:
@ -26,14 +47,6 @@ persistence:
defaultClassReplicaCount: 3
csi:
attacherImage: longhornio/csi-attacher
attacherImageTag: v2.0.0
provisionerImage: longhornio/csi-provisioner
provisionerImageTag: v1.4.0
nodeDriverRegistrarImage: longhornio/csi-node-driver-registrar
nodeDriverRegistrarImageTag: v1.2.0
resizerImage: longhornio/csi-resizer
resizerImageTag: v0.3.0
kubeletRootDir: ~
attacherReplicaCount: ~
provisionerReplicaCount: ~