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): auth svc charts #452

Merged
merged 9 commits into from
Sep 21, 2021
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 3 additions & 8 deletions ml-testing-toolkit/chart-backend/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -268,14 +268,9 @@ parameters: {}
service:
type: ClusterIP
ports:
specApi:
name: "spec-api"
externalPort: 5000
internalPort: 5000
adminApi:
name: "admin-api"
externalPort: 5050
internalPort: 5050
name: "spec-api"
vijayg10 marked this conversation as resolved.
Show resolved Hide resolved
externalPort: 5000
internalPort: 5000

ingress:
enabled: true
Expand Down
15 changes: 15 additions & 0 deletions thirdparty/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
apiVersion: v1
description: WIP - thirdparty api services for Mojaloop
name: thirdparty
version: 0.1.0
appVersion: "1.0.0"
home: http://mojaloop.io
icon: http://mojaloop.io/images/logo.png
sources:
- https://github.com/mojaloop/mojaloop
- https://github.com/mojaloop/helm
- https://github.com/mojaloop/pisp
maintainers:
- name: Lewis Daly
email: lewisd@crosslaketech.com

8 changes: 8 additions & 0 deletions thirdparty/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# thirdparty

Helm charts for Mojaloop Thirdparty API

## Sub-Charts
- [chart-auth-svc](./chart-auth-svc)
- [chart-consent-oracle](./chart-consent-oracle)
- [chart-tp-api-svc](./chart-tp-api-svc)
15 changes: 15 additions & 0 deletions thirdparty/chart-auth-svc/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
apiVersion: v1
description: auth-svc chart for Mojaloop Thirdparty Overlay Services
name: auth-svc
version: 0.1.0
appVersion: "1.0.0"
home: http://mojaloop.io
icon: http://mojaloop.io/images/logo.png
sources:
- https://github.com/mojaloop/mojaloop
- https://github.com/mojaloop/helm
- https://github.com/mojaloop/auth-service
maintainers:
- name: Lewis Daly
email: lewisd@crosslaketech.com

23 changes: 23 additions & 0 deletions thirdparty/chart-auth-svc/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Auth-Svc

The Auth-Svc is a standalone service that validates and storesThirdparty Consent and
Credential Objects.

It simplifies the Thirdparty API integration for DFSPs by abstracting away common
functions that a DFSP needs to do relating to and validating Consents and their
attached credentials using the `POST /consents` HTTP Request.

DFSPs can also use the Auth-Svc to verify a 3rd party transaction with
`POST /thirdpartyRequests/verifications`, which checks that the stored publicKey for
a credential matches the private key that was used on an end user's device to sign a
transaction.


## Dependencies

This chart has the following dependencies:
- redis
- mysql

See `example_dependencies.yaml` for a simple example of installing and using the chart
with base dependencies.
110 changes: 110 additions & 0 deletions thirdparty/chart-auth-svc/example_dependencies.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
##
# mysql-auth-svc
##

# PersistentVolumeClaim
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: mysql-auth-svc-pv-claim
spec:
storageClassName: awsgp2
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 5Gi
---
## Expose MySQL for Auth-Svc
apiVersion: v1
kind: Service
metadata:
name: mysql-auth-svc
spec:
ports:
- port: 3306
selector:
app: mysql-auth-svc
clusterIP: None
---
## Simple MySQL for Auth-Svc
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: mysql-auth-svc
spec:
selector:
matchLabels:
app: mysql-auth-svc
serviceName: mysql-auth-svc-svc
replicas: 1
template:
metadata:
labels:
app: mysql-auth-svc
spec:
containers:
- image: mysql:5.7
name: mysql-auth-svc
# command: [ '/bin/sh' ]
# args: ['-c', 'tail -f /dev/null']
env:
- name: MYSQL_ROOT_PASSWORD
value: password
- name: MYSQL_USER
value: auth-svc
- name: MYSQL_PASSWORD
value: password
- name: MYSQL_DATABASE
value: auth-svc
- name: NODE_ENV
value: development
ports:
- containerPort: 3306
name: mysql
volumeMounts:
- name: mysql-auth-svc-persistent-storage
mountPath: /var/lib/mysql
volumes:
- name: mysql-auth-svc-persistent-storage
persistentVolumeClaim:
claimName: mysql-auth-svc-pv-claim
---

