underpost 3.2.8 → 3.2.10
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/.github/workflows/npmpkg.ci.yml +1 -0
- package/.github/workflows/pwa-microservices-template-test.ci.yml +1 -1
- package/.github/workflows/release.cd.yml +1 -0
- package/.vscode/settings.json +10 -5
- package/CHANGELOG.md +223 -2
- package/CLI-HELP.md +36 -7
- package/README.md +38 -9
- package/bin/build.js +27 -11
- package/bin/deploy.js +20 -21
- package/bin/file.js +32 -13
- package/bin/index.js +2 -1
- package/bin/vs.js +1 -1
- package/bump.config.js +26 -0
- package/conf.js +20 -4
- package/manifests/cronjobs/dd-cron/dd-cron-backup.yaml +2 -2
- package/manifests/cronjobs/dd-cron/dd-cron-dns.yaml +2 -2
- package/manifests/deployment/dd-default-development/deployment.yaml +2 -2
- package/manifests/deployment/dd-test-development/deployment.yaml +4 -2
- package/manifests/kind-config-dev.yaml +8 -0
- package/manifests/mongodb/pv-pvc.yaml +44 -8
- package/manifests/mongodb/statefulset.yaml +55 -68
- package/package.json +40 -25
- package/scripts/k3s-node-setup.sh +30 -11
- package/scripts/nat-iptables.sh +103 -18
- package/src/api/core/core.router.js +19 -14
- package/src/api/core/core.service.js +5 -5
- package/src/api/default/default.router.js +22 -18
- package/src/api/default/default.service.js +5 -5
- package/src/api/document/document.router.js +28 -23
- package/src/api/document/document.service.js +100 -23
- package/src/api/file/file.router.js +19 -13
- package/src/api/file/file.service.js +9 -7
- package/src/api/test/test.router.js +17 -12
- package/src/api/types.js +24 -0
- package/src/api/user/guest.service.js +5 -4
- package/src/api/user/user.router.js +297 -288
- package/src/api/user/user.service.js +100 -35
- package/src/cli/baremetal.js +20 -11
- package/src/cli/cluster.js +243 -55
- package/src/cli/db.js +106 -62
- package/src/cli/deploy.js +297 -154
- package/src/cli/fs.js +19 -3
- package/src/cli/index.js +37 -9
- package/src/cli/ipfs.js +4 -6
- package/src/cli/kubectl.js +4 -1
- package/src/cli/lxd.js +217 -135
- package/src/cli/release.js +289 -131
- package/src/cli/repository.js +91 -34
- package/src/cli/run.js +297 -56
- package/src/cli/test.js +9 -3
- package/src/client/Default.index.js +9 -3
- package/src/client/components/core/Auth.js +19 -5
- package/src/client/components/core/Docs.js +6 -34
- package/src/client/components/core/FileExplorer.js +6 -6
- package/src/client/components/core/Modal.js +65 -2
- package/src/client/components/core/PanelForm.js +56 -52
- package/src/client/components/core/Recover.js +4 -4
- package/src/client/components/core/Worker.js +170 -350
- package/src/client/services/default/default.management.js +20 -25
- package/src/client/services/user/guest.service.js +10 -3
- package/src/client/sw/core.sw.js +174 -112
- package/src/db/DataBaseProvider.js +120 -20
- package/src/db/mongo/MongoBootstrap.js +587 -0
- package/src/db/mongo/MongooseDB.js +126 -22
- package/src/index.js +1 -1
- package/src/runtime/express/Express.js +2 -2
- package/src/runtime/wp/Wp.js +8 -5
- package/src/server/auth.js +2 -2
- package/src/server/client-build-docs.js +1 -1
- package/src/server/client-build.js +94 -129
- package/src/server/conf.js +20 -65
- package/src/server/data-query.js +32 -20
- package/src/server/dns.js +22 -0
- package/src/server/process.js +180 -19
- package/src/server/runtime.js +1 -1
- package/src/server/start.js +26 -7
- package/src/server/valkey.js +9 -2
- package/src/ws/IoInterface.js +16 -16
- package/src/ws/core/channels/core.ws.chat.js +11 -11
- package/src/ws/core/channels/core.ws.mailer.js +29 -29
- package/src/ws/core/channels/core.ws.stream.js +19 -19
- package/src/ws/core/core.ws.connection.js +8 -8
- package/src/ws/core/core.ws.server.js +6 -5
- package/src/ws/default/channels/default.ws.main.js +10 -10
- package/src/ws/default/default.ws.connection.js +4 -4
- package/src/ws/default/default.ws.server.js +4 -3
- package/typedoc.json +10 -1
- package/src/client/ssr/email/DefaultRecoverEmail.js +0 -21
- package/src/client/ssr/email/DefaultVerifyEmail.js +0 -17
- /package/src/client/ssr/{offline → views}/Maintenance.js +0 -0
- /package/src/client/ssr/{offline → views}/NoNetworkConnection.js +0 -0
- /package/src/client/ssr/{pages → views}/Test.js +0 -0
package/bin/deploy.js
CHANGED
|
@@ -443,10 +443,10 @@ ${shellExec(`git log | grep Author: | sort -u`, { stdout: true }).split(`\n`).jo
|
|
|
443
443
|
shellExec(`sudo kubectl delete secret ${secretSelector} -n ${namespace} --ignore-not-found`);
|
|
444
444
|
shellExec(
|
|
445
445
|
`sudo kubectl create secret generic ${secretSelector}` +
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
446
|
+
` --from-literal=POSTGRES_DB=postgresdb` +
|
|
447
|
+
` --from-literal=POSTGRES_USER=admin` +
|
|
448
|
+
` --from-file=POSTGRES_PASSWORD=/home/dd/engine/engine-private/postgresql-password` +
|
|
449
|
+
` --dry-run=client -o yaml | kubectl apply -f - -n ${namespace}`,
|
|
450
450
|
);
|
|
451
451
|
}
|
|
452
452
|
{
|
|
@@ -454,10 +454,10 @@ ${shellExec(`git log | grep Author: | sort -u`, { stdout: true }).split(`\n`).jo
|
|
|
454
454
|
shellExec(`sudo kubectl delete secret ${secretSelector} -n ${namespace} --ignore-not-found`);
|
|
455
455
|
shellExec(
|
|
456
456
|
`sudo kubectl create secret generic ${secretSelector}` +
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
457
|
+
` --from-file=SECRET_KEY=/home/dd/engine/engine-private/postgresql-password` +
|
|
458
|
+
` --from-literal=FIRST_SUPERUSER=${process.env.GITHUB_EMAIL || 'development@underpost.net'}` +
|
|
459
|
+
` --from-file=FIRST_SUPERUSER_PASSWORD=/home/dd/engine/engine-private/postgresql-password` +
|
|
460
|
+
` --dry-run=client -o yaml | kubectl apply -f - -n ${namespace}`,
|
|
461
461
|
);
|
|
462
462
|
}
|
|
463
463
|
}
|
|
@@ -577,8 +577,7 @@ nvidia/gpu-operator \
|
|
|
577
577
|
shellExec(`sudo docker pull ${image}`);
|
|
578
578
|
if (!process.argv.includes('kubeadm'))
|
|
579
579
|
shellExec(
|
|
580
|
-
`sudo ${
|
|
581
|
-
process.argv.includes('kubeadm') ? `ctr -n k8s.io images import` : `kind load docker-image`
|
|
580
|
+
`sudo ${process.argv.includes('kubeadm') ? `ctr -n k8s.io images import` : `kind load docker-image`
|
|
582
581
|
} ${image}`,
|
|
583
582
|
);
|
|
584
583
|
const namespace = process.argv.find((arg) => arg.startsWith('--namespace='))?.split('=')[1] || 'default';
|
|
@@ -627,11 +626,11 @@ nvidia/gpu-operator \
|
|
|
627
626
|
}
|
|
628
627
|
env[key] =
|
|
629
628
|
`${key}`.toUpperCase().match('API') ||
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
629
|
+
`${key}`.toUpperCase().match('KEY') ||
|
|
630
|
+
`${key}`.toUpperCase().match('SECRET') ||
|
|
631
|
+
`${key}`.toUpperCase().match('TOKEN') ||
|
|
632
|
+
`${key}`.toUpperCase().match('PASSWORD') ||
|
|
633
|
+
`${key}`.toUpperCase().match('MAC')
|
|
635
634
|
? 'changethis'
|
|
636
635
|
: isNaN(parseFloat(privateEnv[key]))
|
|
637
636
|
? `${privateEnv[key]}`.match(`@`)
|
|
@@ -714,7 +713,7 @@ nvidia/gpu-operator \
|
|
|
714
713
|
}
|
|
715
714
|
|
|
716
715
|
case 'cyberia': {
|
|
717
|
-
const { CyberiaDependencies } = await import(`../src/
|
|
716
|
+
const { CyberiaDependencies } = await import(`../src/api/cyberia-server-defaults/cyberia-server-defaults.js`);
|
|
718
717
|
for (const dep of Object.keys(CyberiaDependencies)) {
|
|
719
718
|
const ver = CyberiaDependencies[dep];
|
|
720
719
|
shellExec(`npm install ${dep}@${ver}`);
|
|
@@ -823,7 +822,7 @@ nvidia/gpu-operator \
|
|
|
823
822
|
|
|
824
823
|
// Delete merged local and remote branches
|
|
825
824
|
for (const { branch, isAlreadyMerged } of mergedBranches) {
|
|
826
|
-
shellExec(`git branch -D ${branch}`, { silent: true });
|
|
825
|
+
shellExec(`git branch -D ${branch}`, { silent: true, silentOnError: true });
|
|
827
826
|
// logger.info(`Deleting remote branch: ${branch}${isAlreadyMerged ? ' (already merged)' : ''}`);
|
|
828
827
|
// shellExec(`git push https://${process.env.GITHUB_TOKEN}@github.com/${gitUri}.git --delete ${branch}`, {
|
|
829
828
|
// disableLog: true,
|
|
@@ -1394,10 +1393,10 @@ nvidia/gpu-operator \
|
|
|
1394
1393
|
const deployIds = deployIdArg
|
|
1395
1394
|
? [deployIdArg]
|
|
1396
1395
|
: fs
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1396
|
+
.readFileSync(`./engine-private/deploy/dd.router`, 'utf8')
|
|
1397
|
+
.split(',')
|
|
1398
|
+
.map((d) => d.trim())
|
|
1399
|
+
.filter(Boolean);
|
|
1401
1400
|
|
|
1402
1401
|
const addComponentToClientConf = ({ filePath, label, targetClientId, targetSubmoduleId }) => {
|
|
1403
1402
|
if (!fs.existsSync(filePath)) return { added: 0, checked: 0, hasComponentFile: false };
|
package/bin/file.js
CHANGED
|
@@ -15,9 +15,13 @@ import dotenv from 'dotenv';
|
|
|
15
15
|
|
|
16
16
|
const logger = loggerFactory(import.meta);
|
|
17
17
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
18
|
+
if (fs.existsSync('./engine-private/conf/dd-cron/.env.production'))
|
|
19
|
+
dotenv.config({
|
|
20
|
+
path:
|
|
21
|
+
`./engine-private/conf/dd-cron/.env.production`,
|
|
22
|
+
override: true
|
|
23
|
+
});
|
|
24
|
+
else dotenv.config();
|
|
21
25
|
|
|
22
26
|
let [exe, dir, type] = process.argv;
|
|
23
27
|
let rawPath = process.argv[3].replaceAll(`'`, '');
|
|
@@ -56,10 +60,10 @@ try {
|
|
|
56
60
|
|
|
57
61
|
if (type === 'update-template') {
|
|
58
62
|
if (!fs.existsSync(toPath))
|
|
59
|
-
shellExec(`cd .. &&
|
|
63
|
+
shellExec(`cd .. && node engine/bin clone ${process.env.GITHUB_USERNAME}/pwa-microservices-template`);
|
|
60
64
|
else {
|
|
61
65
|
shellExec(`cd ${toPath} && git reset && git checkout . && git clean -f -d`);
|
|
62
|
-
shellExec(`
|
|
66
|
+
shellExec(`node bin pull ${toPath} ${process.env.GITHUB_USERNAME}/pwa-microservices-template`);
|
|
63
67
|
shellExec(`sudo rm -rf ${toPath}/engine-private`);
|
|
64
68
|
shellExec(`sudo rm -rf ${toPath}/logs`);
|
|
65
69
|
}
|
|
@@ -107,6 +111,7 @@ try {
|
|
|
107
111
|
'./src/runtime/cyberia-server',
|
|
108
112
|
'./src/runtime/cyberia-client',
|
|
109
113
|
'./test/shape-generator.test.js',
|
|
114
|
+
'./src/client/public/cyberia-docs',
|
|
110
115
|
'bin/cyberia.js',
|
|
111
116
|
]) {
|
|
112
117
|
if (fs.existsSync(deletePath)) fs.removeSync('../pwa-microservices-template/' + deletePath);
|
|
@@ -134,9 +139,6 @@ try {
|
|
|
134
139
|
const templatePackageJson = JSON.parse(fs.readFileSync('../pwa-microservices-template/package.json', 'utf8'));
|
|
135
140
|
|
|
136
141
|
const name = templatePackageJson.name;
|
|
137
|
-
const description = templatePackageJson.description;
|
|
138
|
-
const dev = templatePackageJson.scripts.dev;
|
|
139
|
-
const build = templatePackageJson.scripts.build;
|
|
140
142
|
|
|
141
143
|
templatePackageJson.dependencies = originPackageJson.dependencies;
|
|
142
144
|
templatePackageJson.devDependencies = originPackageJson.devDependencies;
|
|
@@ -144,11 +146,27 @@ try {
|
|
|
144
146
|
templatePackageJson.scripts = originPackageJson.scripts;
|
|
145
147
|
templatePackageJson.overrides = originPackageJson.overrides;
|
|
146
148
|
templatePackageJson.name = name;
|
|
147
|
-
templatePackageJson.description =
|
|
148
|
-
|
|
149
|
-
// templatePackageJson.scripts.build = build;
|
|
149
|
+
templatePackageJson.description =
|
|
150
|
+
'Underpost Platform — end-to-end CI/CD and application-delivery toolchain CLI. Covers bare metal, Kubernetes, K3s, kubeadm, LXD, container/image orchestration, secrets, databases, cron jobs, monitoring, SSH, runners, PWA + Workbox delivery, and release orchestration. Extensible via downstream CLIs.';
|
|
150
151
|
templatePackageJson.keywords = uniqueArray(
|
|
151
|
-
[
|
|
152
|
+
[
|
|
153
|
+
'underpost',
|
|
154
|
+
'underpost-platform',
|
|
155
|
+
'cli',
|
|
156
|
+
'toolchain',
|
|
157
|
+
'ci-cd',
|
|
158
|
+
'devops',
|
|
159
|
+
'kubernetes',
|
|
160
|
+
'k3s',
|
|
161
|
+
'kubeadm',
|
|
162
|
+
'lxd',
|
|
163
|
+
'bare-metal',
|
|
164
|
+
'container-orchestration',
|
|
165
|
+
'image-management',
|
|
166
|
+
'pwa',
|
|
167
|
+
'workbox',
|
|
168
|
+
'microservices',
|
|
169
|
+
].concat(templatePackageJson.keywords || []),
|
|
152
170
|
);
|
|
153
171
|
delete templatePackageJson.scripts['update:template'];
|
|
154
172
|
fs.writeFileSync(
|
|
@@ -198,4 +216,5 @@ try {
|
|
|
198
216
|
}
|
|
199
217
|
} catch (error) {
|
|
200
218
|
logger.error(error, error.stack);
|
|
201
|
-
|
|
219
|
+
process.exit(1);
|
|
220
|
+
}
|
package/bin/index.js
CHANGED
package/bin/vs.js
CHANGED
package/bump.config.js
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* bumpp configuration for the Underpost engine.
|
|
3
|
+
*
|
|
4
|
+
* Owns the *canonical* version-bearing files (anything that exposes a literal `version` field
|
|
5
|
+
* bumpp can detect natively). Non-canonical files — image tags in workflows, README badges,
|
|
6
|
+
* doc strings, deployment.yaml image refs — are handled by the custom regex walker in
|
|
7
|
+
* src/cli/release.js (VERSION_BUMP_TARGETS), because bumpp only rewrites `version`-shaped lines.
|
|
8
|
+
*
|
|
9
|
+
* release.js drives bumpp programmatically (versionBump from 'bumpp') with commit/tag/push
|
|
10
|
+
* disabled, since the engine release flow stages and commits separately via `node bin cmt`.
|
|
11
|
+
*
|
|
12
|
+
* @see https://github.com/antfu/bumpp
|
|
13
|
+
*/
|
|
14
|
+
export default {
|
|
15
|
+
files: [
|
|
16
|
+
'package.json',
|
|
17
|
+
'package-lock.json',
|
|
18
|
+
// engine-private confs are git-ignored and visited only if present at bump time.
|
|
19
|
+
'engine-private/conf/**/package.json',
|
|
20
|
+
],
|
|
21
|
+
commit: false,
|
|
22
|
+
tag: false,
|
|
23
|
+
push: false,
|
|
24
|
+
confirm: false,
|
|
25
|
+
recursive: false,
|
|
26
|
+
};
|
package/conf.js
CHANGED
|
@@ -168,11 +168,25 @@ const DefaultConf = /**/ {
|
|
|
168
168
|
head: ['Seo', 'Pwa', 'Css', 'DefaultScripts', 'Production'],
|
|
169
169
|
body: ['CacheControl', 'DefaultSplashScreen', '404', '500', 'SwaggerDarkMode'],
|
|
170
170
|
mailer: { userVerifyEmail: 'DefaultVerifyEmail', userRecoverEmail: 'DefaultRecoverEmail' },
|
|
171
|
-
|
|
172
|
-
{
|
|
173
|
-
|
|
171
|
+
views: [
|
|
172
|
+
{
|
|
173
|
+
path: '/offline',
|
|
174
|
+
title: 'No Network Connection',
|
|
175
|
+
client: 'NoNetworkConnection',
|
|
176
|
+
head: [],
|
|
177
|
+
body: [],
|
|
178
|
+
offlineDefault: true,
|
|
179
|
+
},
|
|
180
|
+
{
|
|
181
|
+
path: '/maintenance',
|
|
182
|
+
title: 'Server Maintenance',
|
|
183
|
+
client: 'Maintenance',
|
|
184
|
+
head: [],
|
|
185
|
+
body: [],
|
|
186
|
+
maintenanceDefault: true,
|
|
187
|
+
},
|
|
188
|
+
{ path: '/test', title: 'Test', client: 'Test', head: [], body: [] },
|
|
174
189
|
],
|
|
175
|
-
pages: [{ path: '/test', title: 'Test', client: 'Test', head: [], body: [] }],
|
|
176
190
|
},
|
|
177
191
|
},
|
|
178
192
|
server: {
|
|
@@ -189,6 +203,8 @@ const DefaultConf = /**/ {
|
|
|
189
203
|
provider: 'env:DB_PROVIDER:mongoose',
|
|
190
204
|
host: 'env:DB_HOST:mongodb://127.0.0.1:27017',
|
|
191
205
|
name: 'env:DB_NAME:default',
|
|
206
|
+
replicaSet: 'env:DB_REPLICA_SET:rs0',
|
|
207
|
+
authSource: 'env:DB_AUTH_SOURCE:admin',
|
|
192
208
|
user: 'env:DB_USER:',
|
|
193
209
|
password: 'env:DB_PASSWORD:',
|
|
194
210
|
},
|
|
@@ -23,7 +23,7 @@ spec:
|
|
|
23
23
|
spec:
|
|
24
24
|
containers:
|
|
25
25
|
- name: dd-cron-backup
|
|
26
|
-
image: underpost/underpost-engine:v3.2.
|
|
26
|
+
image: underpost/underpost-engine:v3.2.10
|
|
27
27
|
command:
|
|
28
28
|
- /bin/sh
|
|
29
29
|
- -c
|
|
@@ -42,7 +42,7 @@ spec:
|
|
|
42
42
|
type: Directory
|
|
43
43
|
name: underpost-cron-container-volume
|
|
44
44
|
- hostPath:
|
|
45
|
-
path: /root/.nvm/versions/node/v24.
|
|
45
|
+
path: /root/.nvm/versions/node/v24.15.0/lib/node_modules/underpost
|
|
46
46
|
type: DirectoryOrCreate
|
|
47
47
|
name: underpost-share-env
|
|
48
48
|
restartPolicy: OnFailure
|
|
@@ -23,7 +23,7 @@ spec:
|
|
|
23
23
|
spec:
|
|
24
24
|
containers:
|
|
25
25
|
- name: dd-cron-dns
|
|
26
|
-
image: underpost/underpost-engine:v3.2.
|
|
26
|
+
image: underpost/underpost-engine:v3.2.10
|
|
27
27
|
command:
|
|
28
28
|
- /bin/sh
|
|
29
29
|
- -c
|
|
@@ -42,7 +42,7 @@ spec:
|
|
|
42
42
|
type: Directory
|
|
43
43
|
name: underpost-cron-container-volume
|
|
44
44
|
- hostPath:
|
|
45
|
-
path: /root/.nvm/versions/node/v24.
|
|
45
|
+
path: /root/.nvm/versions/node/v24.15.0/lib/node_modules/underpost
|
|
46
46
|
type: DirectoryOrCreate
|
|
47
47
|
name: underpost-share-env
|
|
48
48
|
restartPolicy: OnFailure
|
|
@@ -17,7 +17,7 @@ spec:
|
|
|
17
17
|
spec:
|
|
18
18
|
containers:
|
|
19
19
|
- name: dd-default-development-blue
|
|
20
|
-
image: underpost/underpost-engine:v3.2.
|
|
20
|
+
image: underpost/underpost-engine:v3.2.10
|
|
21
21
|
# resources:
|
|
22
22
|
# requests:
|
|
23
23
|
# memory: "124Ki"
|
|
@@ -98,7 +98,7 @@ spec:
|
|
|
98
98
|
spec:
|
|
99
99
|
containers:
|
|
100
100
|
- name: dd-default-development-green
|
|
101
|
-
image: underpost/underpost-engine:v3.2.
|
|
101
|
+
image: underpost/underpost-engine:v3.2.10
|
|
102
102
|
# resources:
|
|
103
103
|
# requests:
|
|
104
104
|
# memory: "124Ki"
|
|
@@ -20,7 +20,7 @@ spec:
|
|
|
20
20
|
spec:
|
|
21
21
|
containers:
|
|
22
22
|
- name: dd-test-development-blue
|
|
23
|
-
image: underpost/underpost-engine:v3.2.
|
|
23
|
+
image: underpost/underpost-engine:v3.2.10
|
|
24
24
|
imagePullPolicy: IfNotPresent
|
|
25
25
|
envFrom:
|
|
26
26
|
- secretRef:
|
|
@@ -34,6 +34,7 @@ spec:
|
|
|
34
34
|
underpost start --build --run dd-test development
|
|
35
35
|
|
|
36
36
|
|
|
37
|
+
|
|
37
38
|
---
|
|
38
39
|
apiVersion: v1
|
|
39
40
|
kind: Service
|
|
@@ -147,7 +148,7 @@ spec:
|
|
|
147
148
|
spec:
|
|
148
149
|
containers:
|
|
149
150
|
- name: dd-test-development-green
|
|
150
|
-
image: underpost/underpost-engine:v3.2.
|
|
151
|
+
image: underpost/underpost-engine:v3.2.10
|
|
151
152
|
imagePullPolicy: IfNotPresent
|
|
152
153
|
envFrom:
|
|
153
154
|
- secretRef:
|
|
@@ -161,6 +162,7 @@ spec:
|
|
|
161
162
|
underpost start --build --run dd-test development
|
|
162
163
|
|
|
163
164
|
|
|
165
|
+
|
|
164
166
|
---
|
|
165
167
|
apiVersion: v1
|
|
166
168
|
kind: Service
|
|
@@ -1,8 +1,16 @@
|
|
|
1
1
|
kind: Cluster
|
|
2
2
|
apiVersion: kind.x-k8s.io/v1alpha4
|
|
3
|
+
networking:
|
|
4
|
+
ipFamily: ipv4
|
|
3
5
|
nodes:
|
|
4
6
|
- role: control-plane
|
|
7
|
+
extraMounts:
|
|
8
|
+
- hostPath: /data/mongodb
|
|
9
|
+
containerPath: /data/mongodb
|
|
5
10
|
- role: worker
|
|
11
|
+
extraMounts:
|
|
12
|
+
- hostPath: /data/mongodb
|
|
13
|
+
containerPath: /data/mongodb
|
|
6
14
|
# extraPortMappings:
|
|
7
15
|
# - containerPort: 80
|
|
8
16
|
# hostPort: 80
|
|
@@ -1,23 +1,59 @@
|
|
|
1
1
|
apiVersion: v1
|
|
2
2
|
kind: PersistentVolume
|
|
3
3
|
metadata:
|
|
4
|
-
name: mongodb-pv
|
|
4
|
+
name: mongodb-pv-0
|
|
5
|
+
labels:
|
|
6
|
+
app: mongodb
|
|
5
7
|
spec:
|
|
6
8
|
capacity:
|
|
7
9
|
storage: 5Gi
|
|
8
10
|
accessModes:
|
|
9
11
|
- ReadWriteOnce
|
|
12
|
+
persistentVolumeReclaimPolicy: Retain
|
|
13
|
+
storageClassName: mongodb-storage-class
|
|
14
|
+
claimRef:
|
|
15
|
+
namespace: default
|
|
16
|
+
name: mongodb-storage-mongodb-0
|
|
10
17
|
hostPath:
|
|
11
|
-
path: /data/mongodb
|
|
18
|
+
path: /data/mongodb/v0
|
|
19
|
+
type: DirectoryOrCreate
|
|
12
20
|
---
|
|
13
21
|
apiVersion: v1
|
|
14
|
-
kind:
|
|
22
|
+
kind: PersistentVolume
|
|
23
|
+
metadata:
|
|
24
|
+
name: mongodb-pv-1
|
|
25
|
+
labels:
|
|
26
|
+
app: mongodb
|
|
27
|
+
spec:
|
|
28
|
+
capacity:
|
|
29
|
+
storage: 5Gi
|
|
30
|
+
accessModes:
|
|
31
|
+
- ReadWriteOnce
|
|
32
|
+
persistentVolumeReclaimPolicy: Retain
|
|
33
|
+
storageClassName: mongodb-storage-class
|
|
34
|
+
claimRef:
|
|
35
|
+
namespace: default
|
|
36
|
+
name: mongodb-storage-mongodb-1
|
|
37
|
+
hostPath:
|
|
38
|
+
path: /data/mongodb/v1
|
|
39
|
+
type: DirectoryOrCreate
|
|
40
|
+
---
|
|
41
|
+
apiVersion: v1
|
|
42
|
+
kind: PersistentVolume
|
|
15
43
|
metadata:
|
|
16
|
-
name: mongodb-
|
|
44
|
+
name: mongodb-pv-2
|
|
45
|
+
labels:
|
|
46
|
+
app: mongodb
|
|
17
47
|
spec:
|
|
18
|
-
|
|
48
|
+
capacity:
|
|
49
|
+
storage: 5Gi
|
|
19
50
|
accessModes:
|
|
20
51
|
- ReadWriteOnce
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
52
|
+
persistentVolumeReclaimPolicy: Retain
|
|
53
|
+
storageClassName: mongodb-storage-class
|
|
54
|
+
claimRef:
|
|
55
|
+
namespace: default
|
|
56
|
+
name: mongodb-storage-mongodb-2
|
|
57
|
+
hostPath:
|
|
58
|
+
path: /data/mongodb/v2
|
|
59
|
+
type: DirectoryOrCreate
|
|
@@ -4,7 +4,8 @@ metadata:
|
|
|
4
4
|
name: mongodb # Specifies the name of the statefulset
|
|
5
5
|
spec:
|
|
6
6
|
serviceName: 'mongodb-service' # Specifies the service to use
|
|
7
|
-
|
|
7
|
+
podManagementPolicy: OrderedReady # or Parallel
|
|
8
|
+
replicas: 3
|
|
8
9
|
selector:
|
|
9
10
|
matchLabels:
|
|
10
11
|
app: mongodb
|
|
@@ -13,80 +14,58 @@ spec:
|
|
|
13
14
|
labels:
|
|
14
15
|
app: mongodb
|
|
15
16
|
spec:
|
|
17
|
+
subdomain: mongodb-service
|
|
18
|
+
securityContext:
|
|
19
|
+
fsGroup: 999
|
|
20
|
+
initContainers:
|
|
21
|
+
- name: internal-keyfile-provisioner
|
|
22
|
+
image: docker.io/library/mongo:latest
|
|
23
|
+
securityContext:
|
|
24
|
+
runAsUser: 0
|
|
25
|
+
runAsGroup: 0
|
|
26
|
+
command:
|
|
27
|
+
- sh
|
|
28
|
+
- -c
|
|
29
|
+
- |
|
|
30
|
+
set -ex
|
|
31
|
+
mkdir -p /opt/mongodb
|
|
32
|
+
cp /tmp/raw-keyfile/mongodb-keyfile /opt/mongodb/mongodb-keyfile
|
|
33
|
+
chmod 400 /opt/mongodb/mongodb-keyfile
|
|
34
|
+
chown -R 999:999 /opt/mongodb
|
|
35
|
+
chown -R 999:999 /data/db
|
|
36
|
+
rm -f /data/db/mongod.lock
|
|
37
|
+
volumeMounts:
|
|
38
|
+
- name: raw-secret-keyfile-volume
|
|
39
|
+
mountPath: /tmp/raw-keyfile
|
|
40
|
+
- name: isolated-runtime-keyfile-volume
|
|
41
|
+
mountPath: /opt/mongodb
|
|
42
|
+
- name: mongodb-storage
|
|
43
|
+
mountPath: /data/db
|
|
16
44
|
containers:
|
|
17
45
|
- name: mongodb
|
|
18
46
|
image: docker.io/library/mongo:latest
|
|
19
47
|
command:
|
|
20
48
|
- mongod
|
|
49
|
+
args:
|
|
21
50
|
- '--replSet'
|
|
22
51
|
- 'rs0'
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
# - 'keyFile'
|
|
29
|
-
# - '--keyFile'
|
|
30
|
-
# - '/etc/mongodb-keyfile'
|
|
31
|
-
# - '--interleave'
|
|
32
|
-
# - 'all'
|
|
33
|
-
# - '--wiredTigerCacheSizeGB'
|
|
34
|
-
# - '0.25'
|
|
35
|
-
# - '--setParameter'
|
|
36
|
-
# - 'authenticationMechanisms=SCRAM-SHA-1'
|
|
37
|
-
# - '--fork'
|
|
38
|
-
- '--logpath'
|
|
39
|
-
- '/var/log/mongodb/mongod.log'
|
|
52
|
+
- '--auth'
|
|
53
|
+
- '--clusterAuthMode'
|
|
54
|
+
- 'keyFile'
|
|
55
|
+
- '--keyFile'
|
|
56
|
+
- '/opt/mongodb/mongodb-keyfile'
|
|
40
57
|
- '--bind_ip_all'
|
|
41
|
-
|
|
42
|
-
# args:
|
|
43
|
-
# - |
|
|
44
|
-
# mongod --replSet rs0 --bind_ip_all &
|
|
45
|
-
# sleep 1000
|
|
46
|
-
# if mongosh --host mongodb-0.mongodb-service:27017 --eval "rs.status()" | grep -q "not yet initialized"; then
|
|
47
|
-
# mongosh --host mongodb-0.mongodb-service:27017 <<EOF
|
|
48
|
-
# use admin;
|
|
49
|
-
# rs.initiate({
|
|
50
|
-
# _id: "rs0",
|
|
51
|
-
# members: [
|
|
52
|
-
# { _id: 0, host: "mongodb-0.mongodb-service:27017", priority: 1 },
|
|
53
|
-
# { _id: 1, host: "mongodb-1.mongodb-service:27017", priority: 1 }
|
|
54
|
-
# ]
|
|
55
|
-
# });
|
|
56
|
-
# db.getSiblingDB("admin").createUser({
|
|
57
|
-
# user: process.env.MONGO_INITDB_ROOT_USERNAME,
|
|
58
|
-
# pwd: process.env.MONGO_INITDB_ROOT_PASSWORD,
|
|
59
|
-
# roles: [{ role: "userAdminAnyDatabase", db: "admin" }]
|
|
60
|
-
# });
|
|
61
|
-
# use default;
|
|
62
|
-
# db.createUser(
|
|
63
|
-
# {
|
|
64
|
-
# user: process.env.MONGO_INITDB_ROOT_USERNAME,
|
|
65
|
-
# pwd: process.env.MONGO_INITDB_ROOT_PASSWORD,
|
|
66
|
-
# roles: [
|
|
67
|
-
# { role: "read", db: "test" },
|
|
68
|
-
# { role: "readWrite", db: "default" }
|
|
69
|
-
# ]
|
|
70
|
-
# }
|
|
71
|
-
# );
|
|
72
|
-
# EOF
|
|
73
|
-
# fi
|
|
74
|
-
# wait
|
|
58
|
+
|
|
75
59
|
ports:
|
|
76
60
|
- containerPort: 27017
|
|
77
61
|
volumeMounts:
|
|
62
|
+
- name: isolated-runtime-keyfile-volume
|
|
63
|
+
mountPath: /opt/mongodb
|
|
78
64
|
- name: mongodb-storage
|
|
79
65
|
mountPath: /data/db
|
|
80
|
-
- name: keyfile
|
|
81
|
-
mountPath: /etc/mongodb-keyfile
|
|
82
|
-
readOnly: true
|
|
83
|
-
# - name: mongodb-configuration-file
|
|
84
|
-
# mountPath: /etc/mongod.conf
|
|
85
|
-
# subPath: mongod.conf
|
|
86
|
-
# readOnly: true
|
|
87
|
-
# - name: mongodb-config
|
|
88
|
-
# mountPath: /config
|
|
89
66
|
env:
|
|
67
|
+
- name: MONGO_REPLICA_SET_NAME
|
|
68
|
+
value: rs0
|
|
90
69
|
- name: MONGO_INITDB_ROOT_USERNAME
|
|
91
70
|
valueFrom:
|
|
92
71
|
secretKeyRef:
|
|
@@ -97,6 +76,18 @@ spec:
|
|
|
97
76
|
secretKeyRef:
|
|
98
77
|
name: mongodb-secret
|
|
99
78
|
key: password
|
|
79
|
+
readinessProbe:
|
|
80
|
+
tcpSocket:
|
|
81
|
+
port: 27017
|
|
82
|
+
initialDelaySeconds: 15
|
|
83
|
+
periodSeconds: 10
|
|
84
|
+
timeoutSeconds: 5
|
|
85
|
+
livenessProbe:
|
|
86
|
+
tcpSocket:
|
|
87
|
+
port: 27017
|
|
88
|
+
initialDelaySeconds: 30
|
|
89
|
+
periodSeconds: 20
|
|
90
|
+
timeoutSeconds: 5
|
|
100
91
|
resources:
|
|
101
92
|
requests:
|
|
102
93
|
cpu: '100m'
|
|
@@ -105,16 +96,12 @@ spec:
|
|
|
105
96
|
cpu: '500m'
|
|
106
97
|
memory: '512Mi'
|
|
107
98
|
volumes:
|
|
108
|
-
- name: keyfile
|
|
99
|
+
- name: raw-secret-keyfile-volume
|
|
109
100
|
secret:
|
|
110
101
|
secretName: mongodb-keyfile
|
|
111
102
|
defaultMode: 0400
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
# name: mongodb-config-file
|
|
115
|
-
# - name: mongodb-config
|
|
116
|
-
# configMap:
|
|
117
|
-
# name: mongodb-config
|
|
103
|
+
- name: isolated-runtime-keyfile-volume
|
|
104
|
+
emptyDir: {}
|
|
118
105
|
volumeClaimTemplates:
|
|
119
106
|
- metadata:
|
|
120
107
|
name: mongodb-storage
|