Fix installer and OSM helm chart to include git data and credentials to be used by LCM 48/14548/1
authorgarciadeblas <gerardo.garciadeblas@telefonica.com>
Tue, 10 Sep 2024 16:50:29 +0000 (18:50 +0200)
committergarciadeblas <gerardo.garciadeblas@telefonica.com>
Wed, 11 Sep 2024 07:50:32 +0000 (09:50 +0200)
Change-Id: I2bab55bba10f3274fc3c645d124979438a78c68d
Signed-off-by: garciadeblas <gerardo.garciadeblas@telefonica.com>
installers/full_install_osm.sh
installers/helm/osm/templates/lcm/lcm-deployment.yaml
installers/helm/osm/templates/osm-gitops-secret.yaml [new file with mode: 0644]
installers/helm/osm/values.yaml

index 061aba9..5931522 100755 (executable)
@@ -226,7 +226,15 @@ EOF"
     OSM_HELM_OPTS="${OSM_HELM_OPTS} --set grafana.ingress.hosts={grafana.${OSM_DEFAULT_IP}.nip.io}"
     OSM_HELM_OPTS="${OSM_HELM_OPTS} --set prometheus.server.ingress.hosts={prometheus.${OSM_DEFAULT_IP}.nip.io}"
     # OSM_HELM_OPTS="${OSM_HELM_OPTS} --set prometheus.alertmanager.ingress.hosts={alertmanager.${OSM_DEFAULT_IP}.nip.io}"
-    [ -z "${INSTALL_MGMT_CLUSTER}" ] && OSM_HELM_OPTS="${OSM_HELM_OPTS} --set global.gitops.enabled=false}"
+    if [ -z "${INSTALL_MGMT_CLUSTER}" ]; then
+        OSM_HELM_OPTS="${OSM_HELM_OPTS} --set global.gitops.enabled=false"
+    else
+        source "${HOME}/.osm/.credentials/gitea_environment.rc"
+        OSM_HELM_OPTS="${OSM_HELM_OPTS} --set global.gitops.gitBaseUrl=${GITEA_HTTP_URL}"
+        OSM_HELM_OPTS="${OSM_HELM_OPTS} --set global.gitops.gitUser=${GITEA_STD_USERNAME}"
+        AGE_MGMT_PUBKEY=$(tr -d '\n' < ${HOME}/.osm/.credentials/age.mgmt.pub)
+        OSM_HELM_OPTS="${OSM_HELM_OPTS} --set global.gitops.pubkey=${AGE_MGMT_PUBKEY}"
+    fi
 
     if [ -n "${INSTALL_JUJU}" ]; then
         OSM_HELM_OPTS="${OSM_HELM_OPTS} --set vca.enabled=true"
@@ -545,6 +553,10 @@ function install_osm() {
     echo "Options: ${MGMTCLUSTER_INSTALL_OPTS}"
     $OSM_DEVOPS/installers/mgmt-cluster/install_mgmt_cluster.sh ${MGMTCLUSTER_INSTALL_OPTS} || \
     FATAL_TRACK mgmtcluster "install_mgmt_cluster.sh failed"
+    if [ -n "${INSTALL_MGMT_CLUSTER}" ]; then
+        echo "Credentials stored under ${HOME}/.osm/.credentials"
+        echo "Repos stored under ${HOME}/.osm/repos"
+    fi
     track mgmtcluster mgmt_and_aux_cluster_ok
 
     # Deploy OSM (mongodb, OSM helm chart, NGSA)
index fd01923..a00403a 100644 (file)
@@ -69,6 +69,10 @@ spec:
             - secretRef:
                 name: {{ .Values.lcm.secretName | default "lcm-secret" }}
             {{- end }}
+            {{- if .Values.global.gitops.enabled }}
+            - secretRef:
+                name: {{ include "osm.fullname" . }}-gitops-secret
+            {{- end }}
           {{- if or .Values.vca.enabled .Values.lcm.useOsmSecret }}
           env:
             {{- if .Values.vca.enabled }}
diff --git a/installers/helm/osm/templates/osm-gitops-secret.yaml b/installers/helm/osm/templates/osm-gitops-secret.yaml
new file mode 100644 (file)
index 0000000..233b74c
--- /dev/null
@@ -0,0 +1,29 @@
+{{- if .Values.global.gitops.enabled }}
+#######################################################################################
+# Copyright ETSI Contributors and Others.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#    http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+# implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#######################################################################################
+apiVersion: v1
+kind: Secret
+type: Opaque
+metadata:
+  name: {{ include "osm.fullname" . }}-gitops-secret
+  labels:
+    {{- include "osm.labels" . | nindent 4 }}
+data:
+  OSM_GITOPS_GIT_BASE_URL: {{ ( .Values.global.gitops.gitBaseUrl | default "http://git.127.0.0.1.nip.io" ) | b64enc | quote }}
+  OSM_GITOPS_USER: {{ ( .Values.global.gitops.gitUser | default "osm-developer" ) | b64enc | quote }}
+  OSM_GITOPS_PUBKEY: {{ ( .Values.global.gitops.pubkey | default ( randAlphaNum 32 ) ) | b64enc | quote }}
+{{- end }}
\ No newline at end of file
index 3c648f1..e259f80 100644 (file)
@@ -62,6 +62,9 @@ global:
     mgmtcluster:
       secretName: mgmtcluster-secret
       secretKey: kubeconfig
+    gitUser: osm-developer
+    # gitBaseUrl: http://git.<IP_ADDRESS>.nip.io
+    # pubkey: AGEKEY
 
   podAnnotations: {}