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: deploy portal in abax-vwfs, add abaxvwfs database in abax minuba database instance #344

Closed
wants to merge 9 commits into from
Closed
Show file tree
Hide file tree
Changes from all 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
4 changes: 2 additions & 2 deletions Pulumi.main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ config:
abax-vwfs:abax-client-secret:
secure: AAABACw7CL2RfU5fi7GA3NnyLx9C32vQb+zggY+Xq2Wy5baH+KhutPkNa5ERghESrchdqh4DFoRX7oGnQglfOA==
abax-vwfs:host: abax-vwfs.branches.no
abax-vwfs:tag: main-195814a
abax-vwfs:ui-image: europe-north1-docker.pkg.dev/branches-org-main/branches-org-main/abax-vwfs/ui
abax-vwfs:tag: main-c41fdb6
abax-vwfs:portal-image: europe-north1-docker.pkg.dev/branches-org-main/branches-org-main/abax-vwfs/portal
abax-vwfs:vwfs-api-url: https://cons-fleetextapi.vwfs.se/api
abax-vwfs:vwfs-auth-url: https://idp.cons-common.vwfs.se/
abax-vwfs:vwfs-client-id: f0004c6d-8801-43ee-b18d-d5d17c907182
Expand Down
17 changes: 9 additions & 8 deletions resources/kubernetes/components/standard-database.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,25 +59,25 @@ export interface DatabaseDetails {
* @default 5432
*/
port?: pulumi.Input<number>;
database: pulumi.Input<string>;
databases: pulumi.Input<string>[];
}

export class StandardDatabase extends pulumi.ComponentResource {
readonly databaseName: pulumi.Output<string>;
readonly databaseNames: pulumi.Output<string[]>;
readonly databaseSecretName: pulumi.Output<string>;
readonly serviceHostname: pulumi.Output<string>;
readonly databaseDetails: pulumi.Output<DatabaseDetails>;

constructor(
name: string,
databases: string[],
args: StandardDatabaseArgs = {},
opts?: pulumi.ComponentResourceOptions,
) {
super('branches:k8s:standard-database', name, {}, opts);
const {
team = 'branches',
username = name,
database = name,
sizeInGb = '10Gi',
postgresqlVersion = '15',
numberOfInstances = 1,
Expand Down Expand Up @@ -110,9 +110,10 @@ export class StandardDatabase extends pulumi.ComponentResource {
users: {
[username]: [],
},
databases: {
[database]: username,
},
databases: databases.reduce<Record<string, string>>((acc, db) => {
acc[db] = username;
return acc;
}, {}),
// enableConnectionPooler: true,
allowedSourceRanges: null,
resources: {
Expand All @@ -124,15 +125,15 @@ export class StandardDatabase extends pulumi.ComponentResource {
{ parent: this },
);

this.databaseName = pulumi.output(database);
this.databaseNames = pulumi.output(databases);
this.databaseSecretName = pulumi.interpolate`${username}.${dbCluster.metadata.name}.credentials.postgresql.acid.zalan.do`;
this.serviceHostname = pulumi.interpolate`${dbCluster.metadata.name}.${dbCluster.metadata.namespace}.svc.cluster.local`;

this.databaseDetails = pulumi.output({
secretName: this.databaseSecretName,
hostname: this.serviceHostname,
port: 5432,
database: database,
databases,
});
}
}
10 changes: 9 additions & 1 deletion resources/kubernetes/components/standard-deployment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,11 @@ export interface StandardDeploymentArgs
*/
databaseDetails?: pulumi.Input<DatabaseDetails>;

/**
* The name of the database that the deployment connects to.
*/
database?: pulumi.Input<string>;

/**
* Log level
* @default 'info'
Expand Down Expand Up @@ -229,6 +234,7 @@ export class StandardDeployment extends pulumi.ComponentResource {
args: entrypointArgs = undefined,
volumeMounts = [],
securityContext = undefined,
database,
} = args;

const publicPort = ports.find(p => p.name === 'public');
Expand Down Expand Up @@ -280,7 +286,9 @@ export class StandardDeployment extends pulumi.ComponentResource {
details =>
`postgres://$(POSTGRES_username):$(POSTGRES_password)@${
details.hostname
}:${details.port ?? 5432}/${details.database}?sslmode=require`,
}:${details.port ?? 5432}/${
database?.toString() ?? details.databases[0]
}?sslmode=require`,
),
});
}
Expand Down
1 change: 1 addition & 0 deletions resources/kubernetes/deployments/abax-minuba.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const config = new pulumi.Config('abax-minuba');

export const abaxMinubaDb = new StandardDatabase(
'abax-minuba',
['abaxminuba', 'abaxvwfs'],
{
username: 'abaxminuba',
database: 'abaxminuba',
Expand Down
17 changes: 14 additions & 3 deletions resources/kubernetes/deployments/abax-vwfs.ts
Original file line number Diff line number Diff line change
@@ -1,23 +1,34 @@
import * as pulumi from '@pulumi/pulumi';
import { StandardDeployment } from '../components/standard-deployment';
import { provider } from '../provider';
import { abaxMinubaDb } from './abax-minuba';

const config = new pulumi.Config('abax-vwfs');

export const standardDeployment = new StandardDeployment(
'abax-vwfs',
{
image: config.require('ui-image'),
image: config.require('portal-image'),
tag: config.require('tag'),
host: config.require('host'),
secretEnv: {
DB_HOST: config.require('db-host'),
DB_PASSWORD: config.requireSecret('db-password'),
DB_USER: config.requireSecret('db-user'),
DB_PORT: config.require('db-port'),
DB_DATABASE: config.require('db-database'),
ABAX_CLIENT_ID: config.requireSecret('abax-client-id'),
ABAX_CLIENT_SECRET: config.requireSecret('abax-client-secret'),
VWFS_CLIENT_ID: config.require('vwfs-client-id'),
VWFS_CLIENT_SECRET: config.requireSecret('vwfs-client-secret'),
VWFS_AUTH_URL: config.require('vwfs-auth-url'),
VWFS_API_URL: config.require('vwfs-api-url'),
ABAX_CLIENT_ID: config.requireSecret('abax-client-id'),
ABAX_CLIENT_SECRET: config.requireSecret('abax-client-secret'),
SIGN_SECRET: config.requireSecret('sign-secret'),
SELF_URL: config.require('self-url'),
LOG_LEVEL: config.require('log-level'),
},
databaseDetails: abaxMinubaDb.databaseDetails,
database: 'abaxvwfs',
},
{ providers: [provider] },
);
1 change: 1 addition & 0 deletions resources/kubernetes/deployments/matrix.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ const databaseName = 'matrix';

export const synapseDatabase = new StandardDatabase(
'matrix-db',
['matrix-synapse'],
{
username: databaseUser,
database: databaseName,
Expand Down