-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.ts
89 lines (80 loc) · 3.55 KB
/
main.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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
import { Construct } from 'constructs';
import { App, Chart, ChartProps } from 'cdk8s';
import { Plone, PloneHttpcache } from '@bluedynamics/cdk8s-plone';
import * as kplus from 'cdk8s-plus-24';
import * as path from 'path';
import { IngressChart } from './ingress';
import { config } from 'dotenv';
import { PGBitnamiChart } from './postgres.bitnami';
import { PGZalandoChart } from './postgres.zalando';
export class ExampleChart extends Chart {
constructor(scope: Construct, id: string, props: ChartProps = {}) {
super(scope, id, props);
config();
// ================================================================================================================
// Postgresql
let db: PGBitnamiChart | PGZalandoChart;
if ((process.env.DATABASE ?? 'zalando') == 'bitnami') {
db = new PGBitnamiChart(this, 'db');
} else {
db = new PGZalandoChart(this, 'db');
}
// ================================================================================================================
// Plone
// prepare the environment variables for the plone deployment
const dbMDName = db.dbServiceName
const env = new kplus.Env(
[],
{
SECRET_POSTGRESQL_USERNAME: { valueFrom: { secretKeyRef: { name: `plone.${dbMDName}.credentials.postgresql.acid.zalan.do`, key: 'username' }}},
SECRET_POSTGRESQL_PASSWORD: { valueFrom: { secretKeyRef: { name: `plone.${dbMDName}.credentials.postgresql.acid.zalan.do`, key: 'password' }}},
INSTANCE_db_storage: { value: `relstorage` },
INSTANCE_db_blob_mode: { value: `cache` },
INSTANCE_db_cache_size: { value: `5000` },
INSTANCE_db_cache_size_bytes: { value: `1500MB` },
INSTANCE_db_relstorage: { value: `postgresql` },
INSTANCE_db_relstorage_postgresql_dsn: { value: `host='${dbMDName}' dbname='plone' user='$(SECRET_POSTGRESQL_USERNAME)' password='$(SECRET_POSTGRESQL_PASSWORD)'` },
INSTANCE_db_relstorage_cache_local_mb: { value: `800` },
},
);
// create the plone deployment and related resources
const plone = new Plone(this, 'plone', {
version: 'test.version',
backend: {
image: process.env.PLONE_BACKEND_IMAGE ?? 'ghcr.io/bluedynamics/mximages-plone/mx-plone-backend:main',
environment: env,
},
frontend: {
image: process.env.PLONE_FRONTEND_IMAGE ?? 'ghcr.io/bluedynamics/mximages-plone/mx-plone-frontend:main',
},
})
// ================================================================================================================
// Varnish with kube-httpcache
const httpcache = new PloneHttpcache(
this,
'httpcache',
{
plone: plone,
varnishVclFile: path.join(__dirname, 'config', 'varnish.tpl.vcl'),
}
)
// ================================================================================================================
// Ingress
new IngressChart(
this,
'ingress',
{
ingressType: 'traefik',
issuer: process.env.CLUSTER_ISSUER ?? 'letsencrypt-prod',
domainCached: process.env.DOMAIN_CACHED ?? 'mxplone-cached.example.com',
domainUncached: process.env.DOMAIN_UNCACHED ?? 'mxplone-cached.example.com',
domainMaintenance: process.env.DOMAIN_UNCACHED ?? 'mxplone-maintenance.example.com',
backendServiceName: plone.backendServiceName,
frontendServiceName: plone.frontendServiceName ?? '',
httpcacheServiceName: httpcache.httpcacheServiceName,
});
}
}
const app = new App();
new ExampleChart(app, 'example');
app.synth();