@bluedynamics/cdk8s-plone 0.3.2 → 0.3.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.jsii +47 -28
- package/API.md +28 -3
- package/lib/config/plone-vinyl-backend-response.vcl +25 -0
- package/lib/config/plone-vinyl-recv-routing-volto.vcl +21 -0
- package/lib/config/plone-vinyl-recv.vcl +18 -0
- package/{examples/volto → lib}/config/varnish.tpl.vcl +1 -1
- package/lib/httpcache.js +1 -1
- package/lib/imports/vinyl.bluedynamics.eu.d.ts +398 -66
- package/lib/imports/vinyl.bluedynamics.eu.js +169 -17
- package/lib/plone.js +1 -1
- package/lib/vinylcache.d.ts +21 -0
- package/lib/vinylcache.js +21 -2
- package/package.json +3 -2
- package/.claude/claude.md +0 -39
- package/.claude/settings.local.json +0 -31
- package/CLAUDE.md +0 -352
- package/docs/superpowers/plans/2026-06-12-configurable-service-spec.md +0 -608
- package/docs/superpowers/specs/2026-06-12-configurable-service-spec-design.md +0 -192
- package/documentation/Makefile +0 -357
- package/documentation/README.md +0 -284
- package/documentation/mx.ini +0 -3
- package/documentation/sources/_static/logo.svg +0 -79
- package/documentation/sources/conf.py +0 -145
- package/documentation/sources/explanation/architecture.md +0 -336
- package/documentation/sources/explanation/cdk8s-workflow.md +0 -66
- package/documentation/sources/explanation/features.md +0 -374
- package/documentation/sources/explanation/index.md +0 -34
- package/documentation/sources/how-to/backup-and-restore.md +0 -107
- package/documentation/sources/how-to/configure-env-and-secrets.md +0 -184
- package/documentation/sources/how-to/configure-ingress-tls.md +0 -108
- package/documentation/sources/how-to/configure-security-context.md +0 -143
- package/documentation/sources/how-to/deploy-blicca.md +0 -334
- package/documentation/sources/how-to/deploy-volto.md +0 -324
- package/documentation/sources/how-to/deploy-with-httpcache.md +0 -224
- package/documentation/sources/how-to/deploy-with-vinyl-cache.md +0 -273
- package/documentation/sources/how-to/enable-prometheus-monitoring.md +0 -122
- package/documentation/sources/how-to/index.md +0 -85
- package/documentation/sources/how-to/scale-and-high-availability.md +0 -122
- package/documentation/sources/how-to/schedule-pods.md +0 -145
- package/documentation/sources/how-to/setup-prerequisites.md +0 -363
- package/documentation/sources/how-to/troubleshooting.md +0 -113
- package/documentation/sources/how-to/upgrade-and-rollout.md +0 -140
- package/documentation/sources/index.md +0 -109
- package/documentation/sources/reference/api/index.md +0 -40
- package/documentation/sources/reference/configuration-options.md +0 -352
- package/documentation/sources/reference/index.md +0 -41
- package/documentation/sources/tutorials/01-quick-start.md +0 -165
- package/documentation/sources/tutorials/index.md +0 -53
- package/examples/blicca/.env.example +0 -20
- package/examples/blicca/README.md +0 -339
- package/examples/blicca/__snapshots__/main.test.ts.snap +0 -1035
- package/examples/blicca/cdk8s.yaml +0 -6
- package/examples/blicca/config/varnish.tpl.vcl +0 -217
- package/examples/blicca/ingress.ts +0 -217
- package/examples/blicca/jest.config.js +0 -11
- package/examples/blicca/main.test.ts +0 -18
- package/examples/blicca/main.ts +0 -101
- package/examples/blicca/package.json +0 -36
- package/examples/blicca/postgres.cloudnativepg.ts +0 -63
- package/examples/blicca/postgres.plain.ts +0 -115
- package/examples/blicca/tsconfig.json +0 -33
- package/examples/volto/.env.example +0 -21
- package/examples/volto/README.md +0 -292
- package/examples/volto/__snapshots__/main.test.ts.snap +0 -1206
- package/examples/volto/cdk8s.yaml +0 -6
- package/examples/volto/ingress.ts +0 -229
- package/examples/volto/jest.config.js +0 -11
- package/examples/volto/main.test.ts +0 -18
- package/examples/volto/main.ts +0 -105
- package/examples/volto/package.json +0 -36
- package/examples/volto/postgres.cloudnativepg.ts +0 -63
- package/examples/volto/postgres.plain.ts +0 -115
- package/examples/volto/tsconfig.json +0 -33
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
language: typescript
|
|
2
|
-
app: npx ts-node main.ts
|
|
3
|
-
imports:
|
|
4
|
-
- k8s
|
|
5
|
-
- https://raw.githubusercontent.com/cloudnative-pg/cloudnative-pg/release-1.24/config/crd/bases/postgresql.cnpg.io_clusters.yaml
|
|
6
|
-
- https://raw.githubusercontent.com/traefik/traefik/v3.2/docs/content/reference/dynamic-configuration/traefik.io_middlewares.yaml
|
|
@@ -1,229 +0,0 @@
|
|
|
1
|
-
import { Construct } from 'constructs';
|
|
2
|
-
import * as k8s from './imports/k8s';
|
|
3
|
-
import * as traefik from './imports/traefik.io';
|
|
4
|
-
|
|
5
|
-
export interface IngressOptions {
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* type: konq or traefik
|
|
9
|
-
* @default - traefik
|
|
10
|
-
*/
|
|
11
|
-
readonly ingressType?: string;
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* issuer: cert-manager/cluster-issuer
|
|
15
|
-
* @default none
|
|
16
|
-
*/
|
|
17
|
-
readonly issuer: string;
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* domainCached is the Domain used for the cached setup and should be the main public domain
|
|
21
|
-
* @default - none
|
|
22
|
-
*/
|
|
23
|
-
readonly domainCached: string;
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* domainUncached is the Domain used for the uncached setup and should be the internal for testing pruposes only
|
|
27
|
-
* @default - none
|
|
28
|
-
*/
|
|
29
|
-
readonly domainUncached: string;
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* domainMaintenance is the Domain to access the Plone backend (API) server for maintenance
|
|
33
|
-
* @default - none
|
|
34
|
-
*/
|
|
35
|
-
|
|
36
|
-
readonly domainMaintenance: string;
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* frontendServiceName is the K8S Service name of the Plone frontend (Express)
|
|
40
|
-
* @default - none
|
|
41
|
-
*/
|
|
42
|
-
readonly frontendServiceName: string;
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* backendServiceName is the K8S Service name of the Plone backend (API + Blobs)
|
|
46
|
-
* @default - none
|
|
47
|
-
*/
|
|
48
|
-
readonly backendServiceName: string;
|
|
49
|
-
|
|
50
|
-
/**
|
|
51
|
-
* httpcacheServiceName is the K8S Service name of the http-cache (Varnish)
|
|
52
|
-
* @default - none
|
|
53
|
-
*/
|
|
54
|
-
readonly httpcacheServiceName: string;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
export class IngressChart extends Construct {
|
|
59
|
-
|
|
60
|
-
readonly issuer: string;
|
|
61
|
-
|
|
62
|
-
constructor(scope: Construct, id: string, options: IngressOptions) {
|
|
63
|
-
super(scope, id);
|
|
64
|
-
this.issuer = options.issuer;
|
|
65
|
-
if (options.ingressType === 'traefik') {
|
|
66
|
-
this.traefikIngress(
|
|
67
|
-
'main',
|
|
68
|
-
'cached',
|
|
69
|
-
options.domainCached,
|
|
70
|
-
'/',
|
|
71
|
-
options.httpcacheServiceName,
|
|
72
|
-
80,
|
|
73
|
-
);
|
|
74
|
-
this.traefikIngress(
|
|
75
|
-
'main',
|
|
76
|
-
'uncached',
|
|
77
|
-
options.domainUncached,
|
|
78
|
-
`/`,
|
|
79
|
-
options.frontendServiceName,
|
|
80
|
-
3000,
|
|
81
|
-
);
|
|
82
|
-
this.traefikIngress(
|
|
83
|
-
'main',
|
|
84
|
-
'maintenance',
|
|
85
|
-
options.domainMaintenance,
|
|
86
|
-
`/`,
|
|
87
|
-
options.backendServiceName,
|
|
88
|
-
8080,
|
|
89
|
-
`/VirtualHostBase/https/${options.domainMaintenance}/VirtualHostRoot/`
|
|
90
|
-
);
|
|
91
|
-
} else if (options.ingressType === 'kong') {
|
|
92
|
-
|
|
93
|
-
// Create the ingress for the cached (main) domain
|
|
94
|
-
this.kongIngress(
|
|
95
|
-
'main',
|
|
96
|
-
'cached',
|
|
97
|
-
options.domainCached,
|
|
98
|
-
'/',
|
|
99
|
-
options.httpcacheServiceName,
|
|
100
|
-
80,
|
|
101
|
-
);
|
|
102
|
-
|
|
103
|
-
// Create the two ingresses for the uncached (test) domain
|
|
104
|
-
// - to frontend:
|
|
105
|
-
this.kongIngress(
|
|
106
|
-
'uncached',
|
|
107
|
-
'frontend',
|
|
108
|
-
options.domainUncached,
|
|
109
|
-
'/',
|
|
110
|
-
options.frontendServiceName,
|
|
111
|
-
3000,
|
|
112
|
-
);
|
|
113
|
-
// - to backend:
|
|
114
|
-
this.kongIngress(
|
|
115
|
-
'uncached',
|
|
116
|
-
'backend',
|
|
117
|
-
options.domainUncached,
|
|
118
|
-
'/~/((?:(?:\\+\\+api\\+\\+)(?:.*))|(?:(?:.*)/(?:(?:@@images|@@downloads)/.*)))',
|
|
119
|
-
options.backendServiceName,
|
|
120
|
-
8080,
|
|
121
|
-
`/VirtualHostBase/https/${options.domainUncached}/Plone/VirtualHostRoot/$1`,
|
|
122
|
-
);
|
|
123
|
-
|
|
124
|
-
// Create the ingress for the maintenance
|
|
125
|
-
this.kongIngress(
|
|
126
|
-
'maintenance',
|
|
127
|
-
'backend',
|
|
128
|
-
options.domainMaintenance,
|
|
129
|
-
'/~/(.*)',
|
|
130
|
-
options.backendServiceName,
|
|
131
|
-
8080,
|
|
132
|
-
`/VirtualHostBase/https/${options.domainMaintenance}/VirtualHostRoot/$1`
|
|
133
|
-
);
|
|
134
|
-
} else {
|
|
135
|
-
throw new Error('Unknown ingress type');
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
traefikIngress(prefix: string, postfix: string, domain: string, path: string, backendServiceName: string, backendPort: number, rewrite?: string) {
|
|
140
|
-
var annotations: { [key: string]: string } = {
|
|
141
|
-
'kubernetes.io/ingress.class': 'traefik',
|
|
142
|
-
'cert-manager.io/cluster-issuer': this.issuer,
|
|
143
|
-
};
|
|
144
|
-
if (rewrite !== undefined) {
|
|
145
|
-
const rewritemw = new traefik.Middleware(this, `${prefix}-${postfix}-addprefix`,
|
|
146
|
-
{
|
|
147
|
-
metadata: {},
|
|
148
|
-
spec: {
|
|
149
|
-
addPrefix: {
|
|
150
|
-
prefix: rewrite,
|
|
151
|
-
},
|
|
152
|
-
},
|
|
153
|
-
}
|
|
154
|
-
);
|
|
155
|
-
annotations['traefik.ingress.kubernetes.io/router.middlewares'] = `plone-${rewritemw.name}@kubernetescrd`;
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
new k8s.KubeIngress(this, `${prefix}-${postfix}`, {
|
|
159
|
-
metadata: {
|
|
160
|
-
annotations: annotations,
|
|
161
|
-
},
|
|
162
|
-
spec: {
|
|
163
|
-
ingressClassName: 'traefik',
|
|
164
|
-
rules: [{
|
|
165
|
-
host: domain,
|
|
166
|
-
http: {
|
|
167
|
-
paths: [{
|
|
168
|
-
backend: {
|
|
169
|
-
service: {
|
|
170
|
-
name: backendServiceName,
|
|
171
|
-
port: { number: backendPort },
|
|
172
|
-
},
|
|
173
|
-
},
|
|
174
|
-
path: path,
|
|
175
|
-
pathType: 'Prefix',
|
|
176
|
-
}],
|
|
177
|
-
},
|
|
178
|
-
}],
|
|
179
|
-
},
|
|
180
|
-
});
|
|
181
|
-
|
|
182
|
-
}
|
|
183
|
-
|
|
184
|
-
kongIngress(prefix: string, postfix: string, domain: string, path: string, backendServiceName: string, backendPort: number, rewrite?: string) {
|
|
185
|
-
/*
|
|
186
|
-
Create a konq general ingress
|
|
187
|
-
|
|
188
|
-
Properties:
|
|
189
|
-
- prefix: prefix for the ingress name used for grouping tls secrets
|
|
190
|
-
- postfix: postfix for the ingress name, used concatenated with the prefix as identifer for the ingress
|
|
191
|
-
- domain: domain for the ingress
|
|
192
|
-
- path: path for the ingress
|
|
193
|
-
- backendServiceName: name of the backend service
|
|
194
|
-
- backendPort: port of the backend service
|
|
195
|
-
- rewrite (optional): rewrite path for the ingress
|
|
196
|
-
*/
|
|
197
|
-
var annotations: { [key: string]: string } = {
|
|
198
|
-
'cert-manager.io/cluster-issuer': 'sectigo-issuer',
|
|
199
|
-
'konghq.com/https-redirect-status-code': '308',
|
|
200
|
-
'konghq.com/protocols': 'https',
|
|
201
|
-
};
|
|
202
|
-
if (rewrite !== undefined) {
|
|
203
|
-
annotations['konghq.com/rewrite'] = rewrite;
|
|
204
|
-
}
|
|
205
|
-
new k8s.KubeIngress(this, `${prefix}-${postfix}`, {
|
|
206
|
-
metadata: {
|
|
207
|
-
annotations: annotations,
|
|
208
|
-
},
|
|
209
|
-
spec: {
|
|
210
|
-
ingressClassName: 'kong',
|
|
211
|
-
rules: [{
|
|
212
|
-
host: domain,
|
|
213
|
-
http: {
|
|
214
|
-
paths: [{
|
|
215
|
-
backend: {
|
|
216
|
-
service: {
|
|
217
|
-
name: backendServiceName,
|
|
218
|
-
port: { number: backendPort },
|
|
219
|
-
},
|
|
220
|
-
},
|
|
221
|
-
path: path,
|
|
222
|
-
pathType: 'Prefix',
|
|
223
|
-
}],
|
|
224
|
-
},
|
|
225
|
-
}],
|
|
226
|
-
},
|
|
227
|
-
});
|
|
228
|
-
}
|
|
229
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { ExampleChart } from './main';
|
|
2
|
-
import { Testing } from 'cdk8s';
|
|
3
|
-
|
|
4
|
-
describe('Production Volto Example', () => {
|
|
5
|
-
test('Synthesizes correctly', () => {
|
|
6
|
-
const app = Testing.app();
|
|
7
|
-
const chart = new ExampleChart(app, 'test-chart');
|
|
8
|
-
const results = Testing.synth(chart);
|
|
9
|
-
// kube-httpcache generates a random Varnish admin secret on each synth.
|
|
10
|
-
// Redact it so the snapshot stays deterministic.
|
|
11
|
-
for (const obj of results) {
|
|
12
|
-
if (obj.kind === 'Secret' && obj.data && typeof obj.data.secret === 'string') {
|
|
13
|
-
obj.data.secret = '<redacted-for-snapshot>';
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
expect(results).toMatchSnapshot();
|
|
17
|
-
});
|
|
18
|
-
});
|
package/examples/volto/main.ts
DELETED
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
import { Construct } from 'constructs';
|
|
2
|
-
import { App, Chart, ChartProps } from 'cdk8s';
|
|
3
|
-
import { Plone, PloneHttpcache } from '@bluedynamics/cdk8s-plone';
|
|
4
|
-
import * as kplus from 'cdk8s-plus-30';
|
|
5
|
-
import * as path from 'path';
|
|
6
|
-
import { IngressChart } from './ingress';
|
|
7
|
-
import { config } from 'dotenv';
|
|
8
|
-
import { PGPlainChart } from './postgres.plain';
|
|
9
|
-
import { PGCloudNativePGChart } from './postgres.cloudnativepg';
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
export class ExampleChart extends Chart {
|
|
13
|
-
constructor(scope: Construct, id: string, props: ChartProps = {}) {
|
|
14
|
-
super(scope, id, props);
|
|
15
|
-
|
|
16
|
-
config();
|
|
17
|
-
|
|
18
|
-
// ================================================================================================================
|
|
19
|
-
// Postgresql
|
|
20
|
-
let db: PGPlainChart | PGCloudNativePGChart;
|
|
21
|
-
let postgresql_username;
|
|
22
|
-
let postgresql_password;
|
|
23
|
-
if ((process.env.DATABASE ?? 'plain') == 'cloudnativepg') {
|
|
24
|
-
const cloudnativepgDb = new PGCloudNativePGChart(this, 'db');
|
|
25
|
-
db = cloudnativepgDb;
|
|
26
|
-
// CloudNativePG creates secrets with format: {cluster-name}-app
|
|
27
|
-
// Use the CDK8S-generated cluster name, never hard-code
|
|
28
|
-
const secretName = `${cloudnativepgDb.clusterName}-app`;
|
|
29
|
-
postgresql_username = { valueFrom: { secretKeyRef: { name: secretName, key: 'username' }}};
|
|
30
|
-
postgresql_password = { valueFrom: { secretKeyRef: { name: secretName, key: 'password' }}};
|
|
31
|
-
} else {
|
|
32
|
-
// Operator-free single-instance PostgreSQL using the official image.
|
|
33
|
-
const plainDb = new PGPlainChart(this, 'db');
|
|
34
|
-
db = plainDb;
|
|
35
|
-
postgresql_username = { valueFrom: { secretKeyRef: { name: plainDb.secretName, key: 'username' }}};
|
|
36
|
-
postgresql_password = { valueFrom: { secretKeyRef: { name: plainDb.secretName, key: 'password' }}};
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
// ================================================================================================================
|
|
40
|
-
// Plone
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
// prepare the environment variables for the plone deployment
|
|
44
|
-
const dbMDName = db.dbServiceName
|
|
45
|
-
const env = new kplus.Env(
|
|
46
|
-
[],
|
|
47
|
-
{
|
|
48
|
-
SECRET_POSTGRESQL_USERNAME: postgresql_username,
|
|
49
|
-
SECRET_POSTGRESQL_PASSWORD: postgresql_password,
|
|
50
|
-
INSTANCE_db_storage: { value: `relstorage` },
|
|
51
|
-
INSTANCE_db_blob_mode: { value: `cache` },
|
|
52
|
-
INSTANCE_db_cache_size: { value: `5000` },
|
|
53
|
-
INSTANCE_db_cache_size_bytes: { value: `1500MB` },
|
|
54
|
-
INSTANCE_db_relstorage: { value: `postgresql` },
|
|
55
|
-
INSTANCE_db_relstorage_postgresql_dsn: { value: `host='${dbMDName}' dbname='plone' user='$(SECRET_POSTGRESQL_USERNAME)' password='$(SECRET_POSTGRESQL_PASSWORD)'` },
|
|
56
|
-
INSTANCE_db_relstorage_cache_local_mb: { value: `800` },
|
|
57
|
-
},
|
|
58
|
-
);
|
|
59
|
-
|
|
60
|
-
// create the plone deployment and related resources
|
|
61
|
-
const plone = new Plone(this, 'plone', {
|
|
62
|
-
version: 'test.version',
|
|
63
|
-
backend: {
|
|
64
|
-
image: process.env.PLONE_BACKEND_IMAGE ?? 'plone/plone-backend:6.1.3',
|
|
65
|
-
environment: env,
|
|
66
|
-
},
|
|
67
|
-
frontend: {
|
|
68
|
-
image: process.env.PLONE_FRONTEND_IMAGE ?? 'plone/plone-frontend:latest',
|
|
69
|
-
readinessEnabled: false,
|
|
70
|
-
},
|
|
71
|
-
})
|
|
72
|
-
|
|
73
|
-
// ================================================================================================================
|
|
74
|
-
// Varnish with kube-httpcache
|
|
75
|
-
const httpcache = new PloneHttpcache(
|
|
76
|
-
this,
|
|
77
|
-
'httpcache',
|
|
78
|
-
{
|
|
79
|
-
plone: plone,
|
|
80
|
-
varnishVclFile: path.join(__dirname, 'config', 'varnish.tpl.vcl'),
|
|
81
|
-
}
|
|
82
|
-
)
|
|
83
|
-
|
|
84
|
-
// ================================================================================================================
|
|
85
|
-
// Ingress
|
|
86
|
-
new IngressChart(
|
|
87
|
-
this,
|
|
88
|
-
'ingress',
|
|
89
|
-
{
|
|
90
|
-
ingressType: 'traefik',
|
|
91
|
-
issuer: process.env.CLUSTER_ISSUER ?? 'letsencrypt-prod',
|
|
92
|
-
domainCached: process.env.DOMAIN_CACHED ?? 'mxplone-cached.example.com',
|
|
93
|
-
domainUncached: process.env.DOMAIN_UNCACHED ?? 'mxplone-cached.example.com',
|
|
94
|
-
domainMaintenance: process.env.DOMAIN_MAINTENANCE ?? 'mxplone-maintenance.example.com',
|
|
95
|
-
backendServiceName: plone.backendServiceName,
|
|
96
|
-
frontendServiceName: plone.frontendServiceName ?? '',
|
|
97
|
-
httpcacheServiceName: httpcache.httpcacheServiceName,
|
|
98
|
-
});
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
const app = new App();
|
|
104
|
-
new ExampleChart(app, 'plone-example');
|
|
105
|
-
app.synth();
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "cdk8s-plone-example-volto",
|
|
3
|
-
"version": "1.0.0",
|
|
4
|
-
"description": "Production-ready Plone deployment example using cdk8s-plone",
|
|
5
|
-
"main": "main.js",
|
|
6
|
-
"types": "main.ts",
|
|
7
|
-
"license": "Apache-2.0",
|
|
8
|
-
"private": true,
|
|
9
|
-
"scripts": {
|
|
10
|
-
"import": "cdk8s import",
|
|
11
|
-
"synth": "cdk8s synth",
|
|
12
|
-
"compile": "tsc --build",
|
|
13
|
-
"watch": "tsc --build -w",
|
|
14
|
-
"test": "jest",
|
|
15
|
-
"test-update": "jest --updateSnapshot",
|
|
16
|
-
"build": "npm run compile && npm run test && npm run synth",
|
|
17
|
-
"upgrade": "npm i cdk8s@latest cdk8s-cli@latest",
|
|
18
|
-
"upgrade:next": "npm i cdk8s@next cdk8s-cli@next"
|
|
19
|
-
},
|
|
20
|
-
"dependencies": {
|
|
21
|
-
"@bluedynamics/cdk8s-plone": "../../",
|
|
22
|
-
"cdk8s": "^2.70.27",
|
|
23
|
-
"cdk8s-plus-30": "^2.4.10",
|
|
24
|
-
"constructs": "^10.4.2",
|
|
25
|
-
"dotenv": "^16.4.5"
|
|
26
|
-
},
|
|
27
|
-
"devDependencies": {
|
|
28
|
-
"@types/jest": "^29.5.14",
|
|
29
|
-
"@types/node": "^22.10.0",
|
|
30
|
-
"cdk8s-cli": "^2.206.3",
|
|
31
|
-
"jest": "^29.7.0",
|
|
32
|
-
"ts-jest": "^29.2.5",
|
|
33
|
-
"ts-node": "^10.9.2",
|
|
34
|
-
"typescript": "^5.9.3"
|
|
35
|
-
}
|
|
36
|
-
}
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
import { Construct } from 'constructs';
|
|
2
|
-
import * as cnpg from './imports/postgresql.cnpg.io'
|
|
3
|
-
|
|
4
|
-
export class PGCloudNativePGChart extends Construct {
|
|
5
|
-
// uses the CloudNativePG operator
|
|
6
|
-
// https://cloudnative-pg.io/
|
|
7
|
-
|
|
8
|
-
public readonly dbServiceName: string;
|
|
9
|
-
public readonly clusterName: string;
|
|
10
|
-
|
|
11
|
-
constructor(scope: Construct, id: string) {
|
|
12
|
-
super(scope, id);
|
|
13
|
-
|
|
14
|
-
const db = new cnpg.Cluster(
|
|
15
|
-
this,
|
|
16
|
-
'db',
|
|
17
|
-
{
|
|
18
|
-
metadata: {
|
|
19
|
-
labels: {
|
|
20
|
-
'app.kubernetes.io/name': 'plone-postgresql',
|
|
21
|
-
'app.kubernetes.io/instance': 'postgresql',
|
|
22
|
-
'app.kubernetes.io/component': 'database',
|
|
23
|
-
'app.kubernetes.io/part-of': 'plone',
|
|
24
|
-
}
|
|
25
|
-
},
|
|
26
|
-
spec: {
|
|
27
|
-
instances: 2,
|
|
28
|
-
postgresql: {
|
|
29
|
-
parameters: {
|
|
30
|
-
'max_connections': '200',
|
|
31
|
-
'shared_buffers': '256MB',
|
|
32
|
-
'effective_cache_size': '1GB',
|
|
33
|
-
'maintenance_work_mem': '64MB',
|
|
34
|
-
'checkpoint_completion_target': '0.9',
|
|
35
|
-
'wal_buffers': '16MB',
|
|
36
|
-
'default_statistics_target': '100',
|
|
37
|
-
'random_page_cost': '1.1',
|
|
38
|
-
'effective_io_concurrency': '200',
|
|
39
|
-
'work_mem': '4MB',
|
|
40
|
-
'min_wal_size': '1GB',
|
|
41
|
-
'max_wal_size': '4GB',
|
|
42
|
-
}
|
|
43
|
-
},
|
|
44
|
-
bootstrap: {
|
|
45
|
-
initdb: {
|
|
46
|
-
database: 'plone',
|
|
47
|
-
owner: 'plone',
|
|
48
|
-
}
|
|
49
|
-
},
|
|
50
|
-
storage: {
|
|
51
|
-
size: '10Gi',
|
|
52
|
-
},
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
);
|
|
56
|
-
|
|
57
|
-
// CloudNativePG creates a service named {cluster-name}-rw for read-write access
|
|
58
|
-
// CloudNativePG creates a secret named {cluster-name}-app with username/password
|
|
59
|
-
// Use the CDK8S-generated name, never hard-code metadata.name
|
|
60
|
-
this.clusterName = db.name;
|
|
61
|
-
this.dbServiceName = `${db.name}-rw`;
|
|
62
|
-
}
|
|
63
|
-
}
|
|
@@ -1,115 +0,0 @@
|
|
|
1
|
-
import { Construct } from 'constructs';
|
|
2
|
-
import * as k8s from './imports/k8s';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Operator-free PostgreSQL for the example.
|
|
6
|
-
*
|
|
7
|
-
* Deploys a single-instance PostgreSQL StatefulSet using the official
|
|
8
|
-
* `postgres` Docker image. No operator and no third-party Helm chart are
|
|
9
|
-
* required, which keeps the dependency surface minimal. It is intended for
|
|
10
|
-
* development and small production setups; for high availability, point-in-time
|
|
11
|
-
* recovery, and automated failover use the CloudNativePG variant instead.
|
|
12
|
-
*/
|
|
13
|
-
export class PGPlainChart extends Construct {
|
|
14
|
-
public readonly dbServiceName: string;
|
|
15
|
-
public readonly secretName: string;
|
|
16
|
-
|
|
17
|
-
constructor(scope: Construct, id: string) {
|
|
18
|
-
super(scope, id);
|
|
19
|
-
|
|
20
|
-
const dbname = 'plone';
|
|
21
|
-
const dbuser = 'plone';
|
|
22
|
-
const dbpass = 'admin@plone';
|
|
23
|
-
|
|
24
|
-
const labels = {
|
|
25
|
-
'app.kubernetes.io/name': 'plone-postgresql',
|
|
26
|
-
'app.kubernetes.io/instance': 'postgresql',
|
|
27
|
-
'app.kubernetes.io/component': 'database',
|
|
28
|
-
'app.kubernetes.io/part-of': 'plone',
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
const secret = new k8s.KubeSecret(this, 'secret', {
|
|
32
|
-
metadata: { labels },
|
|
33
|
-
stringData: { username: dbuser, password: dbpass, database: dbname },
|
|
34
|
-
});
|
|
35
|
-
this.secretName = secret.name;
|
|
36
|
-
|
|
37
|
-
const service = new k8s.KubeService(this, 'service', {
|
|
38
|
-
metadata: { labels },
|
|
39
|
-
spec: {
|
|
40
|
-
selector: labels,
|
|
41
|
-
ports: [
|
|
42
|
-
{ port: 5432, targetPort: k8s.IntOrString.fromNumber(5432), name: 'postgresql' },
|
|
43
|
-
],
|
|
44
|
-
},
|
|
45
|
-
});
|
|
46
|
-
this.dbServiceName = service.name;
|
|
47
|
-
|
|
48
|
-
new k8s.KubeStatefulSet(this, 'db', {
|
|
49
|
-
metadata: { labels },
|
|
50
|
-
spec: {
|
|
51
|
-
serviceName: service.name,
|
|
52
|
-
replicas: 1,
|
|
53
|
-
selector: { matchLabels: labels },
|
|
54
|
-
template: {
|
|
55
|
-
metadata: { labels },
|
|
56
|
-
spec: {
|
|
57
|
-
// The official postgres image runs as uid/gid 999.
|
|
58
|
-
// fsGroup makes the mounted volume group-writable for it.
|
|
59
|
-
securityContext: { fsGroup: 999 },
|
|
60
|
-
containers: [
|
|
61
|
-
{
|
|
62
|
-
name: 'postgresql',
|
|
63
|
-
image: 'postgres:18',
|
|
64
|
-
ports: [{ containerPort: 5432, name: 'postgresql' }],
|
|
65
|
-
env: [
|
|
66
|
-
{ name: 'POSTGRES_USER', valueFrom: { secretKeyRef: { name: secret.name, key: 'username' } } },
|
|
67
|
-
{ name: 'POSTGRES_PASSWORD', valueFrom: { secretKeyRef: { name: secret.name, key: 'password' } } },
|
|
68
|
-
{ name: 'POSTGRES_DB', valueFrom: { secretKeyRef: { name: secret.name, key: 'database' } } },
|
|
69
|
-
// Keep PGDATA in a subdirectory so the volume root can hold lost+found.
|
|
70
|
-
{ name: 'PGDATA', value: '/var/lib/postgresql/data/pgdata' },
|
|
71
|
-
],
|
|
72
|
-
volumeMounts: [
|
|
73
|
-
{ name: 'data', mountPath: '/var/lib/postgresql/data' },
|
|
74
|
-
],
|
|
75
|
-
readinessProbe: {
|
|
76
|
-
exec: { command: ['pg_isready', '-U', dbuser, '-d', dbname] },
|
|
77
|
-
initialDelaySeconds: 10,
|
|
78
|
-
periodSeconds: 10,
|
|
79
|
-
timeoutSeconds: 5,
|
|
80
|
-
},
|
|
81
|
-
livenessProbe: {
|
|
82
|
-
exec: { command: ['pg_isready', '-U', dbuser, '-d', dbname] },
|
|
83
|
-
initialDelaySeconds: 30,
|
|
84
|
-
periodSeconds: 15,
|
|
85
|
-
timeoutSeconds: 5,
|
|
86
|
-
},
|
|
87
|
-
resources: {
|
|
88
|
-
requests: {
|
|
89
|
-
cpu: k8s.Quantity.fromString('100m'),
|
|
90
|
-
memory: k8s.Quantity.fromString('256Mi'),
|
|
91
|
-
},
|
|
92
|
-
limits: {
|
|
93
|
-
cpu: k8s.Quantity.fromString('1'),
|
|
94
|
-
memory: k8s.Quantity.fromString('1Gi'),
|
|
95
|
-
},
|
|
96
|
-
},
|
|
97
|
-
},
|
|
98
|
-
],
|
|
99
|
-
},
|
|
100
|
-
},
|
|
101
|
-
volumeClaimTemplates: [
|
|
102
|
-
{
|
|
103
|
-
metadata: { name: 'data', labels },
|
|
104
|
-
spec: {
|
|
105
|
-
accessModes: ['ReadWriteOnce'],
|
|
106
|
-
resources: {
|
|
107
|
-
requests: { storage: k8s.Quantity.fromString('10Gi') },
|
|
108
|
-
},
|
|
109
|
-
},
|
|
110
|
-
},
|
|
111
|
-
],
|
|
112
|
-
},
|
|
113
|
-
});
|
|
114
|
-
}
|
|
115
|
-
}
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"compilerOptions": {
|
|
3
|
-
"alwaysStrict": true,
|
|
4
|
-
"declaration": true,
|
|
5
|
-
"experimentalDecorators": true,
|
|
6
|
-
"inlineSourceMap": true,
|
|
7
|
-
"inlineSources": true,
|
|
8
|
-
"lib": [
|
|
9
|
-
"ES2020"
|
|
10
|
-
],
|
|
11
|
-
"module": "CommonJS",
|
|
12
|
-
"noEmit": false,
|
|
13
|
-
"noEmitOnError": true,
|
|
14
|
-
"noFallthroughCasesInSwitch": true,
|
|
15
|
-
"noImplicitAny": true,
|
|
16
|
-
"noImplicitReturns": true,
|
|
17
|
-
"noImplicitThis": true,
|
|
18
|
-
"noUnusedLocals": true,
|
|
19
|
-
"noUnusedParameters": true,
|
|
20
|
-
"resolveJsonModule": true,
|
|
21
|
-
"strict": true,
|
|
22
|
-
"strictNullChecks": true,
|
|
23
|
-
"strictPropertyInitialization": true,
|
|
24
|
-
"stripInternal": true,
|
|
25
|
-
"target": "ES2020"
|
|
26
|
-
},
|
|
27
|
-
"include": [
|
|
28
|
-
"**/*.ts"
|
|
29
|
-
],
|
|
30
|
-
"exclude": [
|
|
31
|
-
"node_modules"
|
|
32
|
-
]
|
|
33
|
-
}
|