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(thirdparty): add thirdparty support to mojaloop-simulator chart #456

Merged
merged 12 commits into from
Oct 23, 2021
1 change: 1 addition & 0 deletions mojaloop-simulator/.gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# This way you can maintain a values-test.yaml in this repo for testing your changes to the chart,
# without accidentally including it in a packaged chart.
values-test.yaml
tmp.yaml
4 changes: 2 additions & 2 deletions mojaloop-simulator/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
apiVersion: v1
description: "Helm Chart for the Mojaloop (SDK-based) Simulator"
name: mojaloop-simulator
version: 12.2.0
appVersion: "sdk-scheme-adapter: v11.18.8; mojaloop-simulator: v11.4.3"
version: 12.3.0
appVersion: "sdk-scheme-adapter: v11.18.8; mojaloop-simulator: v11.6.1; thirdparty-sdk: v11.55.1"
2 changes: 1 addition & 1 deletion mojaloop-simulator/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ With multiple dictionaries (see the `merge` sprig documentation for more info):
{{- $ctx := . }}
{{- range $_, $container := $ctx.containers -}}
{{/*
Because we need to quote the env vars, we'll print them manually, then print every _other_ key on
Because we need to quote the env vars, we will print them manually, then print every _other_ key on
the init container afterward.
*/}}
- env:
Expand Down
19 changes: 19 additions & 0 deletions mojaloop-simulator/templates/config-thirdparty-sdk.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{{- $RELEASE_NAME := .Release.Name -}}
{{- range $name, $customConfig := .Values.simulators }}
{{- $config := merge $customConfig $.Values.defaults }}
{{- $fullName := printf "%s%s" (include "mojaloop-simulator.prefix" $) $name -}}
{{- if $config.config.thirdpartysdk.enabled }}
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ $fullName }}-thirdparty-sdk-config
labels:
app.kubernetes.io/name: sim-{{ $fullName }}-thirdparty-sdk-config
{{- include "mojaloop-simulator.common-labels" $ | nindent 4 }}
data:
{{- range $k, $v := $config.config.thirdpartysdk.config }}
{{ $k }}: {{ ($v | toPrettyJson | squote | replace "$release_name" $RELEASE_NAME) | replace "$full_name" $fullName | replace "$name" $name }}
{{- end }}
---
{{- end }}
{{- end }}
141 changes: 141 additions & 0 deletions mojaloop-simulator/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -301,4 +301,145 @@ spec:
{{- end }}
---
{{- end }}
{{- if $config.config.thirdpartysdk.enabled }}
apiVersion: {{ template "mojaloop-simulator.apiVersion.Deployment" $ }}
kind: Deployment
metadata:
name: {{ $fullName }}-thirdparty-sdk
labels:
app.kubernetes.io/name: sim-{{ $name }}-thirdparty-sdk
{{- include "mojaloop-simulator.common-labels" $ | nindent 4 }}
spec:
replicas: {{ $config.replicaCount }}
selector:
matchLabels:
app.kubernetes.io/name: sim-{{ $name }}-thirdparty-sdk
app.kubernetes.io/instance: {{ $releaseName }}
template:
metadata:
labels:
app.kubernetes.io/name: sim-{{ $name }}-thirdparty-sdk
{{- include "mojaloop-simulator.common-labels" $ | nindent 8 }}
annotations:
checksum/config-rules: {{ $checksumConfigRules }}
checksum/config-jws-public-keys: {{ $checksumConfigJWSPublicKeys }}
checksum/secrets: {{ $checksumConfigSecrets }}
spec:
volumes:
- name: {{ $fullName }}-thirdparty-sdk-config-volume
configMap:
name: {{ $fullName }}-thirdparty-sdk-config
items:
- key: production.json
path: production.json
initContainers:
{{- if $config.config.initContainers.waitForCache.enabled }}
- name: wait-for-cache
image: "{{ $config.config.cache.image.repository }}:{{ $config.config.cache.image.tag }}"
imagePullPolicy: {{ $config.config.cache.image.pullPolicy }}
command:
- sh
- "-c"
- {{ printf "until redis-cli -h %s -p %v ping; do echo waiting for Redis; sleep 2; done;" $cacheHost $cachePort }}
{{- end }}
{{ include "mojaloop-simulator.prependDictToContainerEnv" (dict "containers" $config.config.thirdpartysdk.initContainers "dict" (merge $config.config.thirdpartysdk.env $initContainerEnv)) | indent 6 }}
containers:
# Inbound container
- name: inbound
image: "{{ $config.config.thirdpartysdk.image.repository }}:{{ $config.config.thirdpartysdk.image.tag }}"
imagePullPolicy: {{ $config.config.thirdpartysdk.image.pullPolicy }}
# TODO: make configurable
command: {{ $config.config.thirdpartysdk.image.inboundCommand }}
ports:
- name: inbound
containerPort: {{ $config.config.thirdpartysdk.env.INBOUND_LISTEN_PORT }}
protocol: TCP
{{- if $config.config.thirdpartysdk.readinessProbe.enabled }}
readinessProbe:
httpGet:
path: /health
port: {{ $config.config.thirdpartysdk.env.INBOUND_LISTEN_PORT }}
scheme: HTTP
{{- end }}
{{- if $config.config.thirdpartysdk.livenessProbe.enabled }}
livenessProbe:
httpGet:
path: /health
port: {{ $config.config.thirdpartysdk.env.INBOUND_LISTEN_PORT }}
scheme: HTTP
{{- end }}
volumeMounts:
- name: {{ $fullName }}-thirdparty-sdk-config-volume
mountPath: /opt/thirdparty-sdk/config/production.json
subPath: production.json
env:
{{- if (not $config.config.thirdpartysdk.env.REDIS_HOST) }}
## We only define this if it is not defined in config.thirdpartysdk.env, otherwise we may have duplicate env values!
- name: REDIS_HOST
value: {{ printf "%s-cache" $fullName }}
{{- end}}
## Map environment values from values.yaml
{{- range $k, $v := $config.config.thirdpartysdk.env }}
- name: {{ $k }}
value: {{ $v | quote | replace "$release_name" $releaseName }}
{{- end }}
resources:
{{ toYaml $config.config.thirdpartysdk.resources | indent 10 }}

