Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add merchant registry helm charts #598

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ Mojaloop Helm deployments currently include the following provisioning (`setup`)

1. Add the following to your hosts file and ensure you have installed Ingress Controller on your Kubernetes Cluster:

`<ip-of-k8s-node-ingress> ml-api-adapter.local central-ledger.local account-lookup-service.local quoting-service.local central-settlement.local moja-simulator.local testing-toolkit.local testing-toolkit-specapi.local`
`<ip-of-k8s-node-ingress> ml-api-adapter.local central-ledger.local account-lookup-service.local quoting-service.local central-settlement.local moja-simulator.local testing-toolkit.local testing-toolkit-specapi.local www.acquirer-merchant.local`

2. Curl Health End-points for ML-API-Adapter

Expand Down
1 change: 1 addition & 0 deletions lint-charts.sh
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ else
mojaloop-bulk/
mojaloop-simulator
mojaloop
merchant-registry-svc
# kube-system/ntpd/ # Deprecated - No longer supported
ml-operator
thirdparty/chart-auth-svc
Expand Down
26 changes: 26 additions & 0 deletions merchant-registry-svc/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
apiVersion: v2
name: merchant-registry
type: application
version: 1.0.1
appVersion: "1.0.1"
description: Merchant Registry Helm chart for Kubernetes

dependencies:
- name: chart-acquirer-backend
version: ">= 1.0.0"
repository: file://./chart-acquirer-backend
- name: chart-acquirer-frontend
version: ">= 1.0.0"
repository: file://./chart-acquirer-frontend
- name: chart-merchant-db
version: ">= 1.0.0"
repository: file://./chart-merchant-db
- name: chart-minio
version: ">= 1.0.0"
repository: file://./chart-minio
- name: chart-rabbitmq
version: ">= 1.0.0"
repository: file://./chart-rabbitmq
- name: chart-registry-oracle
version: ">= 1.0.0"
repository: file://./chart-registry-oracle
96 changes: 96 additions & 0 deletions merchant-registry-svc/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
## Merchant Registry Helm Charts Deployment

### Default Ingress DNS (add following records to the `/etc/hosts` file)

- `<ip-of-k8s-node-ingress> www.acquirer-merchant.local`

### Prerequisites

- Kubernetes cluster
- Helm 3
- SendGrid API Key (for sending verification emails)

- Update the `sendgridApiKey` in the `./chart-acquirer-backend/values.yaml`
- Update the `senderEmail` in the `./chart-acquirer-backend/values.yaml`

- Register for Google reCAPTCHA v2 and Add Ingress Domain
- https://www.google.com/recaptcha/admin/create
- Update the `./chart-acquirer-backend/values.yaml` file with the following values:
- `recaptchaBackendSiteKey`
- Update the `./chart-acquirer-frontend/values.yaml` file with the following values:
- `recaptchaFrontendSiteKey`

### Deploying the Helm Charts

Note For Production: Recommended to use external Third Party S3 Services (like Amazon S3, Digital Ocean Space etc.) for storing the documents and QR Images instead of the MinIO S3 instance service.
See the [`./chart-acquirer-backend/values.yaml`](./chart-acquirer-backend/values.yaml) for the configuration.

1. Build Dependency Chart

```bash
helm dep up ./
```

2. Install the Helm chart:

```bash
helm install merchant ./ --namespace mojaloop
```

### Registering Merchant Oracle in Account Lookup Service

1. Make sure the `account-lookup-service-admin` is running and accessible.
2. Make sure the `merchant-registry-oracle-clusterip-service` is accessible from the `account-lookup-service-admin` pod.
3. Run the following command to register the merchant oracle with `ALIAS` type:

Replace `<account-lookup-service-admin-ip>` and `<merchant-registry-oracle-clusterip-service>` with the Cluster IP Addresses.
`kubectl get svc -n mojaloop` can be used to get the Cluster IP Addresses.


```bash
curl -X POST "http://<account-lookup-service-admin-ip>/oracles" \
-H "accept: application/json" -H "Content-Type: application/json" \
-d '{
"oracleIdType": "ALIAS",
"endpoint": {
"value": "<merchant-registry-oracle-clusterip-service>:8888",
"endpointType": "URL"
},
"currency": "USD",
"isDefault": true
}'
```

