From 15d824261d31033b4a1c31fa0094a179848d46ce Mon Sep 17 00:00:00 2001 From: ckm007 Date: Fri, 4 Oct 2024 12:28:41 +0530 Subject: [PATCH 1/2] [DSD-6382] updated chart version in helm and deployment scripts Signed-off-by: ckm007 --- deploy/esignet/install.sh | 2 +- deploy/oidc-ui/install.sh | 2 +- helm/esignet/Chart.yaml | 2 +- helm/esignet/values.yaml | 2 +- helm/oidc-ui/Chart.yaml | 2 +- helm/oidc-ui/values.yaml | 2 +- partner-onboarder/install.sh | 2 +- partner-onboarder/values.yaml | 10 +++++----- 8 files changed, 12 insertions(+), 12 deletions(-) diff --git a/deploy/esignet/install.sh b/deploy/esignet/install.sh index cf240a99d..e6a3611ad 100755 --- a/deploy/esignet/install.sh +++ b/deploy/esignet/install.sh @@ -7,7 +7,7 @@ if [ $# -ge 1 ] ; then fi NS=esignet -CHART_VERSION=0.0.1-test +CHART_VERSION=1.5.0-develop ESIGNET_HOST=$(kubectl -n esignet get cm esignet-global -o jsonpath={.data.mosip-esignet-host}) diff --git a/deploy/oidc-ui/install.sh b/deploy/oidc-ui/install.sh index 4927f4a58..76faec6de 100755 --- a/deploy/oidc-ui/install.sh +++ b/deploy/oidc-ui/install.sh @@ -7,7 +7,7 @@ if [ $# -ge 1 ] ; then fi NS=esignet -CHART_VERSION=0.0.1-test +CHART_VERSION=1.5.0-develop echo Create $NS namespace kubectl create ns $NS diff --git a/helm/esignet/Chart.yaml b/helm/esignet/Chart.yaml index 265aabe4c..d23e1a56d 100644 --- a/helm/esignet/Chart.yaml +++ b/helm/esignet/Chart.yaml @@ -2,7 +2,7 @@ apiVersion: v2 name: esignet description: A Helm chart for MOSIP esignet module type: application -version: 0.0.1-test +version: 1.5.0-develop appVersion: "" dependencies: - name: common diff --git a/helm/esignet/values.yaml b/helm/esignet/values.yaml index 24fed18f2..d2d6a0d34 100644 --- a/helm/esignet/values.yaml +++ b/helm/esignet/values.yaml @@ -53,7 +53,7 @@ service: image: registry: docker.io repository: mosipdev/esignet - tag: develop + tag: release-1.5.x ## Specify a imagePullPolicy ## Defaults to 'Always' if image tag is 'latest', else set to 'IfNotPresent' ## ref: http://kubernetes.io/docs/user-guide/images/#pre-pulling-images diff --git a/helm/oidc-ui/Chart.yaml b/helm/oidc-ui/Chart.yaml index 1993fec29..e54a454e9 100644 --- a/helm/oidc-ui/Chart.yaml +++ b/helm/oidc-ui/Chart.yaml @@ -2,7 +2,7 @@ apiVersion: v2 name: oidc-ui description: A Helm chart for MOSIP OIDC UI module type: application -version: 0.0.1-test +version: 1.5.0-develop appVersion: "" dependencies: - name: common diff --git a/helm/oidc-ui/values.yaml b/helm/oidc-ui/values.yaml index 5c7b25212..db05da2aa 100755 --- a/helm/oidc-ui/values.yaml +++ b/helm/oidc-ui/values.yaml @@ -52,7 +52,7 @@ service: image: registry: docker.io repository: mosipdev/oidc-ui - tag: develop + tag: release-1.5.x ## Specify a imagePullPolicy ## Defaults to 'Always' if image tag is 'latest', else set to 'IfNotPresent' diff --git a/partner-onboarder/install.sh b/partner-onboarder/install.sh index ed442938d..1243b4001 100755 --- a/partner-onboarder/install.sh +++ b/partner-onboarder/install.sh @@ -21,7 +21,7 @@ if [ "$flag" = "n" ]; then fi NS=esignet -CHART_VERSION=0.0.1-develop +CHART_VERSION=1.5.0-ES-develop echo Create $NS namespace kubectl create ns $NS || true diff --git a/partner-onboarder/values.yaml b/partner-onboarder/values.yaml index c6adfd94c..691725e11 100644 --- a/partner-onboarder/values.yaml +++ b/partner-onboarder/values.yaml @@ -1,7 +1,7 @@ -image: - registry: docker.io - repository: mosipdev/partner-onboarder - tag: develop +#image: +# registry: docker.io +# repository: mosipdev/partner-onboarder +# tag: develop onboarding: modules: @@ -17,7 +17,7 @@ onboarding: # ns_esignet: esignet # ns_signup: signup # secrets: -# s3: +# s3: # s3-user-secret: 'password' # volumes: # reports: From 1013b060c2d587657488c0f06e8d23ea39916760 Mon Sep 17 00:00:00 2001 From: ckm007 Date: Fri, 4 Oct 2024 15:03:11 +0530 Subject: [PATCH 2/2] [DSD-6382] updated changes as reported during dev round Signed-off-by: ckm007 --- deploy/README.md | 11 ++++-- ...-cm.yaml => esignet-global-cm.yaml.sample} | 0 deploy/install-prereq.sh | 32 ++++++----------- deploy/postgres/install.sh | 29 ++++++++++++---- deploy/postgres/postgres-init.sh | 6 ++-- deploy/softhsm/install.sh | 34 +++++++++++++++++++ deploy/{ => softhsm}/softhsm-values.yaml | 0 7 files changed, 77 insertions(+), 35 deletions(-) rename deploy/{esignet-global-cm.yaml => esignet-global-cm.yaml.sample} (100%) create mode 100644 deploy/softhsm/install.sh rename deploy/{ => softhsm}/softhsm-values.yaml (100%) diff --git a/deploy/README.md b/deploy/README.md index d1ca09675..beb32572f 100644 --- a/deploy/README.md +++ b/deploy/README.md @@ -24,9 +24,14 @@ * __Logging__ : Setup logging as per [steps](https://github.com/mosip/k8s-infra/tree/v1.2.0.2/logging). * __Monitoring__ : Setup monitoring consisting elasticsearch, kibana, grafana using [steps](https://github.com/mosip/k8s-infra/tree/v1.2.0.2/monitoring). ### Install Pre-requisites -``` -./install-prereq.sh -``` +* `esignet-global` configmap: For eSignet K8's env, `esignet-global` configmap in `esignet` namespace contains Domain related information. Follow below steps to add domain details for `esignet-global` configmap. + * Make sure kubeconfig file is already set and k8 cluster is accessible and kubectl is installed. + * Copy `esignet-global-cm.yaml.sample` to `esignet-global-cm.yaml`. + * Update the domain names in `esignet-global-cm.yaml` correctly for your environment. +* Install pre-requisites + ``` + ./install-prereq.sh + ``` ### Initialise pre-requisites * Update values file for postgres init [here](postgres/init_values.yaml). * Execute `initialise-prereq.sh` script to initialise postgres and keycloak and set esignet captcha. diff --git a/deploy/esignet-global-cm.yaml b/deploy/esignet-global-cm.yaml.sample similarity index 100% rename from deploy/esignet-global-cm.yaml rename to deploy/esignet-global-cm.yaml.sample diff --git a/deploy/install-prereq.sh b/deploy/install-prereq.sh index ee18d008c..b74765fc9 100755 --- a/deploy/install-prereq.sh +++ b/deploy/install-prereq.sh @@ -8,8 +8,6 @@ if [ $# -ge 1 ]; then fi ROOT_DIR=$(pwd) -SOFTHSM_NS=softhsm -SOFTHSM_CHART_VERSION=12.0.1 function prompt_for_deployment() { local module_name=$1 @@ -30,36 +28,26 @@ function prompt_for_deployment() { function installing_prerequisites() { - helm repo add mosip https://mosip.github.io/mosip-helm - helm repo update - - # Create esignet, softhsm namespace if not present - kubectl create ns esignet || true - kubectl create ns "$SOFTHSM_NS" || true - # Apply esignet-global config-map - kubectl apply -f esignet-global-cm.yaml - - echo "Istio label" - kubectl label ns "$SOFTHSM_NS" istio-injection=enabled --overwrite - - # Deploy Softhsm for Esignet. - echo "Installing Softhsm for esignet" - helm -n "$SOFTHSM_NS" install esignet-softhsm mosip/softhsm -f softhsm-values.yaml --version "$SOFTHSM_CHART_VERSION" --wait - echo "Installed Softhsm for esignet" + echo "Creating esignet-global configmap in esignet namespace" + kubectl -n esignet apply -f esignet-global-cm.yaml - declare -a modules=("istio-gateway" "postgres" "keycloak" "kafka" "redis") + declare -a modules=("istio-gateway" "postgres" "keycloak" "kafka" "redis" "softhsm") declare -A prompts=( - ["keycloak"]="Do you want to deploy keycloak in the keycloak namespace?" - ["kafka"]="Do you want to deploy Kafka in the kafka namespace?" + ["softhsm"]="Do you want to install softhsm for esignet service in softhsm namespace? Opt "n" in case it already exists in Softhsm namespace: " + ["keycloak"]="Do you want to deploy keycloak in the keycloak namespace? Opt "n" in case it already exists in keycloak namespace : " + ["kafka"]="Do you want to deploy Kafka in the kafka namespace? Opt "n" in case it already exists in kafka namespace : " + ["redis"]="Do you want to deploy redis in Redis namespace? Opt "n" in case it already exists in Redis namespace : " ) echo "Installing prerequisite services" for module in "${modules[@]}"; do - if [ "$module" == "istio-gateway" ] || [ "$module" == "redis" ] || [ "$module" == "postgres" ]; then + if [ "$module" == "istio-gateway" ] || [ "$module" == "postgres" ]; then cd "$ROOT_DIR/$module" ./install.sh + elif [[ -n "${prompts[$module]}" ]]; then + prompt_for_deployment "$module" "${prompts[$module]}" fi done echo "All prerequisite services deployed successfully." diff --git a/deploy/postgres/install.sh b/deploy/postgres/install.sh index 22f017242..7bc4bc687 100755 --- a/deploy/postgres/install.sh +++ b/deploy/postgres/install.sh @@ -55,20 +55,35 @@ function installing_postgres() { # Prompt the user if they want to install PostgreSQL while true; do - read -p "Do you want to install Postgres? Opt for 'n' if you have Postgres already installed. (y/n): " answer + read -p "Do you want to install default Postgres in esignet namespace? (y/n): " answer if [ "$answer" = "Y" ] || [ "$answer" = "y" ]; then echo "Continuing with Postgres server deployment..." - break + break # Proceed with the installation elif [ "$answer" = "N" ] || [ "$answer" = "n" ]; then - echo "Skipping Postgres installation. Running generate_secret.py to create Postgres secrets..." - python3 generate-secret-cm.py # Ensure that Python and the script are available in the environment - echo "Secrets generated. Exiting script." - exit 0 # Exit the script after generating secrets + # Prompt the user for further options + while true; do + echo "You opted not to install Postgres. What would you like to do next?" + echo "1. Skip Postgres server installation and configuration in esignet namespace." + echo "2. Configure external Postgres details by generating secrets and configmap in esignet namespace." + + read -p "Enter your choice (1/2): " option + + if [ "$option" = "1" ]; then + echo "Skipping Postgres server installation and configuration in esignet namespace." + exit 0 # Exit the script as the user chose to skip Postgres installation + elif [ "$option" = "2" ]; then + echo "Running generate_secret.py to create Postgres secrets and configmap..." + python3 generate-secret-cm.py # Ensure Python and the script are available in the environment + echo "Secrets generated successfully." + exit 0 # Exit the script after generating secrets and configmap + else + echo "Not a correct option. Please try again or press Ctrl + C to exit." + fi + done else echo "Please provide a correct option (Y or N)" fi done - # set commands for error handling. set -e set -o errexit ## set -e : exit the script if any statement returns a non-true return value diff --git a/deploy/postgres/postgres-init.sh b/deploy/postgres/postgres-init.sh index 7b0068fdf..91029570f 100755 --- a/deploy/postgres/postgres-init.sh +++ b/deploy/postgres/postgres-init.sh @@ -28,15 +28,15 @@ function initialize_db() { then echo Removing existing mosip_esignet installation and secret helm -n $NS delete esignet-postgres-init || true - kubectl delete secret db-common-secrets -n $NS || true + kubectl -n NS delete secret db-common-secrets || true echo Initializing DB helm -n $NS install esignet-postgres-init mosip/postgres-init --version $CHART_VERSION -f init_values.yaml --wait --wait-for-jobs break elif [ "$yn" = "N" ] || [ "$yn" = "n" ]; then - echo "Skipping postgres initialisation as per your input" + echo "Skipping eSignet postgres DB initialisation as per your input" break else - echo "Incorrect Input" + echo "Incorrect Input. Please choose again" break fi done diff --git a/deploy/softhsm/install.sh b/deploy/softhsm/install.sh new file mode 100644 index 000000000..cbd47995e --- /dev/null +++ b/deploy/softhsm/install.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Installs Softhsm service for Esignet +## Usage: ./install.sh [kubeconfig] + +if [ $# -ge 1 ] ; then + export KUBECONFIG=$1 +fi + +NS=softhsm +CHART_VERSION=12.0.1 + +function installing_softhsm() { + echo Create $NS namespaces + kubectl create ns $NS || true + + echo Istio label + kubectl label ns $NS istio-injection=enabled --overwrite + helm repo update + + # Deploy Softhsm for Esignet. + echo "Installing Softhsm for esignet" + helm -n "$SOFTHSM_NS" install esignet-softhsm mosip/softhsm -f softhsm-values.yaml --version "$SOFTHSM_CHART_VERSION" --wait + echo "Installed Softhsm for esignet" + + return 0 +} + +# set commands for error handling. +set -e +set -o errexit ## set -e : exit the script if any statement returns a non-true return value +set -o nounset ## set -u : exit the script if you try to use an uninitialised variable +set -o errtrace # trace ERR through 'time command' and other functions +set -o pipefail # trace ERR through pipes +installing_softhsm # calling function diff --git a/deploy/softhsm-values.yaml b/deploy/softhsm/softhsm-values.yaml similarity index 100% rename from deploy/softhsm-values.yaml rename to deploy/softhsm/softhsm-values.yaml