feat: Add AWS CDK project and Helm charts for Beckn-Onix deployment on AWS cloud

This commit is contained in:
Mozammil Khan
2024-09-23 22:57:34 +05:30
parent 5d5e363ccd
commit c683ec3d74
114 changed files with 10018 additions and 0 deletions

View File

@@ -0,0 +1,9 @@
Get the Beckn-ONIX Gateway URL by running these commands:
{{- if .Values.ingress.enabled }}
export INGRESS_HOST=$(kubectl get ingress {{ include "common.name" . }}-ingress -n {{ .Values.namespace }} -o jsonpath="{.status.loadBalancer.ingress[0].hostname}"){{ "\n" }}
{{- if .Values.ingress.tls.enabled }}
echo "https://$INGRESS_HOST"{{ "\n" }}
{{- else }}
echo "http://$INGRESS_HOST"{{ "\n" }}
{{- end }}
{{- end }}

View File

@@ -0,0 +1,75 @@
{{/*
Expand the name of the chart or use a provided override.
*/}}
{{- define "common.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
{{- end }}
{{/*
Create a default fully qualified app name, with truncation to 63 characters.
*/}}
{{- define "common.fullname" -}}
{{- if .Values.fullnameOverride }}
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- $name := default .Chart.Name .Values.nameOverride }}
{{- if contains $name .Release.Name }}
{{- .Release.Name | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
{{- end }}
{{- end }}
{{- end }}
{{/*
Generate a chart name and version label.
*/}}
{{- define "common.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}
{{/*
Common labels to be used in all charts.
*/}}
{{- define "common.labels" -}}
helm.sh/chart: {{ include "common.chart" . }}
{{ include "common.selectorLabels" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
app.kubernetes.io/release: {{ .Release.Revision | quote }}
{{- end }}
{{/*
Common selector labels.
*/}}
{{- define "common.selectorLabels" -}}
app.kubernetes.io/name: {{ include "common.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}
{{/*
Helper for creating service account names.
*/}}
{{- define "common.serviceAccountName" -}}
{{- if .Values.serviceAccount.create }}
{{- default (include "common.fullname" .) .Values.serviceAccount.name }}
{{- else }}
{{- default "default" .Values.serviceAccount.name }}
{{- end }}
{{- end }}
{{/*
Helper for image names and tags.
*/}}
{{- define "common.image" -}}
{{ printf "%s:%s" .Values.image.repository .Values.image.tag }}
{{- end }}
{{/*
Helper for constructing resource names with prefixes or suffixes.
*/}}
{{- define "common.resourceName" -}}
{{- printf "%s-%s" (include "common.fullname" .) .Values.suffix | trunc 63 | trimSuffix "-" }}
{{- end }}

View File

@@ -0,0 +1,18 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ include "common.name" . }}-onixjson-config
namespace: {{ .Values.namespace }}
data:
onix.json: |
{
"core_version": "1.1.0",
"registry_id": "{{ .Values.registry_url | default "localhost" | replace "http://" "" | replace "https://" "" }}..LREG",
"search_provider_id": "{{ .Values.externalDomain }}",
"self_registration_supported": true,
"subscription_needed_post_registration": true,
"base_url": "{{ .Values.registry_url | default "localhost" }}",
"registry_url": "{{ .Values.registry_url | default "localhost" }}/subscribers",
"extension_package": "in.succinct.beckn.boc",
"wild_card": ""
}

View File

@@ -0,0 +1,34 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ include "common.name" . }}-config
namespace: {{ .Values.namespace }}
data:
swf.properties: |
swf.load.complete.config.tables.if.count.less.than=500
swf.user.password.encrypted=false
swf.plugins.background.core.workers.numThreads=3
swf.application.authentication.required=false
swf.application.requires.registration=true
swf.host={{ .Values.externalDomain }}
swf.external.port=443
swf.external.scheme=https
swf.jdbc.dbschema=public
swf.jdbc.dbschema.setonconnection=true
swf.jdbc.set.dbschema.command=set search_path to 'public'
swf.jdbc.url=jdbc:postgresql://{{ .Values.database.host }}/{{ .Values.database.dbname }}
swf.jdbc.driver=org.postgresql.Driver
swf.jdbc.userid={{ .Values.database.username }}
swf.jdbc.password={{ .Values.database.password }}
swf.jdbc.readOnly=false
swf.api.keys.case=SNAKE
swf.api.root.required=false
swf.encryption.support=false
swf.ftl.dir=src/main/resources/templates
beckn.auth.enabled=true
in.succinct.beckn.gateway.subscriber_id={{ .Values.externalDomain }}
in.succinct.beckn.gateway.public_key_id={{ .Values.externalDomain }}.k1
in.succinct.onet.country.iso.3=IND
in.succinct.onet.country.iso.2=IN
in.succinct.onet.name=onix

View File

@@ -0,0 +1,70 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "common.name" . }}
namespace: {{ .Values.namespace }}
labels:
{{- include "common.labels" . | nindent 4 }}
spec:
{{- if not .Values.autoscaling.enabled }}
replicas: {{ .Values.replicaCount }}
{{- end }}
selector:
matchLabels:
{{- include "common.selectorLabels" . | nindent 6 }}
template:
metadata:
annotations:
{{- with .Values.podAnnotations }}
{{- toYaml . | nindent 8 }}
{{- end }}
labels:
{{- include "common.labels" . | nindent 8 }}
{{- with .Values.podLabels }}
{{- toYaml . | nindent 8 }}
{{- end }}
spec:
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
serviceAccountName: {{ include "common.serviceAccountName" . }}
securityContext:
{{- toYaml .Values.podSecurityContext | nindent 8 }}
containers:
- name: {{ .Chart.Name }}
image: {{ .Values.image.repository }}
imagePullPolicy: {{ .Values.image.pullPolicy }}
ports:
- name: gateway-port
containerPort: {{ .Values.service.port }}
protocol: TCP
- name: sec-gtw-port
containerPort: {{ .Values.service.secondaryPort }}
protocol: TCP
{{- if .Values.livenessProbe }}
livenessProbe:
{{- toYaml .Values.livenessProbe | nindent 12 }}
{{- end }}
{{- if .Values.readinessProbe }}
readinessProbe:
{{- toYaml .Values.readinessProbe | nindent 12 }}
{{- end }}
resources:
{{- toYaml .Values.resources | nindent 12 }}
volumeMounts:
- name: gateway-config
mountPath: "/gateway/overrideProperties/config/swf.properties"
subPath: swf.properties
readOnly: true
- name: onixjson-config
mountPath: "/gateway/overrideProperties/config/networks/onix.json"
subPath: onix.json
readOnly: true
volumes:
- name: gateway-config
configMap:
name: {{ include "common.name" . }}-config
- name: onixjson-config
configMap:
name: {{ include "common.name" . }}-onixjson-config

View File

@@ -0,0 +1,32 @@
{{- if .Values.ingress.enabled }}
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: {{ include "common.name" . }}-ingress
namespace: {{ .Values.namespace }}
labels:
{{- include "common.labels" . | nindent 4 }}
annotations:
alb.ingress.kubernetes.io/scheme: internet-facing
alb.ingress.kubernetes.io/listen-ports: '[{"HTTP": 80}, {"HTTPS": 443}]'
alb.ingress.kubernetes.io/ssl-policy: ELBSecurityPolicy-TLS-1-1-2017-01
alb.ingress.kubernetes.io/certificate-arn: {{ .Values.ingress.tls.certificateArn | quote }}
alb.ingress.kubernetes.io/ssl-redirect: '443'
alb.ingress.kubernetes.io/group.name: beckn-onix-gateway
alb.ingress.kubernetes.io/load-balancer-name: beckn-onix-gateway
alb.ingress.kubernetes.io/target-group-attributes: stickiness.enabled=true,stickiness.lb_cookie.duration_seconds=300
alb.ingress.kubernetes.io/target-type: ip
alb.ingress.kubernetes.io/success-codes: 200,302
spec:
ingressClassName: alb
rules:
- http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: {{ include "common.name" . }}-svc
port:
number: {{ .Values.service.port }}
{{- end }}

View File

@@ -0,0 +1,6 @@
apiVersion: v1
kind: Namespace
metadata:
name: {{ .Values.namespace }}
labels:
{{- include "common.labels" . | nindent 4 }}

View File

@@ -0,0 +1,16 @@
apiVersion: v1
kind: Service
metadata:
name: {{ include "common.name" . }}-svc
namespace: {{ .Values.namespace }}
labels:
{{- include "common.labels" . | nindent 4 }}
spec:
type: {{ .Values.service.type }}
ports:
- port: {{ .Values.service.port }}
targetPort: gateway-port
protocol: TCP
name: http
selector:
{{- include "common.selectorLabels" . | nindent 4 }}

View File

@@ -0,0 +1,14 @@
{{- if .Values.serviceAccount.create -}}
apiVersion: v1
kind: ServiceAccount
metadata:
name: {{ include "registry.serviceAccountName" . }}
namespace: {{- toYaml .Values.namespace | nindent 2 }}
labels:
{{- include "registry.labels" . | nindent 4 }}
{{- with .Values.serviceAccount.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
automountServiceAccountToken: {{ .Values.serviceAccount.automount }}
{{- end }}