From 6b990aea63b88863c62cec6e3907560407caeab6 Mon Sep 17 00:00:00 2001 From: meldafrawi Date: Fri, 20 Mar 2020 00:20:09 +0200 Subject: [PATCH] Add airgap support to chart Signed-off-by: meldafrawi --- chart/questions.yml | 79 +++++++++++++++++++++++++- chart/templates/_helpers.tpl | 5 ++ chart/templates/daemonset-sa.yaml | 4 ++ chart/templates/default-setting.yaml | 1 + chart/templates/deployment-driver.yaml | 8 +++ chart/templates/deployment-ui.yaml | 4 ++ chart/templates/postupgrade-job.yaml | 4 ++ chart/templates/registry-secret.yml | 9 +++ chart/templates/uninstall-job.yaml | 4 ++ chart/values.yaml | 7 +++ 10 files changed, 124 insertions(+), 1 deletion(-) create mode 100644 chart/templates/registry-secret.yml diff --git a/chart/questions.yml b/chart/questions.yml index be7e8b7..4bf0d5d 100644 --- a/chart/questions.yml +++ b/chart/questions.yml @@ -4,6 +4,54 @@ labels: io.rancher.certified: experimental namespace: longhorn-system questions: +- variable: image.longhorn.manager + default: longhornio/longhorn-manager + description: "Specify Longhorn Manager Image Name" + type: string + label: Longhorn Manager Image Name + group: "Longhorn Images Settings" +- variable: image.longhorn.managerTag + default: v0.8.0 + description: "Specify Longhorn Manager Image Tag" + type: string + label: Longhorn Manager Image Tag + group: "Longhorn Images Settings" +- variable: image.longhorn.engine + default: longhornio/longhorn-engine + description: "Specify Longhorn Engine Image Name" + type: string + label: Longhorn Engine Image Name + group: "Longhorn Images Settings" +- variable: image.longhorn.engineTag + default: v0.8.0 + description: "Specify Longhorn Engine Image Tag" + type: string + label: Longhorn Engine Image Tag + group: "Longhorn Images Settings" +- variable: image.longhorn.ui + default: longhornio/longhorn-ui + description: "Specify Longhorn UI Image Name" + type: string + label: Longhorn UI Image Name + group: "Longhorn Images Settings" +- variable: image.longhorn.uiTag + default: v0.8.0 + description: "Specify Longhorn UI Image Tag" + type: string + label: Longhorn UI Image Tag + group: "Longhorn Images Settings" +- variable: image.longhorn.instanceManager + default: longhornio/longhorn-instance-manager + description: "Specify Longhorn Instance Manager Image Name" + type: string + label: Longhorn Instance Manager Image Name + group: "Longhorn Images Settings" +- variable: image.longhorn.instanceManagerTag + default: v1_20200301 + description: "Specify Longhorn Instance Manager Image Tag" + type: string + label: Longhorn Manager Image Tag + group: "Longhorn Images Settings" - variable: csi.attacherImage default: description: "Specify CSI attacher image. Leave blank to autodetect." @@ -22,6 +70,12 @@ questions: type: string label: Longhorn CSI Driver Registrar Image group: "Longhorn CSI Driver Settings" +- variable: csi.resizerImage + default: + description: "Specify CSI Driver Resizer image. Leave blank to autodetect." + type: string + label: Longhorn CSI Driver Resizer Image + group: "Longhorn CSI Driver Settings" - variable: csi.kubeletRootDir default: description: "Specify kubelet root-dir. Leave blank to autodetect." @@ -59,7 +113,6 @@ questions: min: 1 max: 10 label: Default Storage Class Replica Count - - variable: defaultSettings.backupTarget label: Backup Target description: "The target used for backup. Support NFS or S3." @@ -144,6 +197,30 @@ questions: group: "Longhorn Default Settings" type: string default: "" +- variable: defaultSettings.registrySecret + label: Private registry secret + description: "The Kubernetes Secret name" + group: "Longhorn Default Settings" + type: string + default: "" +- variable: privateRegistry.registryUrl + label: Private registry URL + description: "URL of private registry" + group: "Private Registry Settings" + type: string + default: "" +- variable: privateRegistry.registryUser + label: Private registry user + description: "User used to authenticate to private registry" + group: "Private Registry Settings" + type: string + default: "" +- variable: privateRegistry.registryPasswd + label: Private registry password + description: "Password used to authenticate to private registry" + group: "Private Registry Settings" + type: password + default: "" - variable: ingress.enabled default: "false" description: "Expose app using Layer 7 Load Balancer - ingress" diff --git a/chart/templates/_helpers.tpl b/chart/templates/_helpers.tpl index 88d0f45..964b243 100644 --- a/chart/templates/_helpers.tpl +++ b/chart/templates/_helpers.tpl @@ -20,3 +20,8 @@ We truncate at 63 chars because some Kubernetes name fields are limited to this {{- $fullname := (include "longhorn.fullname" .) -}} {{- printf "http://%s-backend:9500" $fullname | trunc 63 | trimSuffix "-" -}} {{- end -}} + + +{{- define "secret" }} +{{- printf "{\"auths\": {\"%s\": {\"auth\": \"%s\"}}}" .Values.privateRegistry.registryUrl (printf "%s:%s" .Values.privateRegistry.registryUser .Values.privateRegistry.registryPasswd | b64enc) | b64enc }} +{{- end }} diff --git a/chart/templates/daemonset-sa.yaml b/chart/templates/daemonset-sa.yaml index 0084a21..47fe44b 100644 --- a/chart/templates/daemonset-sa.yaml +++ b/chart/templates/daemonset-sa.yaml @@ -80,6 +80,10 @@ spec: - name: longhorn-default-setting configMap: name: longhorn-default-setting + {{- if .Values.defaultSettings.registrySecret }} + imagePullSecrets: + - name: {{ .Values.defaultSettings.registrySecret }} + {{- end }} serviceAccountName: longhorn-service-account updateStrategy: rollingUpdate: diff --git a/chart/templates/default-setting.yaml b/chart/templates/default-setting.yaml index 1fc48c4..403049b 100644 --- a/chart/templates/default-setting.yaml +++ b/chart/templates/default-setting.yaml @@ -18,3 +18,4 @@ data: default-longhorn-static-storage-class: {{ .Values.defaultSettings.defaultLonghornStaticStorageClass }} backupstore-poll-interval: {{ .Values.defaultSettings.backupstorePollInterval }} taint-toleration: {{ .Values.defaultSettings.taintToleration }} + registry-secret: {{ .Values.defaultSettings.registrySecret }} diff --git a/chart/templates/deployment-driver.yaml b/chart/templates/deployment-driver.yaml index 47c7467..2855a1d 100644 --- a/chart/templates/deployment-driver.yaml +++ b/chart/templates/deployment-driver.yaml @@ -58,6 +58,10 @@ spec: - name: CSI_DRIVER_REGISTRAR_IMAGE value: {{ .Values.csi.driverRegistrarImage }} {{- end }} + {{- if .Values.csi.resizerImage }} + - name: CSI_RESIZER_IMAGE + value: {{ .Values.csi.resizerImage }} + {{- end }} {{- if .Values.csi.attacherReplicaCount }} - name: CSI_ATTACHER_REPLICA_COUNT value: "{{ .Values.csi.attacherReplicaCount }}" @@ -66,4 +70,8 @@ spec: - name: CSI_PROVISIONER_REPLICA_COUNT value: "{{ .Values.csi.provisionerReplicaCount }}" {{- end }} + {{- if .Values.defaultSettings.registrySecret }} + imagePullSecrets: + - name: {{ .Values.defaultSettings.registrySecret }} + {{- end }} serviceAccountName: longhorn-service-account diff --git a/chart/templates/deployment-ui.yaml b/chart/templates/deployment-ui.yaml index f91327a..33bfc24 100644 --- a/chart/templates/deployment-ui.yaml +++ b/chart/templates/deployment-ui.yaml @@ -24,6 +24,10 @@ spec: env: - name: LONGHORN_MANAGER_IP value: "http://longhorn-backend:9500" + {{- if .Values.defaultSettings.registrySecret }} + imagePullSecrets: + - name: {{ .Values.defaultSettings.registrySecret }} + {{- end }} --- kind: Service apiVersion: v1 diff --git a/chart/templates/postupgrade-job.yaml b/chart/templates/postupgrade-job.yaml index 695962b..5494aed 100644 --- a/chart/templates/postupgrade-job.yaml +++ b/chart/templates/postupgrade-job.yaml @@ -26,4 +26,8 @@ spec: fieldRef: fieldPath: metadata.namespace restartPolicy: OnFailure + {{- if .Values.defaultSettings.registrySecret }} + imagePullSecrets: + - name: {{ .Values.defaultSettings.registrySecret }} + {{- end }} serviceAccountName: longhorn-service-account diff --git a/chart/templates/registry-secret.yml b/chart/templates/registry-secret.yml new file mode 100644 index 0000000..b327c87 --- /dev/null +++ b/chart/templates/registry-secret.yml @@ -0,0 +1,9 @@ +{{- if .Values.defaultSettings.registrySecret }} +apiVersion: v1 +kind: Secret +metadata: + name: {{ .Values.defaultSettings.registrySecret }} +type: kubernetes.io/dockerconfigjson +data: + .dockerconfigjson: {{ template "secret" . }} +{{- end }} diff --git a/chart/templates/uninstall-job.yaml b/chart/templates/uninstall-job.yaml index 0adc2a4..43488d3 100644 --- a/chart/templates/uninstall-job.yaml +++ b/chart/templates/uninstall-job.yaml @@ -27,4 +27,8 @@ spec: fieldRef: fieldPath: metadata.namespace restartPolicy: OnFailure + {{- if .Values.defaultSettings.registrySecret }} + imagePullSecrets: + - name: {{ .Values.defaultSettings.registrySecret }} + {{- end }} serviceAccountName: longhorn-service-account diff --git a/chart/values.yaml b/chart/values.yaml index 17c7746..63b00a3 100644 --- a/chart/values.yaml +++ b/chart/values.yaml @@ -29,6 +29,7 @@ csi: attacherImage: provisionerImage: driverRegistrarImage: + resizerImage: kubeletRootDir: attacherReplicaCount: provisionerReplicaCount: @@ -47,6 +48,12 @@ defaultSettings: defaultLonghornStaticStorageClass: backupstorePollInterval: taintToleration: + registrySecret: + +privateRegistry: + registryUrl: + registryUser: + registryPasswd: resources: {} # We usually recommend not to specify default resources and to leave this as a conscious