Skip to content

Commit

Permalink
[MOSIP-37447] added nfs helm changes for apitestrig
Browse files Browse the repository at this point in the history
Signed-off-by: bhumi46 <[email protected]>
  • Loading branch information
bhumi46 committed Nov 14, 2024
1 parent 6ecfe85 commit 4b9cb29
Show file tree
Hide file tree
Showing 18 changed files with 1,003 additions and 26 deletions.
2 changes: 1 addition & 1 deletion deploy/esignet-apitestrig/delete.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,4 @@ set -o errexit ## set -e : exit the script if any statement returns a non-true
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
deleting_apitestrig # calling function
deleting_apitestrig # calling function
100 changes: 75 additions & 25 deletions deploy/esignet-apitestrig/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ if [ $# -ge 1 ] ; then
fi

NS=esignet
CHART_VERSION=0.0.1-develop
CHART_VERSION=1.5.0-develop
COPY_UTIL=../copy_cm_func.sh

echo Create $NS namespace
Expand Down Expand Up @@ -96,29 +96,79 @@ function installing_apitestrig() {
else
echo "eSignet service is not deployed. hence will be skipping esignet related test-cases..."
fi

echo Installing esignet apitestrig
helm -n $NS install esignet-apitestrig mosip/apitestrig \
--set crontime="0 $time * * *" \
-f values.yaml \
--version $CHART_VERSION \
--set apitestrig.configmaps.s3.s3-host='http://minio.minio:9000' \
--set apitestrig.configmaps.s3.s3-user-key='admin' \
--set apitestrig.configmaps.s3.s3-region='' \
--set apitestrig.configmaps.db.db-server="$DB_HOST" \
--set apitestrig.configmaps.db.db-su-user="postgres" \
--set apitestrig.configmaps.db.db-port="5432" \
--set apitestrig.configmaps.apitestrig.ENV_USER="$ENV_USER" \
--set apitestrig.configmaps.apitestrig.ENV_ENDPOINT="https://$API_INTERNAL_HOST" \
--set apitestrig.configmaps.apitestrig.ENV_TESTLEVEL="smokeAndRegression" \
--set apitestrig.configmaps.apitestrig.reportExpirationInDays="$reportExpirationInDays" \
--set apitestrig.configmaps.apitestrig.slack-webhook-url="$slackWebhookUrl" \
--set apitestrig.configmaps.apitestrig.eSignetDeployed="$eSignetDeployed" \
--set apitestrig.configmaps.apitestrig.NS="$NS" \
$ENABLE_INSECURE

echo Installed esignet apitestrig.
return 0
read -p "Is values.yaml for onboarder chart set correctly as part of pre-requisites? (Y/n) : " yn;
if [[ $yn = "Y" ]] || [[ $yn = "y" ]] ; then
NFS_OPTION=''
S3_OPTION=''
config_complete=false # flag to check if S3 or NFS is configured
while [ "$config_complete" = false ]; do
read -p "Do you have S3 details for storing Onboarder reports? (Y/n) : " ans
if [[ "$ans" == "y" || "$ans" == "Y" ]]; then
read -p "Please provide S3 host: " s3_host
if [[ -z $s3_host ]]; then
echo "S3 host not provided; EXITING;"
exit 1;
fi
read -p "Please provide S3 region: " s3_region
if [[ $s3_region == *[' !@#$%^&*()+']* ]]; then
echo "S3 region should not contain spaces or special characters; EXITING;"
exit 1;
fi
read -p "Please provide S3 access key: " s3_user_key
if [[ -z $s3_user_key ]]; then
echo "S3 access key not provided; EXITING;"
exit 1;
fi
S3_OPTION="--set apitestrig.configmaps.s3.s3-host=$s3_host --set apitestrig.configmaps.s3.s3-user-key=$s3_user_key --set apitestrig.configmaps.s3.s3-region=$s3_region"
push_reports_to_s3="yes"
config_complete=true
elif [[ "$ans" == "n" || "$ans" == "N" ]]; then
push_reports_to_s3="no"
read -p "Since S3 details are not available, do you want to use NFS directory mount for storing reports? (y/n) : " answer
if [[ $answer == "Y" ]] || [[ $answer == "y" ]]; then
read -p "Please provide NFS Server IP: " nfs_server
if [[ -z $nfs_server ]]; then
echo "NFS server not provided; EXITING."
exit 1;
fi
read -p "Please provide NFS directory to store reports from NFS server (e.g. /srv/nfs/<sandbox>/onboarder/), make sure permission is 777 for the folder: " nfs_path
if [[ -z $nfs_path ]]; then
echo "NFS Path not provided; EXITING."
exit 1;
fi
NFS_OPTION="--set apitestrig.volumes.reports.nfs.server=$nfs_server --set apitestrig.volumes.reports.nfs.path=$nfs_path"
config_complete=true
else
echo "Please rerun the script with either S3 or NFS server details."
exit 1;
fi
else
echo "Invalid input. Please respond with Y (yes) or N (no)."
fi
done
echo Installing esignet apitestrig
helm -n $NS install esignet-apitestrig mosip/apitestrig \
--set crontime="0 $time * * *" \
-f values.yaml \
--version $CHART_VERSION \
$NFS_OPTION \
$S3_OPTION \
--set apitestrig.variables.push_reports_to_s3=$push_reports_to_s3 \
--set apitestrig.configmaps.db.db-server="$DB_HOST" \
--set apitestrig.configmaps.db.db-su-user="postgres" \
--set apitestrig.configmaps.db.db-port="5432" \
--set apitestrig.configmaps.apitestrig.ENV_USER="$ENV_USER" \
--set apitestrig.configmaps.apitestrig.ENV_ENDPOINT="https://$API_INTERNAL_HOST" \
--set apitestrig.configmaps.apitestrig.ENV_TESTLEVEL="smokeAndRegression" \
--set apitestrig.configmaps.apitestrig.reportExpirationInDays="$reportExpirationInDays" \
--set apitestrig.configmaps.apitestrig.slack-webhook-url="$slackWebhookUrl" \
--set apitestrig.configmaps.apitestrig.eSignetDeployed="$eSignetDeployed" \
--set apitestrig.configmaps.apitestrig.NS="$NS" \
$ENABLE_INSECURE

echo Installed esignet apitestrig.
return 0
fi
}

# set commands for error handling.
Expand All @@ -127,4 +177,4 @@ set -o errexit ## set -e : exit the script if any statement returns a non-true
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_apitestrig # calling function
installing_apitestrig # calling function
1 change: 1 addition & 0 deletions helm/apitestrig/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
charts/
21 changes: 21 additions & 0 deletions helm/apitestrig/.helmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Patterns to ignore when building packages.
# This supports shell glob matching, relative path matching, and
# negation (prefixed with !). Only one pattern per line.
.DS_Store
# Common VCS dirs
.git/
.gitignore
.bzr/
.bzrignore
.hg/
.hgignore
.svn/
# Common backup files
*.swp
*.bak
*.tmp
*~
# Various IDEs
.project
.idea/
*.tmproj
19 changes: 19 additions & 0 deletions helm/apitestrig/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
apiVersion: v2
name: apitestrig
description: A Helm chart to deploy APITESTRIG for MOSIP modules
type: application
version: 1.5.0-develop
appVersion: ""
dependencies:
- name: common
repository: https://charts.bitnami.com/bitnami
tags:
- bitnami-common
version: 1.x.x
home: https://mosip.io
keywords:
- mosip
- apitestrig
maintainers:
- email: [email protected]
name: MOSIP
10 changes: 10 additions & 0 deletions helm/apitestrig/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# APITESTRIG

Helm chart to deploy APITESTRIG for `MOSIP` modules

## TL;DR

```console
$ helm repo add mosip https://mosip.github.io
$ helm install my-release mosip/apitestrig
```
1 change: 1 addition & 0 deletions helm/apitestrig/templates/NOTES.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

63 changes: 63 additions & 0 deletions helm/apitestrig/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
{{/*
Return the proper image name
*/}}
{{- define "apitestrig.image" -}}
{{ include "common.images.image" (dict "imageRoot" .Values.image "global" .Values.global) }}
{{- end -}}

{{/*
Return the proper image name (for the init container volume-permissions image)
*/}}
{{- define "apitestrig.volumePermissions.image" -}}
{{- include "common.images.image" ( dict "imageRoot" .Values.volumePermissions.image "global" .Values.global ) -}}
{{- end -}}

{{/*
Return the proper Docker Image Registry Secret Names
*/}}
{{- define "apitestrig.imagePullSecrets" -}}
{{- include "common.images.pullSecrets" (dict "images" (list .Values.image .Values.volumePermissions.image) "global" .Values.global) -}}
{{- end -}}

{{/*
Create the name of the service account to use
*/}}
{{- define "apitestrig.serviceAccountName" -}}
{{- if .Values.serviceAccount.create -}}
{{ default (printf "%s" (include "common.names.fullname" .)) .Values.serviceAccount.name }}
{{- else -}}
{{ default "default" .Values.serviceAccount.name }}
{{- end -}}
{{- end -}}

{{/*
Compile all warnings into a single message.
*/}}
{{- define "apitestrig.validateValues" -}}
{{- $messages := list -}}
{{- $messages := append $messages (include "apitestrig.validateValues.foo" .) -}}
{{- $messages := append $messages (include "apitestrig.validateValues.bar" .) -}}
{{- $messages := without $messages "" -}}
{{- $message := join "\n" $messages -}}

{{- if $message -}}
{{- printf "\nVALUES VALIDATION:\n%s" $message -}}
{{- end -}}
{{- end -}}

{{/*
Return podAnnotations
*/}}
{{- define "apitestrig.podAnnotations" -}}
{{- if .Values.podAnnotations }}
{{ include "common.tplvalues.render" (dict "value" .Values.podAnnotations "context" $) }}
{{- end }}
{{- if and .Values.metrics.enabled .Values.metrics.podAnnotations }}
{{ include "common.tplvalues.render" (dict "value" .Values.metrics.podAnnotations "context" $) }}
{{- end }}
{{- end -}}

{{/* Create the name for restart cronjob */}}
{{- define "apitestrig.cronjob" -}}
{{ default (printf "cronjob-%s" (include "common.names.fullname" .)) .Values.serviceAccount.name }}
{{- end -}}
10 changes: 10 additions & 0 deletions helm/apitestrig/templates/clusterrole.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: {{ template "apitestrig.serviceAccountName" . }}-{{ .Release.Namespace }}
namespace: {{ .Release.Namespace }}
rules:
- apiGroups: [""]
resources: ["pods"]
verbs: ["get","patch","list","watch"]
19 changes: 19 additions & 0 deletions helm/apitestrig/templates/clusterrolebinding.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
kind: ClusterRoleBinding
apiVersion: {{ include "common.capabilities.rbac.apiVersion" . }}
metadata:
labels: {{- include "common.labels.standard" . | nindent 4 }}
{{- if .Values.commonLabels }}
{{- include "common.tplvalues.render" ( dict "value" .Values.commonLabels "context" $ ) | nindent 4 }}
{{- end }}
name: {{ template "common.names.fullname" . }}-{{ .Release.Namespace }}
{{- if .Values.commonAnnotations }}
annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
{{- end }}
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: {{ template "apitestrig.serviceAccountName" . }}-{{ .Release.Namespace }}
subjects:
- kind: ServiceAccount
name: {{ template "apitestrig.serviceAccountName" . }}
namespace: {{ .Release.Namespace }}
21 changes: 21 additions & 0 deletions helm/apitestrig/templates/configmaps.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{{- if .Values.apitestrig.configmaps }}
{{- range $cm_name, $cm_value := .Values.apitestrig.configmaps }}
---
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ $cm_name }}
namespace: {{ $.Release.Namespace }}
labels: {{- include "common.labels.standard" $ | nindent 8 }}
{{- if $.Values.commonLabels }}
{{- include "common.tplvalues.render" ( dict "value" $.Values.commonLabels "context" $ ) | nindent 8 }}
{{- end }}
{{- if $.Values.commonAnnotations }}
annotations: {{- include "common.tplvalues.render" ( dict "value" $.Values.commonAnnotations "context" $ ) | nindent 8 }}
{{- end }}
data:
{{- range $key, $value := $cm_value }}
{{ $key }}: {{ $value | quote }}
{{- end }}
{{- end }}
{{- end }}
Loading

0 comments on commit 4b9cb29

Please sign in to comment.