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

View File

@ -36,3 +36,20 @@ app.kubernetes.io/managed-by: {{ .Release.Service }}
app.kubernetes.io/instance: {{ .Release.Name }} app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/version: {{ .Chart.AppVersion }} app.kubernetes.io/version: {{ .Chart.AppVersion }}
{{- end -}} {{- 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: ["*"] verbs: ["*"]
- apiGroups: ["coordination.k8s.io"] - apiGroups: ["coordination.k8s.io"]
resources: ["leases"] resources: ["leases"]
verbs: ["get", "watch", "list", "delete", "update", "create"] verbs: ["*"]
- apiGroups: ["longhorn.io"] - apiGroups: ["longhorn.io"]
resources: ["volumes", "volumes/status", "engines", "engines/status", "replicas", "replicas/status", "settings", resources: ["volumes", "volumes/status", "engines", "engines/status", "replicas", "replicas/status", "settings",
"engineimages", "engineimages/status", "nodes", "nodes/status", "instancemanagers", "instancemanagers/status"] "engineimages", "engineimages/status", "nodes", "nodes/status", "instancemanagers", "instancemanagers/status"]
verbs: ["*"] verbs: ["*"]
- apiGroups: ["coordination.k8s.io"]
resources: ["leases"]
verbs: ["*"]

View File

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

View File

@ -16,30 +16,18 @@ spec:
spec: spec:
initContainers: initContainers:
- name: wait-longhorn-manager - name: wait-longhorn-manager
{{- if .Values.privateRegistry.registryUrl }} image: {{ template "registry_url" . }}{{ .Values.image.longhorn.manager.repository }}:{{ .Values.image.longhorn.manager.tag }}
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 }}
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'] 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: containers:
- name: longhorn-driver-deployer - name: longhorn-driver-deployer
{{- if .Values.privateRegistry.registryUrl }} image: {{ template "registry_url" . }}{{ .Values.image.longhorn.manager.repository }}:{{ .Values.image.longhorn.manager.tag }}
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 }}
imagePullPolicy: IfNotPresent imagePullPolicy: IfNotPresent
command: command:
- longhorn-manager - longhorn-manager
- -d - -d
- deploy-driver - deploy-driver
- --manager-image - --manager-image
{{- if .Values.privateRegistry.registryUrl }} - "{{ template "registry_url" . }}{{ .Values.image.longhorn.manager.repository }}:{{ .Values.image.longhorn.manager.tag }}"
- {{ 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 }}
- --manager-url - --manager-url
- http://longhorn-backend:9500/v1 - http://longhorn-backend:9500/v1
env: env:
@ -59,40 +47,21 @@ spec:
- name: KUBELET_ROOT_DIR - name: KUBELET_ROOT_DIR
value: {{ .Values.csi.kubeletRootDir }} value: {{ .Values.csi.kubeletRootDir }}
{{- end }} {{- end }}
{{- if .Values.privateRegistry.registryUrl }} {{- if and .Values.image.csi.attacher.repository .Values.image.csi.attacher.tag }}
{{- if and .Values.csi.attacherImage .Values.csi.attacherImageTag }}
- name: CSI_ATTACHER_IMAGE - 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 }} {{- 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 - 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 }} {{- 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 - 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 }} {{- 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 - 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 }} {{- end }}
{{- if .Values.csi.attacherReplicaCount }} {{- if .Values.csi.attacherReplicaCount }}
- name: CSI_ATTACHER_REPLICA_COUNT - name: CSI_ATTACHER_REPLICA_COUNT

View File

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

View File

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

View File

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

View File

@ -1,16 +1,37 @@
# Default values for longhorn. # Default values for longhorn.
# This is a YAML-formatted file. # This is a YAML-formatted file.
# Declare variables to be passed into your templates. # Declare variables to be passed into your templates.
global:
cattle:
systemDefaultRegistry: ""
image: image:
longhorn: longhorn:
engine: longhornio/longhorn-engine engine:
engineTag: v1.0.2 repository: longhornio/longhorn-engine
manager: longhornio/longhorn-manager tag: v1.0.2
managerTag: v1.0.2 manager:
ui: longhornio/longhorn-ui repository: longhornio/longhorn-manager
uiTag: v1.0.2 tag: v1.0.2
instanceManager: longhornio/longhorn-instance-manager ui:
instanceManagerTag: v1_20200514 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 pullPolicy: IfNotPresent
service: service:
@ -26,14 +47,6 @@ persistence:
defaultClassReplicaCount: 3 defaultClassReplicaCount: 3
csi: 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: ~ kubeletRootDir: ~
attacherReplicaCount: ~ attacherReplicaCount: ~
provisionerReplicaCount: ~ provisionerReplicaCount: ~