# Outbound Container
- name: outbound
image: "{{ $config.config.thirdpartysdk.image.repository }}:{{ $config.config.thirdpartysdk.image.tag }}"
imagePullPolicy: {{ $config.config.thirdpartysdk.image.pullPolicy }}
command: {{ $config.config.thirdpartysdk.image.outboundCommand }}
ports:
- name: outbound
containerPort: {{ $config.config.thirdpartysdk.env.OUTBOUND_LISTEN_PORT }}
protocol: TCP
{{- if $config.config.thirdpartysdk.readinessProbe.enabled }}
readinessProbe:
httpGet:
path: /health
port: {{ $config.config.thirdpartysdk.env.OUTBOUND_LISTEN_PORT }}
scheme: HTTP
{{- end }}
{{- if $config.config.thirdpartysdk.livenessProbe.enabled }}
livenessProbe:
httpGet:
path: /health
port: {{ $config.config.thirdpartysdk.env.OUTBOUND_LISTEN_PORT }}
scheme: HTTP
{{- end }}
volumeMounts:
- name: {{ $fullName }}-thirdparty-sdk-config-volume
mountPath: /opt/thirdparty-sdk/config/production.json
subPath: production.json
env:
{{- if (not $config.config.schemeAdapter.env.REDIS_HOST) }}
## We only define this if it is not defined in config.schemeAdapter.env, otherwise we may have duplicate env values!
- name: REDIS_HOST
value: {{ printf "%s-cache" $fullName }}
{{- end}}
## Map environment values from values.yaml
{{- range $k, $v := $config.config.thirdpartysdk.env }}
- name: {{ $k }}
value: {{ $v | quote | replace "$release_name" $releaseName }}
{{- end }}
resources:
{{ toYaml $config.config.thirdpartysdk.resources | indent 10 }}
imagePullSecrets:
- name: {{ $config.config.imagePullSecretName }}
{{- with $config.nodeSelector }}
nodeSelector:
{{ toYaml . | indent 8 }}
{{- end }}
{{- with $config.affinity }}
affinity:
{{ toYaml . | indent 8 }}
{{- end }}
{{- with $config.tolerations }}
tolerations:
{{ toYaml . | indent 8 }}
{{- end }}
---
{{- end }}
{{ end }}
37 changes: 37 additions & 0 deletions mojaloop-simulator/templates/ingress-thirdparty-sdk.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{{- $apiVersion := include "mojaloop-simulator.apiVersion.Ingress" . -}}
{{- range $name, $customConfig := .Values.simulators }}
{{- $config := merge $customConfig $.Values.defaults }}
{{- $fullName := printf "%s%s" (include "mojaloop-simulator.prefix" $) $name -}}
{{- if $config.config.thirdpartysdk.enabled }}
apiVersion: {{ $apiVersion }}
kind: Ingress
metadata:
name: {{ $fullName }}-thirdparty-sdk-ingress
labels:
app.kubernetes.io/name: sim-{{ $fullName }}-thirdparty-sdk-ingress
{{- include "mojaloop-simulator.common-labels" $ | nindent 4 }}
{{- with $config.ingress.annotations }}
annotations:
{{ toYaml . | indent 4 }}
{{- end }}
spec:
rules:
{{- if $config.ingress.enabled -}}
{{ $hosts := default (list nil) $config.ingress.hosts }}
{{- range $host := $hosts }}
- host: {{ $host }}
http:
paths:
- path: /sim/{{ $name }}/thirdpartysdk/outbound{{ $.Values.ingress.ingressPathRewriteRegex }}
backend:
serviceName: {{ $fullName }}-thirdparty-sdk
servicePort: outbound
- path: /sim/{{ $name }}/thirdpartysdk/inbound{{ $.Values.ingress.ingressPathRewriteRegex }}
backend:
serviceName: {{ $fullName }}-thirdparty-sdk
servicePort: inboundapi
{{- end }}
{{- end }}
---
{{- end }}
{{- end }}
1 change: 1 addition & 0 deletions mojaloop-simulator/templates/ingress.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ spec:
backend:
serviceName: {{ $fullName }}-backend
servicePort: testapi

{{- end }}
{{- end }}
{{- end }}
Expand Down
26 changes: 26 additions & 0 deletions mojaloop-simulator/templates/service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -75,4 +75,30 @@ spec:
app.kubernetes.io/instance: {{ $.Release.Name }}
{{- end }}
---
{{- if $config.config.thirdpartysdk.enabled }}
apiVersion: v1
kind: Service
metadata:
name: {{ $fullName }}-thirdparty-sdk
labels:
app.kubernetes.io/name: sim-{{ $name }}-thirdparty-sdk
{{- include "mojaloop-simulator.common-labels" $ | nindent 4 }}
spec:
type: ClusterIP
ports:
- port: {{ $config.config.thirdpartysdk.env.INBOUND_LISTEN_PORT }}
protocol: TCP
name: inbound
targetPort: inbound
- port: {{ $config.config.thirdpartysdk.env.OUTBOUND_LISTEN_PORT }}
protocol: TCP
name: outbound
targetPort: outbound
selector:
app.kubernetes.io/name: sim-{{ $name }}-thirdparty-sdk
app.kubernetes.io/instance: {{ $.Release.Name }}
{{- end }}

# TODO: thirdparty service!
---
{{ end }}
Loading