From 14f319a1b4d113dc6d20c9f2850e1b5a9292febe Mon Sep 17 00:00:00 2001 From: Lakshmi Narasimhan Date: Fri, 22 Dec 2023 19:20:42 +0530 Subject: [PATCH] Helm registry update. --- addons/sb-registry/enable | 19 +++++-------------- addons/sb-registry/values.yaml | 20 ++++++++++++++++++++ 2 files changed, 25 insertions(+), 14 deletions(-) create mode 100644 addons/sb-registry/values.yaml diff --git a/addons/sb-registry/enable b/addons/sb-registry/enable index 563c7d5..b989b4c 100755 --- a/addons/sb-registry/enable +++ b/addons/sb-registry/enable @@ -2,6 +2,7 @@ import os import subprocess +from string import Template import click @@ -36,20 +37,10 @@ def main(cluster_name, tld, password): subprocess.run([HELM, "repo", "add", "docker-registry", "https://helm.twun.io/"]) subprocess.run([HELM, "repo", "update"]) - args = [] - args.extend(["--set", "persistence.enabled=true"]) - args.extend(["--set", "persistence.size=20Gi"]) - args.extend(["--set", "ingress.enabled=true"]) - args.extend(["--set", f"ingress.hosts[0]=registry.{cluster_name}.{tld}"]) - args.extend(["--set", f"ingress.tls[0].hosts[0]=registry.{cluster_name}.{tld}"]) - args.extend(["--set", "ingress.tls[0].secretName=registry-tls"]) - args.extend(["--set", 'ingress.annotations."cert-manager\.io/cluster-issuer"=letsencrypt-prod']) - # maybe set ingress class - args.extend(["--set", "ingress.className=public"]) - args.extend(["--set", 'ingress.annotations."nginx\.ingress\.kubernetes\.io/proxy-body-size=0"']) - args.extend(["--set", f"secrets.htpasswd={cluster_name}:{password}"]) - args.extend(["--set", "updateStrategy.type=Recreate"]) - subprocess.run([HELM, "install", "sb-registry", "docker-registry/docker-registry", *args]) + current_path = os.path.dirname(os.path.realpath(__file__)) + registry_values_template = Template(open(f'{current_path}/values.yaml').read()) + registry_values = registry_values_template.substitute(cluster_name=cluster_name, tld=tld, password=password) + subprocess.run([HELM, "install", "sb-registry", "docker-registry/docker-registry", "-f", "-"], input=registry_values.encode()) click.echo("Enabled SB registry") if __name__ == "__main__": diff --git a/addons/sb-registry/values.yaml b/addons/sb-registry/values.yaml new file mode 100644 index 0000000..7dcfe5a --- /dev/null +++ b/addons/sb-registry/values.yaml @@ -0,0 +1,20 @@ +persistence: + enabled: true + size: "20Gi" +ingress: + enabled: true + hosts: + - "registry.$cluster_name.$tld" + tls: + - hosts: + - "registry.$cluster_name.$tld" + secretName: registry-tls + annotations: + cert-manager.io/cluster-issuer: letsencrypt-prod + nginx.ingress.kubernetes.io/proxy-body-size: 0 + className: public + +secrets: + htpasswd: "$cluster_name:$password" +updateStrategy: + type: Recreate