##
# Auth-Svc Redis
##
apiVersion: apps/v1
kind: Deployment
metadata:
name: auth-svc-redis
labels:
app: auth-svc-redis
spec:
replicas: 1
strategy:
type: RollingUpdate
rollingUpdate:
maxSurge: 1
selector:
matchLabels:
app: auth-svc-redis
template:
metadata:
labels:
app: auth-svc-redis
spec:
containers:
- name: redis
image: redis:5.0.4-alpine
---
apiVersion: v1
kind: Service
metadata:
name: auth-svc-redis-svc
spec:
ports:
- port: 6379
selector:
app: auth-svc-redis
clusterIP: None
48 changes: 48 additions & 0 deletions thirdparty/chart-auth-svc/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
{{/*
Create chart name and version as used by the chart label.
*/}}
{{- define "auth-svc.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}

{{- define "auth-svc.name" -}}
{{- default .Chart.Name | trunc 63 | trimSuffix "-" -}}
{{- end -}}

{{/*
Common labels
*/}}
{{- define "auth-svc.labels" -}}
helm.sh/chart: {{ include "auth-svc.chart" . }}
app.kubernetes.io/name: {{ include "auth-svc.name" . }}
{{ include "auth-svc.selectorLabels" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end }}

{{/*
Selector labels
*/}}
{{- define "auth-svc.selectorLabels" -}}
app.kubernetes.io/name: {{ include "auth-svc.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}


{{- define "apiVersion.Deployment" -}}
{{- if .Capabilities.APIVersions.Has "apps/v1/Deployment" -}}
{{- print "apps/v1" -}}
{{- else -}}
{{- print "apps/v1beta2" -}}
{{- end -}}
{{- end -}}

{{- define "apiVersion.Ingress" -}}
{{- if .Capabilities.APIVersions.Has "networking.k8s.io/v1beta1/Ingress" -}}
{{- print "networking.k8s.io/v1beta1" -}}
{{- else -}}
{{- print "extensions/v1beta1" -}}
{{- end -}}
{{- end -}}
10 changes: 10 additions & 0 deletions thirdparty/chart-auth-svc/templates/configmap.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: "auth-svc-config"
labels:
{{- include "auth-svc.labels" . | nindent 4 }}
data:
{{- range $k, $v := index .Values.config }}
{{ $k }}: {{ ($v | toPrettyJson | squote ) }}
{{- end }}
72 changes: 72 additions & 0 deletions thirdparty/chart-auth-svc/templates/deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
{{- if .Values.enabled -}}
apiVersion: {{ template "apiVersion.Deployment" . }}
kind: Deployment
metadata:
name: {{ include "auth-svc.name" . }}
labels:
{{- include "auth-svc.labels" . | nindent 4 }}
spec:
replicas: {{ .Values.replicaCount }}
strategy:
type: RollingUpdate
rollingUpdate:
maxSurge: 1
selector:
matchLabels:
{{- include "auth-svc.selectorLabels" . | nindent 6 }}
template:
metadata:
labels:
{{- include "auth-svc.selectorLabels" . | nindent 8 }}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be labels not selectorLabels, btw this is also something that needs to be fixed in the ml-operator chart.

selectorLabels should only be used for selectors ;D

spec:
{{- with .Values.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
containers:
- name: {{ .Chart.Name }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
command: {{ .Values.image.command }}
{{- if .Values.readinessProbe.enabled }}
readinessProbe:
httpGet:
path: {{ .Values.readinessProbe.httpGet.path }}
port: {{ .Values.service.ports.internalPort }}
initialDelaySeconds: {{ .Values.readinessProbe.initialDelaySeconds }}
periodSeconds: {{ .Values.readinessProbe.periodSeconds }}
{{- end }}
{{- if .Values.livenessProbe.enabled }}
livenessProbe:
httpGet:
path: {{ .Values.livenessProbe.httpGet.path }}
port: {{ .Values.service.ports.internalPort }}
initialDelaySeconds: {{ .Values.livenessProbe.initialDelaySeconds }}
periodSeconds: {{ .Values.livenessProbe.periodSeconds }}
{{- end }}
volumeMounts:
- name: auth-svc-config-volume
mountPath: /opt/auth-service/config/production.json
subPath: production.json
env:
{{- range $envItem := .Values.env }}
- name: {{ $envItem.name }}
value: {{ $envItem.value }}
{{- end }}
volumes:
- name: auth-svc-config-volume
configMap:
name: auth-svc-config
items:
{{- range $k, $v := index .Values.config }}
Copy link
Member

@mdebarros mdebarros Sep 21, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason that this generally loads all config files, but the above volumeMounts a specific file production.json?

If you are not planning to do something like that, I would just define the config files you need.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, I can do that.

I thought this approach would be more generic, in case we wanted to specify more than one file and be able to switch between them easily. That is similar to the approach we use when switching development environments with convict - see https://github.com/mojaloop/auth-service/tree/master/config for example

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not a fan of that approach, i.e. uploading multiple configurations and selecting the desired one based on the target environment.

I would prefer to be explicit, i.e. if it's the dev environment, then only configure the dev environment configs, etc.

- key: {{ $k }}
path: {{ $k }}
{{- end }}
{{- end -}}
30 changes: 30 additions & 0 deletions thirdparty/chart-auth-svc/templates/ingress.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{{- if index .Values "ingress" "enabled" -}}
apiVersion: {{ template "apiVersion.Ingress" . }}
kind: Ingress
metadata:
name: {{ include "auth-svc.name" . }}-ingress
labels:
{{- include "auth-svc.labels" . | nindent 4 }}
{{- with index .Values "ingress" "annotations" }}
annotations:
{{ toYaml . | indent 4 }}
{{- end }}
spec:
rules:
{{- range $hostType, $service := .Values.ingress.hosts }}
- host: {{ index $service "host" }}
http:
paths:
{{- range $path := (index $service "paths") }}
- path: {{ $path }}
backend:
serviceName: {{ index $service "name" }}
servicePort: {{ index $service "port" }}
{{- end -}}
{{- end -}}
{{- if .Values.ingress.tls }}
tls:
{{ toYaml .Values.ingress.tls | indent 4 }}
{{- end -}}

{{- end }}
17 changes: 17 additions & 0 deletions thirdparty/chart-auth-svc/templates/service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
apiVersion: v1
kind: Service
metadata:
name: {{ include "auth-svc.name" . }}
labels:
app: auth-svc
{{- include "auth-svc.labels" . | nindent 4 }}
spec:
ports:
{{- with .Values.service.ports }}
- port: {{ .externalPort }}
targetPort: {{ .internalPort }}
name: {{ .name }}
{{- end }}
selector:
{{- include "auth-svc.selectorLabels" . | nindent 6 }}
clusterIP: None
Loading