-
Notifications
You must be signed in to change notification settings - Fork 0
/
postgres.bitnami.ts
49 lines (45 loc) · 1.68 KB
/
postgres.bitnami.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
import { Construct } from 'constructs';
import { Helm } from 'cdk8s';
export class PGBitnamiChart extends Construct {
public readonly dbServiceName: string;
constructor(scope: Construct, id: string) {
super(scope, id);
const dbname = 'plone';
const dbuser = 'plone';
const dbpass = 'admin@plone';
const db = new Helm(this, 'db', {
chart: 'postgresql',
repo: 'https://charts.bitnami.com/bitnami',
// XXX: in fact I do not want a namespace here.
// I want to use the passed in with kubectl apply.
// need to figure out how to achieve this. Could be bitnami specific.
namespace: 'plone',
values: {
'commonLabels': { 'app.kubernetes.io/part-of': 'plone' },
'global': {
'postgresql': {
'postgresPassword': 'admin@postgres',
'username': dbuser,
'password': dbpass,
'database': dbname,
},
},
'auth': {
'username': dbuser,
'password': dbpass,
'database': dbname,
}
}
});
const dbService = db.apiObjects.find(construct => {
if ((construct.kind === 'Service') && (construct.metadata.name?.endsWith('postgresql'))) {
return construct.name;
}
return undefined;
});
if (dbService === undefined) {
throw new Error('Could not find postgresql service');
}
this.dbServiceName = dbService.name;
}
};