From 049a4ea9749d1493e053d7795daa289b268d5193 Mon Sep 17 00:00:00 2001 From: wilson1999112 <99640674+wilson1999112@users.noreply.github.com> Date: Fri, 18 Mar 2022 13:50:45 +0800 Subject: [PATCH] Allow using an existing private registry secret (#3673) Co-authored-by: David Ko Co-authored-by: JenTing Hsiao --- chart/questions.yaml | 32 +++++++++++++++++----------- chart/templates/registry-secret.yaml | 2 ++ chart/values.yaml | 1 + 3 files changed, 22 insertions(+), 13 deletions(-) diff --git a/chart/questions.yaml b/chart/questions.yaml index dbd0b8c..fe72a61 100644 --- a/chart/questions.yaml +++ b/chart/questions.yaml @@ -148,24 +148,30 @@ questions: 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: privateRegistry.registrySecret label: Private registry secret name - description: "Longhorn will automatically generate a Kubernetes secret with this name and use it to pull images from your private registry." + description: "If create a new private registry secret is true, create a Kubernetes secret with this name; else use the existing secret of this name. Use it to pull images from your private registry." group: "Private Registry Settings" type: string default: "" +- variable: privateRegistry.createSecret + default: "true" + description: "Create a new private registry secret" + type: boolean + group: "Private Registry Settings" + label: Create Secret for Private Registry Settings + show_subquestion_if: true + subquestions: + - variable: privateRegistry.registryUser + label: Private registry user + description: "User used to authenticate to private registry." + type: string + default: "" + - variable: privateRegistry.registryPasswd + label: Private registry password + description: "Password used to authenticate to private registry." + type: password + default: "" - variable: longhorn.default_setting default: "false" description: "Customize the default settings before installing Longhorn for the first time. This option will only work if the cluster hasn't installed Longhorn." diff --git a/chart/templates/registry-secret.yaml b/chart/templates/registry-secret.yaml index 1c7565f..3c6b1dc 100644 --- a/chart/templates/registry-secret.yaml +++ b/chart/templates/registry-secret.yaml @@ -1,3 +1,4 @@ +{{- if .Values.privateRegistry.createSecret }} {{- if .Values.privateRegistry.registrySecret }} apiVersion: v1 kind: Secret @@ -8,4 +9,5 @@ metadata: type: kubernetes.io/dockerconfigjson data: .dockerconfigjson: {{ template "secret" . }} +{{- end }} {{- end }} \ No newline at end of file diff --git a/chart/values.yaml b/chart/values.yaml index a062dad..29a3437 100644 --- a/chart/values.yaml +++ b/chart/values.yaml @@ -114,6 +114,7 @@ defaultSettings: guaranteedEngineManagerCPU: ~ guaranteedReplicaManagerCPU: ~ privateRegistry: + createSecret: ~ registryUrl: ~ registryUser: ~ registryPasswd: ~