diff --git a/deploy/config-server/install.sh b/deploy/config-server/install.sh index e6e3e25b657..bec2a0115b0 100755 --- a/deploy/config-server/install.sh +++ b/deploy/config-server/install.sh @@ -11,23 +11,36 @@ CHART_VERSION=0.0.2-develop read -p "Is conf-secrets module installed?(Y/n) " conf_installed -read -p "Do you want to enable config-server to pull configurations from local repository?(Y/n)( Default: n )" local_enabled -if [[ -z $local_enabled ]]; then - local_enabled=n +echo "Please select the configuration source for config-server:" +echo "1. Pull configurations from multiple remote repositories (Git)" +echo "2. Pull configurations from local repository (NFS)" +echo "3. Both (Remote Git and Local NFS)" +read -p "Enter your choice (1/2/3) [Default: 1]: " repo_choice + +if [[ -z $repo_choice ]]; then + repo_choice=1 fi -if [ "$local_enabled" = "Y" ]; then - LOCALREPO="true" - read -p "Provide the NFS path where the local repository is cloned/maintained: " path - NFS_PATH="$path" +case $repo_choice in + 1) + SPRING_PROFILES="true" + LOCALREPO="false" + ;; + 2) + SPRING_PROFILES="false" + LOCALREPO="true" + ;; + 3) + SPRING_PROFILES="true" + LOCALREPO="true" + ;; + *) + echo "Invalid choice. Defaulting to option 1." + SPRING_PROFILES="true" + LOCALREPO="false" + ;; +esac - read -p "Provide the NFS IP address of the server where the local repository is cloned: " ip - NFS_SERVER="$ip" -else - LOCALREPO="false" - NFS_PATH="" - NFS_SERVER="" -fi if [ $conf_installed = "Y" ]; then read -p "Is values.yaml for config-server chart set correctly as part of Pre-requisites?(Y/n) " yn; fi if [ $yn = "Y" ] @@ -56,9 +69,8 @@ if [ $yn = "Y" ] echo "Installing config-server" helm -n $NS install config-server mosip/config-server \ + --set spring_profiles.enabled="$SPRING_PROFILES" \ --set localRepo.enabled="$LOCALREPO" \ - --set volume.nfs.path="$NFS_PATH" \ - --set volume.nfs.server="$NFS_SERVER" \ -f values.yaml \ --timeout 10m \ --wait --version $CHART_VERSION diff --git a/deploy/config-server/values.yaml b/deploy/config-server/values.yaml index 6b2b9772700..4d9ab9bee74 100644 --- a/deploy/config-server/values.yaml +++ b/deploy/config-server/values.yaml @@ -1,5 +1,6 @@ spring_profiles: enabled: true + spring_profiles_active: "composite" spring_compositeRepos: # Based on the user requiremnt the number of multiple sources from where configuration needs to be pulled can be updated below as mentioned. - type: git @@ -39,16 +40,13 @@ volume: # existingClaim: your-claim ## ReadWriteMany not supported by AWS gp2 name: config-server - storageClass: nfs-client + storageClass: nfs-csi accessModes: - ReadWriteMany size: 10Mi existingClaim: # Dir where config and keys are written inside container mountDir: '/var/lib/config_repo' - nfs: - path: '' # Dir within the nfs server where config repo is cloned/maintained locally. - server: '' # Ip address of nfs server. ## Extra environment variables to be passed to the config-server container ## By default, these are enabled for development/testing. Set enabled: false in production if not needed. diff --git a/helm/config-server/templates/config-pv.yaml b/helm/config-server/templates/config-pv.yaml deleted file mode 100644 index d209ba3aa86..00000000000 --- a/helm/config-server/templates/config-pv.yaml +++ /dev/null @@ -1,21 +0,0 @@ -{{- if .Values.spring_profiles.enabled }} - {{- if or .Values.localRepo.enabled (include "config-server.hasNative" . | eq "true") }} -apiVersion: v1 -kind: PersistentVolume -metadata: - name: {{ .Values.volume.name }} - labels: - name: {{ .Values.volume.name }} -spec: - storageClassName: {{ .Values.volume.storageClass }} - capacity: - storage: {{ .Values.volume.size }} - accessModes: - {{- range .Values.volume.accessModes }} - - {{ . }} - {{- end }} - nfs: - server: {{ .Values.volume.nfs.server }} - path: {{ .Values.volume.nfs.path }} - {{- end }} -{{- end }} \ No newline at end of file diff --git a/helm/config-server/templates/config-pvc.yaml b/helm/config-server/templates/config-pvc.yaml index b06ab486759..35fbee9f182 100644 --- a/helm/config-server/templates/config-pvc.yaml +++ b/helm/config-server/templates/config-pvc.yaml @@ -1,5 +1,4 @@ -{{- if .Values.spring_profiles.enabled }} - {{- if or .Values.localRepo.enabled (include "config-server.hasNative" . | eq "true") }} +{{- if .Values.localRepo.enabled }} apiVersion: v1 kind: PersistentVolumeClaim metadata: @@ -14,8 +13,5 @@ spec: resources: requests: storage: {{ .Values.volume.size }} - selector: - matchLabels: - name: {{ .Values.volume.name }} + {{- end }} -{{- end }} diff --git a/helm/config-server/templates/deployment.yaml b/helm/config-server/templates/deployment.yaml index 4128a9fe92f..0186ef460ee 100644 --- a/helm/config-server/templates/deployment.yaml +++ b/helm/config-server/templates/deployment.yaml @@ -41,6 +41,16 @@ spec: env: - name: JDK_JAVA_OPTIONS value: {{ .Values.additionalResources.javaOpts }} + {{- if and .Values.spring_profiles.enabled .Values.localRepo.enabled }} + - name: SPRING_PROFILES_ACTIVE + value: "{{ .Values.spring_profiles.spring_profiles_active }},{{ .Values.localRepo.spring_profiles_active }}" + {{- else if .Values.spring_profiles.enabled }} + - name: SPRING_PROFILES_ACTIVE + value: {{ .Values.spring_profiles.spring_profiles_active | quote }} + {{- else if .Values.localRepo.enabled }} + - name: SPRING_PROFILES_ACTIVE + value: {{ .Values.localRepo.spring_profiles_active | quote }} + {{- end }} {{- if .Values.spring_profiles.enabled }} {{- range $index, $repo := .Values.spring_profiles.spring_compositeRepos }} - name: SPRING_CLOUD_CONFIG_SERVER_COMPOSITE_{{ $index }}_URI @@ -78,7 +88,7 @@ spec: valueFrom: secretKeyRef: name: {{ include "config-server.fullname" $ }} - key: github-token-{{ $index }} + key: SPRING_CLOUD_CONFIG_SERVER_COMPOSITE_{{ $index }}_PASSWORD {{- end }} {{- if $repo.username }} - name: SPRING_CLOUD_CONFIG_SERVER_COMPOSITE_{{ $index }}_USERNAME @@ -147,20 +157,16 @@ spec: {{- end }} resources: {{- toYaml .Values.resources | nindent 12 }} - {{- if .Values.spring_profiles.enabled }} - {{- if or .Values.localRepo.enabled (include "config-server.hasNative" . | eq "true") }} + {{- if .Values.localRepo.enabled }} volumeMounts: - name: {{ .Values.volume.name }} mountPath: {{ .Values.volume.mountDir }} - {{- end }} {{- end }} - {{- if .Values.spring_profiles.enabled }} - {{- if or .Values.localRepo.enabled (include "config-server.hasNative" . | eq "true") }} + {{- if .Values.localRepo.enabled }} volumes: - name: {{ .Values.volume.name }} persistentVolumeClaim: claimName: {{ .Values.volume.name }} - {{- end }} {{- end }} {{- with .Values.nodeSelector }} nodeSelector: diff --git a/helm/config-server/templates/secret.yaml b/helm/config-server/templates/secret.yaml index dcf4f09f03a..c030877fdda 100644 --- a/helm/config-server/templates/secret.yaml +++ b/helm/config-server/templates/secret.yaml @@ -9,8 +9,8 @@ type: Opaque data: {{- range $index, $repo := .Values.spring_profiles.spring_compositeRepos }} {{- if $repo.token }} - github-token-{{ $index }}: {{ $repo.token | quote }} + SPRING_CLOUD_CONFIG_SERVER_COMPOSITE_{{ $index }}_PASSWORD: {{ $repo.token | b64enc | quote }} {{- else }} - github-token-{{ $index }}: "" + SPRING_CLOUD_CONFIG_SERVER_COMPOSITE_{{ $index }}_PASSWORD: "" {{- end }} {{- end }} diff --git a/helm/config-server/values.yaml b/helm/config-server/values.yaml index ec495ee2c3d..9d7daa87b3a 100644 --- a/helm/config-server/values.yaml +++ b/helm/config-server/values.yaml @@ -123,6 +123,7 @@ tolerations: [] affinity: {} spring_profiles: enabled: true + spring_profiles_active: "composite" spring_compositeRepos: # Based on the user requiremnt the number of multiple sources from where configuration needs to be pulled can be updated below as mentioned. - type: git @@ -160,18 +161,13 @@ volume: # existingClaim: your-claim ## ReadWriteMany not supported by AWS gp2 name: config-server - storageClass: nfs-client + storageClass: nfs-csi accessModes: - ReadWriteMany size: 10Mi existingClaim: # Dir where config and keys are written inside container mountDir: '/var/lib/config_repo' - nfs: - path: '' - # Dir within the nfs server where config repo is cloned/maintained locally. - server: '' - # Ip address of nfs server. ## Init containers parameters: ## volumePermissions: Change the owner and group of the persistent volume mountpoint to runAsUser:fsGroup values from the securityContext section. ##