From e8385c6a3b08f6ae30c707ba642a451fd0a7fcc1 Mon Sep 17 00:00:00 2001 From: dgiannopoulos Date: Thu, 5 Sep 2024 16:19:31 +0300 Subject: [PATCH 1/4] feat: error handling and kubeconfig from local dir --- .../templates/{cridge-config.yaml => cridge-secret.yaml} | 6 ++++-- kubernetes/helm/openslice/templates/cridge.yaml | 8 ++------ 2 files changed, 6 insertions(+), 8 deletions(-) rename kubernetes/helm/openslice/templates/{cridge-config.yaml => cridge-secret.yaml} (61%) diff --git a/kubernetes/helm/openslice/templates/cridge-config.yaml b/kubernetes/helm/openslice/templates/cridge-secret.yaml similarity index 61% rename from kubernetes/helm/openslice/templates/cridge-config.yaml rename to kubernetes/helm/openslice/templates/cridge-secret.yaml index 2c62c9a..e790b53 100644 --- a/kubernetes/helm/openslice/templates/cridge-config.yaml +++ b/kubernetes/helm/openslice/templates/cridge-secret.yaml @@ -1,5 +1,6 @@ +{{- $kubeconfig := .Values.kubeconfig | default (.Files.Get "files/org.etsi.osl.cridge/kubeconfig.yaml") -}} apiVersion: v1 -kind: ConfigMap +kind: Secret metadata: namespace: {{ .Release.Namespace }} labels: @@ -8,6 +9,7 @@ metadata: chart: "{{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}" {{- include "openslice.labels" . | nindent 4 }} name: {{ include "openslice.fullname" . }}-cridge-kubeconfig +type: Opaque data: config: |- - {{- .Files.Get "files/org.etsi.osl.cridge/config" | nindent 4 }} + {{- required "A kubeconfig file is required." ($kubeconfig | b64enc) | nindent 4 }} diff --git a/kubernetes/helm/openslice/templates/cridge.yaml b/kubernetes/helm/openslice/templates/cridge.yaml index 5e55846..aebb439 100644 --- a/kubernetes/helm/openslice/templates/cridge.yaml +++ b/kubernetes/helm/openslice/templates/cridge.yaml @@ -24,10 +24,6 @@ spec: org.etsi.osl.service: cridge {{- include "openslice.selectorLabels" . | nindent 8 }} spec: - initContainers: - - name: init-osscapi - image: busybox:1.28 - command: ['sh', '-c', "until nslookup {{ include "openslice.fullname" . }}-osscapi; do echo waiting for osscapi; sleep 2; done"] containers: - image: "{{ .Values.image.cridge.repository }}:{{ .Values.image.cridge.tag | default .Chart.AppVersion }}" imagePullPolicy: {{ .Values.image.cridge.pullPolicy | default "Always" }} @@ -51,5 +47,5 @@ spec: restartPolicy: Always volumes: - name: cridge-kubeconfig - configMap: - name: {{ include "openslice.fullname" . }}-cridge-kubeconfig + secret: + secretName: {{ include "openslice.fullname" . }}-cridge-kubeconfig -- GitLab From e3326188aeab189373285e97d62287bf1beb6f07 Mon Sep 17 00:00:00 2001 From: Dimitrios Giannopoulos Date: Fri, 22 Nov 2024 15:53:57 +0200 Subject: [PATCH 2/4] feat: enhance cridge helm chart --- kubernetes/helm/openslice/Chart.yaml | 2 +- .../openslice/templates/cridge-secret.yaml | 21 +++++++++++++++++-- .../helm/openslice/templates/cridge.yaml | 10 ++++----- kubernetes/helm/openslice/values.yaml | 4 ++++ 4 files changed, 29 insertions(+), 8 deletions(-) diff --git a/kubernetes/helm/openslice/Chart.yaml b/kubernetes/helm/openslice/Chart.yaml index 18a24ba..0e5de20 100644 --- a/kubernetes/helm/openslice/Chart.yaml +++ b/kubernetes/helm/openslice/Chart.yaml @@ -20,4 +20,4 @@ version: 1.0.0 # 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 # follow Semantic Versioning. They should reflect the version the application is using. -appVersion: 2024Q2 +appVersion: 2024Q4-SNAPSHOT diff --git a/kubernetes/helm/openslice/templates/cridge-secret.yaml b/kubernetes/helm/openslice/templates/cridge-secret.yaml index e790b53..4a32bff 100644 --- a/kubernetes/helm/openslice/templates/cridge-secret.yaml +++ b/kubernetes/helm/openslice/templates/cridge-secret.yaml @@ -1,4 +1,15 @@ -{{- $kubeconfig := .Values.kubeconfig | default (.Files.Get "files/org.etsi.osl.cridge/kubeconfig.yaml") -}} +{{ if .Values.cridge.enabled }} + +{{- $kubeconfigBase64 := .Values.cridge.kubeconfig.base64 | default "" -}} +{{- $kubeconfigFile := .Values.cridge.kubeconfig.raw | default (.Files.Get "files/org.etsi.osl.cridge/kubeconfig.yaml") -}} +{{- $kubeconfig := "" -}} + +{{- if $kubeconfigBase64 }} + {{- $kubeconfig = $kubeconfigBase64 | b64dec }} +{{- else if $kubeconfigFile }} + {{- $kubeconfig = $kubeconfigFile }} +{{- end }} + apiVersion: v1 kind: Secret metadata: @@ -8,8 +19,14 @@ metadata: org.etsi.osl.service: cridge chart: "{{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}" {{- include "openslice.labels" . | nindent 4 }} - name: {{ include "openslice.fullname" . }}-cridge-kubeconfig + name: {{ include "openslice.fullname" . }}-kubeconfig type: Opaque data: config: |- + {{- if $kubeconfig }} + {{ $kubeconfig | b64enc | nindent 4 }} + {{- else }} {{- required "A kubeconfig file is required." ($kubeconfig | b64enc) | nindent 4 }} + {{- end }} + +{{- end }} diff --git a/kubernetes/helm/openslice/templates/cridge.yaml b/kubernetes/helm/openslice/templates/cridge.yaml index aebb439..1065639 100644 --- a/kubernetes/helm/openslice/templates/cridge.yaml +++ b/kubernetes/helm/openslice/templates/cridge.yaml @@ -1,3 +1,4 @@ +{{ if .Values.cridge.enabled }} apiVersion: apps/v1 kind: Deployment metadata: @@ -9,9 +10,7 @@ metadata: {{- include "openslice.labels" . | nindent 4 }} name: {{ include "openslice.fullname" . }}-cridge spec: - {{- if not .Values.autoscaling.enabled }} replicas: {{ .Values.replicaCount }} - {{- end }} selector: matchLabels: app: {{ include "openslice.fullname" . }} @@ -41,11 +40,12 @@ spec: resources: {{- toYaml .Values.resources | nindent 12 }} volumeMounts: - - name: cridge-kubeconfig + - name: kubeconfig readOnly: true mountPath: /root/.kube restartPolicy: Always volumes: - - name: cridge-kubeconfig + - name: kubeconfig secret: - secretName: {{ include "openslice.fullname" . }}-cridge-kubeconfig + secretName: {{ include "openslice.fullname" . }}-kubeconfig +{{- end }} diff --git a/kubernetes/helm/openslice/values.yaml b/kubernetes/helm/openslice/values.yaml index 178451e..7af2383 100644 --- a/kubernetes/helm/openslice/values.yaml +++ b/kubernetes/helm/openslice/values.yaml @@ -112,9 +112,13 @@ mysql: storage: 10Gi cridge: + enabled: true logLevel: INFO spring: loglevel: INFO + kubeconfig: + base64: "" # Provide base64-encoded kubeconfig here if available + raw: "" # Provide raw kubeconfig here if available portalapi: logLevel: INFO -- GitLab From 7ce0a2ba2cc68365ad1f92c62e620a34bbc6b2b1 Mon Sep 17 00:00:00 2001 From: Dimitrios Giannopoulos Date: Fri, 22 Nov 2024 16:36:15 +0200 Subject: [PATCH 3/4] fix: gitlab ci syntax --- .gitlab-ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 3787a3a..95f4774 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -3,11 +3,11 @@ include: - local: ci-templates/build.yml rules: - - if: '$CI_COMMIT_REF_NAME == "main" || $CI_COMMIT_REF_NAME == "develop" || $CI_COMMIT_REF_PROTECTED' + - if: '$CI_COMMIT_REF_NAME == "main" || $CI_COMMIT_REF_NAME == "develop" || $CI_COMMIT_REF_PROTECTED == "true"' - local: ci-templates/build_unprotected.yml rules: - - if: '$CI_COMMIT_REF_NAME != "main" && $CI_COMMIT_REF_NAME != "develop" && !$CI_COMMIT_REF_PROTECTED' + - if: '$CI_COMMIT_REF_NAME != "main" && $CI_COMMIT_REF_NAME != "develop" && $CI_COMMIT_REF_PROTECTED != "true"' maven_build: -- GitLab From bc6d54a81dcfc604e39a5ed6d6b64b47ab45819e Mon Sep 17 00:00:00 2001 From: Dimitrios Giannopoulos Date: Fri, 22 Nov 2024 14:42:50 +0000 Subject: [PATCH 4/4] Revert "fix: gitlab ci syntax" This reverts commit 7ce0a2ba2cc68365ad1f92c62e620a34bbc6b2b1 --- .gitlab-ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 95f4774..3787a3a 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -3,11 +3,11 @@ include: - local: ci-templates/build.yml rules: - - if: '$CI_COMMIT_REF_NAME == "main" || $CI_COMMIT_REF_NAME == "develop" || $CI_COMMIT_REF_PROTECTED == "true"' + - if: '$CI_COMMIT_REF_NAME == "main" || $CI_COMMIT_REF_NAME == "develop" || $CI_COMMIT_REF_PROTECTED' - local: ci-templates/build_unprotected.yml rules: - - if: '$CI_COMMIT_REF_NAME != "main" && $CI_COMMIT_REF_NAME != "develop" && $CI_COMMIT_REF_PROTECTED != "true"' + - if: '$CI_COMMIT_REF_NAME != "main" && $CI_COMMIT_REF_NAME != "develop" && !$CI_COMMIT_REF_PROTECTED' maven_build: -- GitLab