Skip to content

Commit

Permalink
Merge pull request #9 from lalithkota/main
Browse files Browse the repository at this point in the history
SPAR: Added new module & microservice for spar mapper
  • Loading branch information
shibu-narayanan authored Feb 4, 2024
2 parents 50d6fd2 + c74b403 commit 1fd465c
Show file tree
Hide file tree
Showing 38 changed files with 806 additions and 195 deletions.
23 changes: 23 additions & 0 deletions charts/g2p-cash-transfer-bridge/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,26 @@ Create the name of the service account to use
{{- default "default" .Values.serviceAccount.name }}
{{- end }}
{{- end }}

{{/*
Render Env values section
*/}}
{{- define "gctb.envVars" -}}
{{- range $k, $v := .Values.envVars }}
- name: {{ $k }}
value: {{ tpl $v $ | quote }}
{{- end }}
{{- range $k, $v := .Values.envVarsFrom }}
- name: {{ $k }}
valueFrom:
{{- if $v.configMapKeyRef }}
configMapKeyRef:
name: {{ tpl $v.configMapKeyRef.name $ | quote }}
key: {{ tpl $v.configMapKeyRef.key $ | quote }}
{{- else if $v.secretKeyRef }}
secretKeyRef:
name: {{ tpl $v.secretKeyRef.name $ | quote }}
key: {{ tpl $v.secretKeyRef.key $ | quote }}
{{- end }}
{{- end }}
{{- end }}
46 changes: 2 additions & 44 deletions charts/g2p-cash-transfer-bridge/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,56 +34,14 @@ spec:
- 'sh'
- '-c'
- 'until pg_isready -U $GCTB_CORE_DB_USERNAME -h $GCTB_CORE_DB_HOSTNAME -p ${GCTB_CORE_DB_PORT:-5432} -d ${GCTB_CORE_DB_DBNAME:-gctbdb}; do sleep 3; done'
env:
{{- range $k, $v := .Values.envVars }}
- name: {{ $k }}
{{- if and (eq $k "GCTB_CORE_DB_HOSTNAME") (not $v) }}
value: {{ include "postgresql.v1.primary.fullname" $.Subcharts.postgresql }}
{{- else }}
value: {{ $v | quote }}
{{- end }}
{{- end }}
{{- range $k, $v := .Values.envVarsFrom }}
- name: {{ $k }}
{{- if and (eq $k "GCTB_CORE_DB_PASSWORD") (not $v) }}
valueFrom:
secretKeyRef:
name: {{ include "postgresql.v1.primary.fullname" $.Subcharts.postgresql }}
key: password
{{- else }}
{{- toYaml $v | nindent 14 }}
{{- end }}
{{- end }}
env: {{ include "gctb.envVars" . | nindent 10 }}
containers:
- name: {{ .Chart.Name }}
securityContext:
{{- toYaml .Values.securityContext | nindent 12 }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
env:
{{- range $k, $v := .Values.envVars }}
- name: {{ $k }}
{{- if and (eq $k "GCTB_CORE_DB_HOSTNAME") (not $v) }}
value: {{ include "postgresql.v1.primary.fullname" $.Subcharts.postgresql }}
{{- else if and (eq $k "GCTB_ID_TRANSLATE_QUEUE_REDIS_HOST") (not $v) }}
value: {{ printf "%s-master" (include "common.names.fullname" $.Subcharts.redis) }}
{{- else if and (eq $k "GCTB_ID_TRANSLATE_MAPPER_RESOLVE_SENDER_URL") (not $v) }}
value: {{ printf "http://%s.%s/internal/callback/mapper" (include "gctb.fullname" $) $.Release.Namespace }}
{{- else }}
value: {{ $v | quote }}
{{- end }}
{{- end }}
{{- range $k, $v := .Values.envVarsFrom }}
- name: {{ $k }}
{{- if and (eq $k "GCTB_CORE_DB_PASSWORD") (not $v) }}
valueFrom:
secretKeyRef:
name: {{ include "postgresql.v1.primary.fullname" $.Subcharts.postgresql }}
key: password
{{- else }}
{{- toYaml $v | nindent 14 }}
{{- end }}
{{- end }}
env: {{ include "gctb.envVars" . | nindent 10 }}
ports:
- name: http
containerPort: {{ .Values.containerPort }}
Expand Down
17 changes: 7 additions & 10 deletions charts/g2p-cash-transfer-bridge/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -75,22 +75,19 @@ tolerations: []
affinity: {}

envVars:
GCTB_CORE_DB_HOSTNAME: "" # Leave blank to take default value
GCTB_CORE_DB_HOSTNAME: '{{ include "postgresql.v1.primary.fullname" .Subcharts.postgresql }}'
GCTB_CORE_DB_USERNAME: "gctbuser"
GCTB_CORE_OPENAPI_ROOT_PATH: "/g2pCashTransferBridge/v1"
GCTB_ID_TRANSLATE_MAPPER_API_TIMEOUT_SECS: "1"
GCTB_ID_TRANSLATE_MAPPER_RESOLVE_URL: "http://mapper.spar/v0.1.0/mapper/resolve" # Change to the url according to ID Mapper provider
GCTB_ID_TRANSLATE_MAPPER_RESOLVE_SENDER_URL: "" # Leave blank to take default value
GCTB_ID_TRANSLATE_QUEUE_REDIS_HOST: "" # Leave blank to take default value
GCTB_ID_TRANSLATE_MAPPER_RESOLVE_SENDER_URL: 'http://{{ include "gctb.fullname" . }}.{{ .Release.Namespace }}/internal/callback/mapper'
GCTB_ID_TRANSLATE_QUEUE_REDIS_HOST: '{{ include "common.names.fullname" .Subcharts.redis }}-master'

envVarsFrom:
GCTB_CORE_DB_PASSWORD: {}
# Leave blank to take default value
# GCTB_CORE_DB_PASSWORD:
# valueFrom:
# secretKeyRef:
# name: postgresql
# key: password
GCTB_CORE_DB_PASSWORD:
secretKeyRef:
name: '{{ include "postgresql.v1.primary.fullname" .Subcharts.postgresql }}'
key: password

istio:
enabled: true
Expand Down
14 changes: 10 additions & 4 deletions charts/social-payments-account-registry/Chart.lock
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
dependencies:
- name: postgresql
repository: oci://registry-1.docker.io/bitnamicharts
version: 13.2.24
version: 13.4.4
- name: redis
repository: oci://registry-1.docker.io/bitnamicharts
version: 18.5.0
digest: sha256:f7a78c28904bfb08c2c1b1daf44c8ffa57faeb9a5df4ae82274e68e54b7cc31b
generated: "2023-12-11T21:54:58.092231288+05:30"
version: 18.12.0
- name: spar-g2pconnect-id-mapper
repository: ""
version: 0.1.0
- name: sunbird-rc-g2p-mapper-registry
repository: ""
version: 0.1.0
digest: sha256:1e9deadb92614547a6635a0a81e152362d46ceb9d9dd8f7e6cac6eb208c7dd7c
generated: "2024-02-02T02:08:46.452615943+05:30"
6 changes: 6 additions & 0 deletions charts/social-payments-account-registry/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,9 @@ dependencies:
repository: oci://registry-1.docker.io/bitnamicharts
version: 18.x.x
condition: redis.enabled
- name: spar-g2pconnect-id-mapper
version: 0.1.0
condition: spar-g2pconnect-id-mapper.enabled
- name: sunbird-rc-g2p-mapper-registry
version: 0.1.0
condition: sunbird-rc-g2p-mapper-registry.enabled
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
46 changes: 46 additions & 0 deletions charts/social-payments-account-registry/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,49 @@ Create the name of the service account to use
{{- default "default" .Values.serviceAccount.name }}
{{- end }}
{{- end }}

{{/*
Render Env values section
*/}}
{{- define "spar.envVars" -}}
{{- range $k, $v := .Values.envVars }}
- name: {{ $k }}
value: {{ tpl $v $ | quote }}
{{- end }}
{{- range $k, $v := .Values.envVarsFrom }}
- name: {{ $k }}
valueFrom:
{{- if $v.configMapKeyRef }}
configMapKeyRef:
name: {{ tpl $v.configMapKeyRef.name $ | quote }}
key: {{ tpl $v.configMapKeyRef.key $ | quote }}
{{- else if $v.secretKeyRef }}
secretKeyRef:
name: {{ tpl $v.secretKeyRef.name $ | quote }}
key: {{ tpl $v.secretKeyRef.key $ | quote }}
{{- end }}
{{- end }}
{{- end }}

{{/*
Render Postgres Init Env values
*/}}
{{- define "spar.postgresInitEnvVars" -}}
{{- range $k, $v := .Values.postgresInit.envVars }}
- name: {{ $k }}
value: {{ tpl $v $ | quote }}
{{- end }}
{{- range $k, $v := .Values.postgresInit.envVarsFrom }}
- name: {{ $k }}
valueFrom:
{{- if $v.configMapKeyRef }}
configMapKeyRef:
name: {{ tpl $v.configMapKeyRef.name $ | quote }}
key: {{ tpl $v.configMapKeyRef.key $ | quote }}
{{- else if $v.secretKeyRef }}
secretKeyRef:
name: {{ tpl $v.secretKeyRef.name $ | quote }}
key: {{ tpl $v.secretKeyRef.key $ | quote }}
{{- end }}
{{- end }}
{{- end }}
50 changes: 2 additions & 48 deletions charts/social-payments-account-registry/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,60 +34,14 @@ spec:
- 'sh'
- '-c'
- 'until pg_isready -U $SPAR_CORE_DB_USERNAME -h $SPAR_CORE_DB_HOSTNAME -p ${SPAR_CORE_DB_PORT:-5432} -d ${SPAR_CORE_DB_DBNAME:-spardb}; do sleep 3; done'
env:
{{- range $k, $v := .Values.envVars }}
- name: {{ $k }}
{{- if and (eq $k "SPAR_CORE_DB_HOSTNAME") (not $v) }}
value: {{ include "postgresql.v1.primary.fullname" $.Subcharts.postgresql }}
{{- else }}
value: {{ $v | quote }}
{{- end }}
{{- end }}
{{- range $k, $v := .Values.envVarsFrom }}
- name: {{ $k }}
{{- if and (eq $k "SPAR_CORE_DB_PASSWORD") (not $v) }}
valueFrom:
secretKeyRef:
name: {{ include "postgresql.v1.primary.fullname" $.Subcharts.postgresql }}
key: password
{{- else }}
{{- toYaml $v | nindent 14 }}
{{- end }}
{{- end }}
env: {{ include "spar.envVars" . | nindent 10 }}
containers:
- name: {{ .Chart.Name }}
securityContext:
{{- toYaml .Values.securityContext | nindent 12 }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
env:
{{- range $k, $v := .Values.envVars }}
- name: {{ $k }}
{{- if and (eq $k "SPAR_CORE_DB_HOSTNAME") (not $v) }}
value: {{ include "postgresql.v1.primary.fullname" $.Subcharts.postgresql }}
{{- else if and (eq $k "SPAR_G2P_CONNECT_QUEUE_REDIS_HOST") (not $v) }}
value: {{ printf "%s-master" (include "common.names.fullname" $.Subcharts.redis) }}
{{- else if and (eq $k "SPAR_G2P_CONNECT_MAPPER_RESOLVE_SENDER_URL") (not $v) }}
value: {{ printf "http://%s/internal/callback/mapper" (include "spar.fullname" $) }}
{{- else if and (eq $k "SPAR_G2P_CONNECT_MAPPER_LINK_SENDER_URL") (not $v) }}
value: {{ printf "http://%s/internal/callback/mapper" (include "spar.fullname" $) }}
{{- else if and (eq $k "SPAR_G2P_CONNECT_MAPPER_UPDATE_SENDER_URL") (not $v) }}
value: {{ printf "http://%s/internal/callback/mapper" (include "spar.fullname" $) }}
{{- else }}
value: {{ $v | quote }}
{{- end }}
{{- end }}
{{- range $k, $v := .Values.envVarsFrom }}
- name: {{ $k }}
{{- if and (eq $k "SPAR_CORE_DB_PASSWORD") (not $v) }}
valueFrom:
secretKeyRef:
name: {{ include "postgresql.v1.primary.fullname" $.Subcharts.postgresql }}
key: password
{{- else }}
{{- toYaml $v | nindent 14 }}
{{- end }}
{{- end }}
env: {{ include "spar.envVars" . | nindent 10 }}
ports:
- name: http
containerPort: {{ .Values.containerPort }}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{{- if .Values.postgresInit.enabled }}
apiVersion: batch/v1
kind: Job
metadata:
name: {{ include "spar.fullname" . }}-postgres-init
labels:
{{- include "spar.labels" . | nindent 4 }}
annotations:
"helm.sh/hook": post-install,post-upgrade
spec:
backoffLimit: {{ .Values.postgresInit.backoffLimit }}
template:
spec:
restartPolicy: {{ .Values.postgresInit.restartPolicy }}
serviceAccountName: {{ include "spar.serviceAccountName" . }}
containers:
- name: postgres-init
image: {{ .Values.postgresInit.image }}
imagePullPolicy: {{ .Values.postgresInit.imagePullPolicy }}
env:
{{ include "spar.envVars" . | nindent 10 }}
{{ include "spar.postgresInitEnvVars" . | nindent 10 }}
command: {{ toYaml .Values.postgresInit.command | nindent 10 }}
{{- end }}
89 changes: 71 additions & 18 deletions charts/social-payments-account-registry/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -75,28 +75,33 @@ tolerations: []
affinity: {}

envVars:
SPAR_CORE_DB_HOSTNAME: "" # Leave blank to take default value
SPAR_CORE_DB_HOSTNAME: '{{ include "postgresql.v1.primary.fullname" .Subcharts.postgresql }}'
SPAR_CORE_DB_USERNAME: "sparuser"
SPAR_CORE_OPENAPI_ROOT_PATH: "/spar/v1"
SPAR_CORE_AUTH_DEFAULT_ISSUERS: '["https://esignet.openg2p.sandbox.net/v1/esignet"]'
SPAR_CORE_AUTH_DEFAULT_JWKS_URLS: '["https://esignet.openg2p.sandbox.mosip.net/v1/esignet/oauth/.well-known/jwks.json"]'
SPAR_G2P_CONNECT_MAPPER_API_TIMEOUT_SECS: "1"
SPAR_G2P_CONNECT_MAPPER_RESOLVE_URL: "http://mapper/v0.1.0/mapper/resolve" # Change to the url according to ID Mapper provider
SPAR_G2P_CONNECT_MAPPER_LINK_URL: "http://mapper/v0.1.0/mapper/link" # Change to the url according to ID Mapper provider
SPAR_G2P_CONNECT_MAPPER_UPDATE_URL: "http://mapper/v0.1.0/mapper/update" # Change to the url according to ID Mapper provider
SPAR_G2P_CONNECT_MAPPER_RESOLVE_SENDER_URL: "" # Leave blank to take default value
SPAR_G2P_CONNECT_MAPPER_LINK_SENDER_URL: "" # Leave blank to take default value
SPAR_G2P_CONNECT_MAPPER_UPDATE_SENDER_URL: "" # Leave blank to take default value
SPAR_G2P_CONNECT_QUEUE_REDIS_HOST: "" # Leave blank to take default value
SPAR_CONNECTOR_G2PCONNECT_MAPPER_API_TIMEOUT_SECS: "1"

# Change to these url according to ID Mapper provider
# Use this for SPAR Mapper
SPAR_CONNECTOR_G2PCONNECT_MAPPER_RESOLVE_URL: "http://mapper/mapper/resolve"
SPAR_CONNECTOR_G2PCONNECT_MAPPER_LINK_URL: "http://mapper/mapper/link"
SPAR_CONNECTOR_G2PCONNECT_MAPPER_UPDATE_URL: "http://mapper/mapper/update"
# Use this for Sunbird Mapper Registry
# SPAR_CONNECTOR_G2PCONNECT_MAPPER_RESOLVE_URL: "http://mapper/v0.1.0/mapper/resolve"
# SPAR_CONNECTOR_G2PCONNECT_MAPPER_LINK_URL: "http://mapper/v0.1.0/mapper/link"
# SPAR_CONNECTOR_G2PCONNECT_MAPPER_UPDATE_URL: "http://mapper/v0.1.0/mapper/update"

SPAR_CONNECTOR_G2PCONNECT_MAPPER_RESOLVE_SENDER_URL: 'http://{{ include "spar.fullname" . }}/internal/callback/mapper'
SPAR_CONNECTOR_G2PCONNECT_MAPPER_LINK_SENDER_URL: 'http://{{ include "spar.fullname" . }}/internal/callback/mapper'
SPAR_CONNECTOR_G2PCONNECT_MAPPER_UPDATE_SENDER_URL: 'http://{{ include "spar.fullname" . }}/internal/callback/mapper'
SPAR_CONNECTOR_G2PCONNECT_QUEUE_REDIS_HOST: '{{ include "common.names.fullname" .Subcharts.redis }}-master'

envVarsFrom:
SPAR_CORE_DB_PASSWORD: {}
# Leave blank to take default value
# SPAR_CORE_DB_PASSWORD:
# valueFrom:
# secretKeyRef:
# name: postgresql
# key: password
SPAR_CORE_DB_PASSWORD:
secretKeyRef:
name: '{{ include "postgresql.v1.primary.fullname" .Subcharts.postgresql }}'
key: password

istio:
enabled: true
Expand Down Expand Up @@ -134,12 +139,60 @@ redis:
auth:
enabled: false

sunbird-rc-g2p-mapper-registry:
# Choose between either of the following mappers. Or disable both if using external mapper.
# Accordingly the URLs above in SPAR_CONNECTOR configs will need to be edited.
# Defaults to SPAR Mapper
spar-g2pconnect-id-mapper:
enabled: true
fullnameOverride: mapper
postgresql:
enabled: false
envVars:
SPAR_G2PCONNECT_MAPPER_DB_HOSTNAME: spar-postgresql # Change this value acc to name of the helm release.
envVarsFrom:
SPAR_G2PCONNECT_MAPPER_DB_PASSWORD:
secretKeyRef:
name: spar-postgresql # Change this value acc to name of the helm release.

sunbird-rc-g2p-mapper-registry:
enabled: false
fullnameOverride: mapper
registry:
fullnameOverride: mapper-registry
elasticsearch:
fullnameOverride: mapper-registry-elasticsearch
postgresql:
fullnameOverride: mapper-registry-postgresql
enabled: false
envVars:
connectionInfo_uri: 'jdbc:postgresql://spar-postgresql:5432/spardb' # Change this value acc to name of the helm release.
connectionInfo_username: sparuser
envVarsFrom:
connectionInfo_password:
secretKeyRef:
name: 'spar-postgresql' # Change this value acc to name of the helm release.
key: password

postgresInit:
enabled: true
image: jbergknoff/postgresql-client
imagePullPolicy: Always
restartPolicy: Never
envVars:
GIT_REPO_URL: 'https://github.com/lalithkota/social-payments-account-registry'
GIT_BRANCH: 'develop'
DEPLOY_DDL: 'false'
envVarsFrom: {}
backoffLimit: 1
command:
- sh
- -c
- >-
sleep 10s;
apk --no-cache add bash gettext git;
export DB_HOST=$SPAR_CORE_DB_HOSTNAME;
export DB_USER=$SPAR_CORE_DB_USERNAME;
export DB_USER_PASSWORD=$SPAR_CORE_DB_PASSWORD;
git_repo_name="$(basename "$GIT_REPO_URL" .git)";
git clone --depth 1 --branch $GIT_BRANCH $GIT_REPO_URL &&
cd $git_repo_name/db_scripts &&
./deploy.sh
Loading

0 comments on commit 1fd465c

Please sign in to comment.