4. Verify the registration by running the following command:

```bash
curl -X GET "http://<account-lookup-service-admin-ip>/oracles" \
-H "accept: application/json" \
-H "Content-Type: application/json" \
-H "date: $(date -Ru)"
```

should return the registered oracle.
```json
[
{
"oracleId":1,
"oracleIdType":"ALIAS",
"endpoint":{
"value":"10.43.83.251:8888",
"endpointType":"URL"
},
"currency":"USD",
"isDefault":1
}
]
```

### IMPORTANT NOTES:

When updating ingress's host make sure to update the `apiUrl` of `./chart-acquirer-frontend/values.yaml` file too.
Otherwise frontend will not be able to communicate with backend.

The system utilize RabbitMQ for message queuing between services and SendGrid for email verification.
Adopters can substitute these services with their preferred choices for a customized integration.

23 changes: 23 additions & 0 deletions merchant-registry-svc/chart-acquirer-backend/.helmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# 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
*.orig
*~
# Various IDEs
.project
.idea/
*.tmproj
.vscode/
6 changes: 6 additions & 0 deletions merchant-registry-svc/chart-acquirer-backend/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
apiVersion: v2
name: chart-acquirer-backend
description: A Helm chart for Kubernetes
type: application
version: 1.0.0
appVersion: "1.0.1"
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ .Release.Name }}-acquirer-backend-deployment
spec:
replicas: {{ .Values.acquirerBackend.replicaCount }}
selector:
matchLabels:
component: acquirer-backend
template:
metadata:
labels:
component: acquirer-backend
spec:
automountServiceAccountToken: false
containers:
- name: acquirer-backend
Fixed Show fixed Hide fixed
Fixed Show fixed Hide fixed
image: "{{ .Values.acquirerBackend.image.repository }}:{{ .Values.acquirerBackend.image.tag }}"
ports:
- containerPort: {{ .Values.acquirerBackend.service.port }}
resources:
{{- toYaml .Values.resources | nindent 12 }}
env:
- name: APP_URL # for email redirect verification
value: "{{ .Values.acquirerBackend.env.appURL }}"
- name: FRONTEND_SET_PASSWORD_URL
value: "{{ .Values.acquirerBackend.env.frontendSetPasswordRedirectURL }}"
- name: RECAPTCHA_SECRET_KEY
value: "{{ .Values.acquirerBackend.env.recaptchaBackendSiteKey }}"
- name: DB_HOST
value: "{{ .Release.Name }}-{{ .Values.acquirerBackend.env.dbHost }}"
- name: DB_PORT
value: "{{ .Values.acquirerBackend.env.dbPort }}"
- name: DB_DATABASE
value: "{{ .Values.acquirerBackend.env.database }}"
- name: DB_USERNAME
value: "{{ .Values.acquirerBackend.env.dbUsername }}"
- name: DB_PASSWORD
valueFrom:
secretKeyRef:
name: {{ .Release.Name }}-merchant-db-secret
key: mysql-root-password
- name: SENDGRID_API_KEY
value: "{{ .Values.acquirerBackend.env.sendgridApiKey }}"
- name: SENDER_EMAIL
value: "{{ .Values.acquirerBackend.env.senderEmail }}"

- name: S3_ENDPOINT
value: "{{ .Release.Name }}-{{ .Values.acquirerBackend.env.s3Endpoint }}"

- name: RABBITMQ_HOST
value: "{{ .Release.Name }}-{{ .Values.acquirerBackend.env.rabbitmqHost }}"
- name: RABBITMQ_PORT
value: "{{ .Values.acquirerBackend.env.rabbitmqPort }}"
- name: RABBITMQ_USERNAME
value: "{{ .Values.acquirerBackend.env.rabbitmqUsername }}"
- name: RABBITMQ_PASSWORD
value: "{{ .Values.acquirerBackend.env.rabbitmqPassword }}"
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
apiVersion: v1
kind: Service
metadata:
name: {{ .Release.Name}}-acquirer-backend-clusterip-service
spec:
type: {{ .Values.acquirerBackend.service.type }}
selector:
component: acquirer-backend
ports:
- port: {{ .Values.acquirerBackend.service.port }}
targetPort: {{ .Values.acquirerBackend.service.port }}
37 changes: 37 additions & 0 deletions merchant-registry-svc/chart-acquirer-backend/values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# Default values for acquirer-backend.
# This is a YAML-formatted file.
# Declare variables to be passed into your templates.

