From 3dd3c6293a22226147f42a06b465c48beff465da Mon Sep 17 00:00:00 2001 From: jessebot Date: Tue, 26 Mar 2024 14:02:54 +0100 Subject: [PATCH] create admin curl script instead of fighting spacing --- charts/netmaker/Chart.yaml | 2 +- charts/netmaker/README.md | 2 +- .../templates/netmaker-admin-configmap.yaml | 14 ++++++++++++++ .../templates/netmaker-admin-user-job.yaml | 14 +++++++++----- 4 files changed, 25 insertions(+), 7 deletions(-) create mode 100644 charts/netmaker/templates/netmaker-admin-configmap.yaml diff --git a/charts/netmaker/Chart.yaml b/charts/netmaker/Chart.yaml index db54875..c57bc5a 100644 --- a/charts/netmaker/Chart.yaml +++ b/charts/netmaker/Chart.yaml @@ -15,7 +15,7 @@ type: application # This is the chart version. This version number should be incremented each time you make changes # to the chart and its templates, including the app version. # Versions are expected to follow Semantic Versioning (https://semver.org/) -version: 0.11.2 +version: 0.11.3 # This is the version number of the application being deployed. This version number should be # incremented each time you make changes to the application. Versions are not expected to diff --git a/charts/netmaker/README.md b/charts/netmaker/README.md index fef727f..ee2b9e9 100644 --- a/charts/netmaker/README.md +++ b/charts/netmaker/README.md @@ -1,6 +1,6 @@ # netmaker -![Version: 0.11.2](https://img.shields.io/badge/Version-0.11.2-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: v0.23.0](https://img.shields.io/badge/AppVersion-v0.23.0-informational?style=flat-square) +![Version: 0.11.3](https://img.shields.io/badge/Version-0.11.3-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: v0.23.0](https://img.shields.io/badge/AppVersion-v0.23.0-informational?style=flat-square) A Helm chart to run HA Netmaker on Kubernetes diff --git a/charts/netmaker/templates/netmaker-admin-configmap.yaml b/charts/netmaker/templates/netmaker-admin-configmap.yaml new file mode 100644 index 0000000..5c0b389 --- /dev/null +++ b/charts/netmaker/templates/netmaker-admin-configmap.yaml @@ -0,0 +1,14 @@ +{{- if or .Values.netmaker.admin.user .Values.netmaker.admin.existingSecret }} +apiVersion: v1 +kind: ConfigMap +metadata: + name: setup-initial-user-job-script + labels: + "helm.sh/hook": post-install + "helm.sh/hook-delete-policy": hook-succeeded + "helm.sh/hook-weight": "-5" + {{- include "netmaker.labels" . | nindent 4 }} +data: + create_admin_user.sh: | + curl --location "https://$SERVER_HTTP_HOST/api/users/adm/createsuperadmin" --header 'Content-Type: application/json' --data "{\"username\":\"$ADMIN_USER\",\"password\":\"$ADMIN_PASSWORD\"}" +{{- end }} diff --git a/charts/netmaker/templates/netmaker-admin-user-job.yaml b/charts/netmaker/templates/netmaker-admin-user-job.yaml index 9dfee64..ee08584 100644 --- a/charts/netmaker/templates/netmaker-admin-user-job.yaml +++ b/charts/netmaker/templates/netmaker-admin-user-job.yaml @@ -7,20 +7,24 @@ metadata: annotations: "helm.sh/hook": post-install "helm.sh/hook-delete-policy": hook-succeeded + "helm.sh/hook-weight": "-4" spec: template: metadata: name: setup-initial-user-pod spec: restartPolicy: {{ .Values.netmaker.admin.jobRestartPolicy }} + volumes: + - name: admin-script + configMap: + name: setup-initial-user-job-script containers: - name: setup-initial-user image: curlimages/curl:latest - command: - - |- - curl --location "https://$SERVER_HTTP_HOST/api/users/adm/createsuperadmin" \ - --header 'Content-Type: application/json' \ - --data "{\"username\":\"$ADMIN_USER\",\"password\":\"$ADMIN_PASSWORD\"}" + volumeMounts: + - mountPath: /scripts + name: admin-script + command: ['/scripts/create_admin_user.sh'] env: - name: SERVER_HTTP_HOST valueFrom: