Skip to content

Commit 2dbb7d6

Browse files
committed
feat: new minuba setup
1 parent a10fcaf commit 2dbb7d6

File tree

2 files changed

+225
-0
lines changed

2 files changed

+225
-0
lines changed

stacks/abax-minuba/Pulumi.prod.yaml

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
config:
2+
abax:client-id:
3+
secure: AAABAKk4157pwBBVsoW9bub4gHC/jeS/+OZ8VLMgGxz2W6aRb5RVbg/fIvu4HtnODlGKJ9PP+Vqc6iyTivtIyg==
4+
abax:client-secret:
5+
secure: AAABAF/kuvtrSu2dw6axE4N1MK3KaaOC3WEYbP4+dQGJ1SZ48RPH+bUb5/53GO8ceRH4JQKcSBLGIniuGNuhlw==
6+
agent:image: blabla
7+
agent:tag: blabla
8+
kubernetes:namespace: abax-minuba
9+
minuba:api-key:
10+
secure: AAABAN4qomcASPDtdx+4m3qU6BbDNCeMDoUzh5AK6jggoGyoGG+UQYEv0qL1yyI75oPW9r5HDQati8qx+btmWA==
11+
ui:host: am.branches.no
12+
ui:image: blabla
13+
ui:tag: blabla
14+
environment:
15+
- kubernetes
16+
- common
17+
- database

stacks/abax-minuba/Pulumi.yaml

+208
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,208 @@
1+
name: abax-minuba
2+
runtime: yaml
3+
description: Common Unleash server
4+
5+
variables:
6+
appLabels:
7+
app: ${pulumi.project}-${pulumi.stack}
8+
9+
resources:
10+
namespace:
11+
type: kubernetes:core/v1:Namespace
12+
properties:
13+
metadata:
14+
name: ${pulumi.project}-${pulumi.stack}
15+
# A database in the common database instance to be used for the Abax Minuba integration
16+
database:
17+
type: gcp:sql/database:Database
18+
properties:
19+
name: abax-minuba
20+
instance: ${database:instanceName}
21+
databasePassword:
22+
type: random:RandomPassword
23+
properties:
24+
length: 16
25+
special: true
26+
overrideSpecial: '_%@'
27+
# A user in the common database instance to be used for the Abax Minuba integration
28+
databaseUser:
29+
type: gcp:sql/user:User
30+
properties:
31+
name: abax-minuba
32+
instance: ${database:instanceName}
33+
password: ${databasePassword.result}
34+
# A set of kubernetes secrets to be used by apps that need to connect to the database
35+
databaseSecret:
36+
type: kubernetes:core/v1:Secret
37+
properties:
38+
metadata:
39+
name: ${pulumi.project}-${pulumi.stack}-database
40+
namespace: ${namespace.metadata.name}
41+
stringData:
42+
DATABASE_NAME: ${database.name}
43+
DATABASE_USERNAME: ${databaseUser.name}
44+
DATABASE_PASSWORD: ${databasePassword.result}
45+
DATABASE_URL: postgres://${databaseUser.name}:${databasePassword.result}@$localhost:$5432/${database.name}
46+
serviceAccount:
47+
type: kubernetes:core/v1:ServiceAccount
48+
properties:
49+
metadata:
50+
name: ${pulumi.project}-${pulumi.stack}
51+
namespace: ${namespace.metadata.name}
52+
annotations:
53+
'iam.gke.io/gcp-service-account': ${database:serviceAccountEmail}
54+
serviceAccountIamBinding:
55+
type: gcp:serviceaccount:IAMBinding
56+
properties:
57+
serviceAccountId: ${database:serviceAccountId}
58+
role: roles/iam.workloadIdentityUser
59+
members:
60+
- serviceAccount:${gcp:project}.svc.id.goog[${namespace.metadata.name}/${serviceAccount.metadata.name}]
61+
62+
# Secrets for connecting to ABAX API
63+
abaxClientSecret:
64+
type: kubernetes:core/v1:Secret
65+
properties:
66+
metadata:
67+
name: ${pulumi.project}-${pulumi.stack}-abax-client-secret
68+
namespace: ${namespace.metadata.name}
69+
stringData:
70+
ABAX_CLIENT_ID: ${abax:client-id}
71+
ABAX_CLIENT_SECRET: ${abax:client-secret}
72+
73+
# Secrets for connecting to Minuba API
74+
minubaApiKeySecret:
75+
type: kubernetes:core/v1:Secret
76+
properties:
77+
metadata:
78+
name: ${pulumi.project}-${pulumi.stack}-minuba-api-key
79+
namespace: ${namespace.metadata.name}
80+
stringData:
81+
MINUBA_API_KEY: ${minuba:api-key}
82+
83+
# Cronjob for running the agent, which synchronises data between ABAX and Minuba
84+
cronjob:
85+
type: kubernetes:batch/v1:CronJob
86+
properties:
87+
metadata:
88+
name: abax-minuba-agent
89+
annotations:
90+
'pulumi.com/skipAwait': 'true'
91+
spec:
92+
schedule: '*/30 * * * *' # every 30 minutes
93+
jobTemplate:
94+
spec:
95+
template:
96+
spec:
97+
restartPolicy: OnFailure
98+
containers:
99+
- name: ${pulumi.project}-${pulumi.stack}-cronjob
100+
image: ${agent:image}:${agent:tag}
101+
envFrom:
102+
- secretRef:
103+
name: ${databaseSecret.metadata.name}
104+
- secretRef:
105+
name: ${abaxClientSecret.metadata.name}
106+
- secretRef:
107+
name: ${minubaApiKeySecret.metadata.name}
108+
env:
109+
- name: NODE_ENV
110+
value: production
111+
- name: LOG_LEVEL
112+
value: debug
113+
114+
# Deployment for the UI, where users can configure the integration
115+
deployment:
116+
type: kubernetes:apps/v1:Deployment
117+
properties:
118+
metadata:
119+
name: ${pulumi.project}-${pulumi.stack}
120+
namespace: ${namespace.metadata.name}
121+
annotations:
122+
pulumi.com/skipAwait: 'true'
123+
pulumi.com/patchForce: 'true'
124+
spec:
125+
replicas: 1
126+
selector:
127+
matchLabels: ${appLabels}
128+
template:
129+
metadata:
130+
labels: ${appLabels}
131+
spec:
132+
serviceAccountName: ${serviceAccount.metadata.name}
133+
nodeSelector:
134+
'iam.gke.io/gke-metadata-server-enabled': 'true'
135+
initContainers:
136+
- name: migrate
137+
image: ${agent:image}:${agent:tag}
138+
imagePullPolicy: IfNotPresent
139+
command:
140+
- pnpm
141+
- run
142+
- db:migrate:deploy
143+
envFrom:
144+
- secretRef:
145+
name: ${databaseSecret.metadata.name}
146+
- secretRef:
147+
name: ${abaxClientSecret.metadata.name}
148+
- secretRef:
149+
name: ${minubaApiKeySecret.metadata.name}
150+
env:
151+
- name: NODE_ENV
152+
value: production
153+
- name: LOG_LEVEL
154+
value: debug,
155+
containers:
156+
- name: app
157+
image: ${ui:image}:${ui:tag}
158+
ports:
159+
- containerPort: 8484
160+
envFrom:
161+
- secretRef:
162+
name: ${databaseSecret.metadata.name}
163+
- secretRef:
164+
name: ${abaxClientSecret.metadata.name}
165+
env:
166+
- name: SELF_URL
167+
value: https://${ui:host}
168+
- name: cloud-sql-proxy
169+
image: gcr.io/cloud-sql-connectors/cloud-sql-proxy:2.8.0
170+
args:
171+
- --structured-logs=true
172+
- --port=5432
173+
- ${database:connectionName}
174+
securityContext:
175+
runAsNonRoot: true
176+
177+
service:
178+
type: kubernetes:core/v1:Service
179+
properties:
180+
metadata:
181+
name: ${pulumi.project}-${pulumi.stack}
182+
namespace: ${namespace.metadata.name}
183+
spec:
184+
selector: ${appLabels}
185+
ports:
186+
- port: 8484
187+
targetPort: 8484
188+
ingress:
189+
type: kubernetes:networking.k8s.io/v1:Ingress
190+
properties:
191+
metadata:
192+
name: ${pulumi.project}-${pulumi.stack}
193+
namespace: ${namespace.metadata.name}
194+
annotations:
195+
pulumi.com/skipAwait: 'true'
196+
kubernetes.io/ingress.class: 'caddy'
197+
spec:
198+
rules:
199+
- host: ${ui:host}
200+
http:
201+
paths:
202+
- path: /
203+
pathType: Prefix
204+
backend:
205+
service:
206+
name: ${pulumi.project}-${pulumi.stack}
207+
port:
208+
number: 8484

0 commit comments

Comments
 (0)