acquirerBackend:
replicaCount: 1
image:
repository: mojaloop/merchant-acquirer-backend
tag: 1.0.1
service:
type: ClusterIP
port: 5555
env:
dbHost: merchant-db-clusterip-service
dbPort: "3306"
database: acquirer_db
dbUsername: root
# db password will be fetched from k8s secret object

rabbitmqHost: rabbitmq-clusterip-service
rabbitmqPort: "5672"
rabbitmqUsername: guest
rabbitmqPassword: guest
sendgridApiKey: "YOUR_SENDGIRD_API_KEY" # 3rd Party Email Service
senderEmail: "[email protected]"
s3Endpoint: minio-clusterip-service
appURL: "http://www.acquirer-merchant.local" # for email verification backend link
frontendSetPasswordRedirectURL: "http://www.acquirer-merchant.local/set-password" # reset password link after email verification
recaptchaBackendSiteKey: "6LcEfT4pAAAAAF9a9PgebViC87aRPsd10JQDalNy"

resources:
requests:
cpu: "200m"
memory: "256Mi"
limits:
cpu: "1000m"
memory: "512Mi"
23 changes: 23 additions & 0 deletions merchant-registry-svc/chart-acquirer-frontend/.helmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# 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
*.orig
*~
# Various IDEs
.project
.idea/
*.tmproj
.vscode/
6 changes: 6 additions & 0 deletions merchant-registry-svc/chart-acquirer-frontend/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
apiVersion: v2
name: chart-acquirer-frontend
description: A Helm chart for Kubernetes
type: application
version: 1.0.0
appVersion: "1.0.1"
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ .Release.Name }}-acquirer-frontend-deployment
spec:
replicas: {{ .Values.acquirerFrontend.replicaCount }}
selector:
matchLabels:
component: acquirer-frontend
template:
metadata:
labels:
component: acquirer-frontend
spec:
automountServiceAccountToken: false
containers:
- name: acquirer-frontend
Fixed Show fixed Hide fixed
Fixed Show fixed Hide fixed
image: "{{ .Values.acquirerFrontend.image.repository }}:{{ .Values.acquirerFrontend.image.tag }}"
ports:
- containerPort: {{ .Values.acquirerFrontend.service.port }}
resources:
{{- toYaml .Values.resources | nindent 12 }}
env:
- name: VITE_API_URL
value: "{{ .Values.acquirerFrontend.env.apiURL }}"
- name: VITE_PORT
value: "{{ .Values.acquirerFrontend.service.port }}"
- name: VITE_RECAPTCHA_SITE_KEY
value: {{ .Values.acquirerFrontend.env.recaptchaFrontendSiteKey }}

Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
apiVersion: v1
kind: Service
metadata:
name: {{ .Release.Name }}-acquirer-frontend-clusterip-service
spec:
type: {{ .Values.acquirerFrontend.service.type }}
selector:
component: acquirer-frontend
ports:
- port: {{ .Values.acquirerFrontend.service.port }}
targetPort: {{ .Values.acquirerFrontend.service.port }}
24 changes: 24 additions & 0 deletions merchant-registry-svc/chart-acquirer-frontend/values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Default values for acquirer-frontend.
# This is a YAML-formatted file.
# Declare variables to be passed into your templates.

acquirerFrontend:
replicaCount: 1
image:
repository: mojaloop/merchant-acquirer-frontend
tag: 1.0.1
service:
type: ClusterIP
port: 5173
env:
apiURL: "http://www.acquirer-merchant.local/api/v1"
recaptchaFrontendSiteKey: "6LcEfT4pAAAAAAONtUPIQYSoYvNSbvKiexaZLo4R"

resources:
requests:
cpu: "50m"
memory: "128Mi"
limits:
cpu: "200m"
memory: "256Mi"

Loading