underpost 2.8.44 → 2.8.451

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.
Files changed (36) hide show
  1. package/.vscode/settings.json +2 -0
  2. package/CHANGELOG.md +16 -0
  3. package/Dockerfile +3 -24
  4. package/bin/build.js +31 -0
  5. package/bin/file.js +15 -13
  6. package/bin/index.js +100 -40
  7. package/docker-compose.yml +1 -1
  8. package/manifests/mongodb/backup-access.yaml +16 -0
  9. package/manifests/mongodb/backup-cronjob.yaml +40 -0
  10. package/manifests/mongodb/backup-pv-pvc.yaml +22 -0
  11. package/manifests/mongodb/configmap.yaml +26 -0
  12. package/manifests/mongodb/headless-service.yaml +10 -0
  13. package/manifests/mongodb/kustomization.yaml +11 -0
  14. package/manifests/mongodb/pv-pvc.yaml +23 -0
  15. package/manifests/mongodb/statefulset.yaml +125 -0
  16. package/manifests/valkey/kustomization.yaml +2 -2
  17. package/manifests/valkey/service.yaml +17 -0
  18. package/manifests/valkey/statefulset.yaml +39 -0
  19. package/package.json +9 -3
  20. package/src/cli/cluster.js +154 -0
  21. package/src/cli/env.js +52 -0
  22. package/src/cli/image.js +118 -0
  23. package/src/cli/repository.js +108 -0
  24. package/src/cli/script.js +29 -0
  25. package/src/cli/secrets.js +37 -0
  26. package/src/cli/test.js +32 -0
  27. package/src/client/components/core/CommonJs.js +73 -1
  28. package/src/client/components/core/Input.js +1 -1
  29. package/src/client/components/core/Scroll.js +1 -0
  30. package/src/index.js +53 -24
  31. package/src/server/conf.js +6 -208
  32. package/src/server/logger.js +2 -3
  33. package/src/server/network.js +1 -1
  34. package/startup.cjs +0 -12
  35. /package/manifests/deployment/{mongo-express.yaml → mongo-express/deployment.yaml} +0 -0
  36. /package/manifests/deployment/{phpmyadmin.yaml → phpmyadmin/deployment.yaml} +0 -0
@@ -59,9 +59,11 @@
59
59
  "runas",
60
60
  "Scatterplot",
61
61
  "sortablejs",
62
+ "statefulset",
62
63
  "supervisord",
63
64
  "Tokenomics",
64
65
  "underpost",
66
+ "underpostnet",
65
67
  "Unequip",
66
68
  "uuidv",
67
69
  "Valkey",
package/CHANGELOG.md CHANGED
@@ -4,6 +4,22 @@ All notable changes to this project will be documented in this file. Dates are d
4
4
 
5
5
  Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).
6
6
 
7
+ #### [v2.8.44](https://github.com/underpostnet/engine/compare/v2.8.42...v2.8.44)
8
+
9
+ > 18 February 2025
10
+
11
+ - ci(package-pwa-microservices-template): ⚙️ update version 2.8.44 [`1d1731d`](https://github.com/underpostnet/engine/commit/1d1731d8c81389f9ba6a308af9a66e455baa8fad)
12
+ - ci(package-pwa-microservices-template): ⚙️ Changes to our CI configuration files and scripts (example scopes: Travis, Circle, BrowserStack, SauceLabs) [`1c2cc3e`](https://github.com/underpostnet/engine/commit/1c2cc3ed8c96c1d7d219f112692397de14aea172)
13
+ - ci(package-pwa-microservices-template): ⚙️ add underpost cli root env management [`1923fb6`](https://github.com/underpostnet/engine/commit/1923fb6b32c1d2df1564fb94d3475b4ef0400f99)
14
+
15
+ #### [v2.8.42](https://github.com/underpostnet/engine/compare/v2.8.31...v2.8.42)
16
+
17
+ > 18 February 2025
18
+
19
+ - ci(engine-lampp-repo-build): ⚙️ Changes to our CI configuration files and scripts (example scopes: Travis, Circle, BrowserStack, SauceLabs) [`cd076c0`](https://github.com/underpostnet/engine/commit/cd076c095fde19caf744e5e04e419973670fbc6c)
20
+ - ci(engine-cyberia-repo-build): ⚙️ Changes to our CI configuration files and scripts (example scopes: Travis, Circle, BrowserStack, SauceLabs) [`69d55e2`](https://github.com/underpostnet/engine/commit/69d55e2d9f8f93252561c17747472f12c6369e1c)
21
+ - ci(engine-core-repo-build): ⚙️ Changes to our CI configuration files and scripts (example scopes: Travis, Circle, BrowserStack, SauceLabs) [`b031b0f`](https://github.com/underpostnet/engine/commit/b031b0f65884d9d908143e2d609ea8b0f30828a0)
22
+
7
23
  #### [v2.8.31](https://github.com/underpostnet/engine/compare/v2.8.1...v2.8.31)
8
24
 
9
25
  > 5 February 2025
package/Dockerfile CHANGED
@@ -37,33 +37,12 @@ RUN apt-get install -y nodejs build-essential
37
37
  RUN node --version
38
38
  RUN npm --version
39
39
 
40
- # local test
41
-
42
- # COPY . .
43
-
44
- # RUN npm install
45
-
46
- # VOLUME [ "/code/logs" ]
47
- # EXPOSE 22
48
-
49
- # EXPOSE 4000-4004
50
- # CMD [ "npm", "run", "dev" ]
51
-
52
- # EXPOSE 3000-3004
53
- # CMD [ "npm", "start" ]
54
-
55
- # package
56
-
57
- # Install underpost cli
58
-
59
40
  RUN npm install -g underpost
60
- RUN npm install shelljs
61
- COPY startup.cjs /code/startup.cjs
62
41
 
63
42
  VOLUME [ "/code/app/logs" ]
64
43
 
65
- EXPOSE 22 80 443 3306 27017
66
- # EXPOSE 22
44
+ EXPOSE 22
45
+
67
46
  EXPOSE 4000-4004
68
47
 
69
- CMD [ "node", "./startup.cjs" ]
48
+ CMD [ "underpost", "new", "app" ]
package/bin/build.js CHANGED
@@ -35,6 +35,13 @@ logger.info('', {
35
35
 
36
36
  if (process.argv.includes('info')) process.exit(0);
37
37
 
38
+ if (process.argv.includes('clean')) {
39
+ if (fs.existsSync(`${basePath}/images`)) fs.copySync(`${basePath}/images`, `./images`);
40
+ shellExec(`cd ${basePath} && git checkout .`);
41
+ shellExec(`cd ${basePath} && git clean -f -d`);
42
+ process.exit(0);
43
+ }
44
+
38
45
  if (process.argv.includes('proxy')) {
39
46
  const env = process.argv.includes('development') ? 'development' : 'production';
40
47
  process.env.NODE_ENV = env;
@@ -280,4 +287,28 @@ const { DefaultConf } = await import(`../conf.${confName}.js`);
280
287
  JSON.stringify(packageJson, null, 4).replaceAll('pwa-microservices-template', repoName),
281
288
  'utf8',
282
289
  );
290
+
291
+ fs.copySync(`./src/cli`, `${basePath}/src/cli`);
292
+ if (!fs.existsSync(`${basePath}/images`)) fs.mkdirSync(`${basePath}/images`);
293
+
294
+ const env = process.argv.includes('development') ? 'development' : 'production';
295
+
296
+ // remove engine-private of .dockerignore for local testing
297
+
298
+ {
299
+ fs.removeSync(`${basePath}/manifests/deployment`);
300
+
301
+ if (!fs.existsSync(`./manifests/deployment/${confName}-${env}`))
302
+ fs.mkdirSync(`./manifests/deployment/${confName}-${env}`);
303
+
304
+ for (const file of ['Dockerfile', 'proxy.yaml', 'deployment.yaml', 'secret.yaml']) {
305
+ if (fs.existsSync(`./engine-private/conf/${confName}/build/${env}/${file}`)) {
306
+ fs.copyFileSync(`./engine-private/conf/${confName}/build/${env}/${file}`, `${basePath}/${file}`);
307
+ fs.copyFileSync(
308
+ `./engine-private/conf/${confName}/build/${env}/${file}`,
309
+ `./manifests/deployment/${confName}-${env}/${file}`,
310
+ );
311
+ }
312
+ }
313
+ }
283
314
  }
package/bin/file.js CHANGED
@@ -25,16 +25,8 @@ let name = getCapVariableName(file.split('.')[0]);
25
25
  logger.info('File metadata', { path, file, ext, name });
26
26
 
27
27
  try {
28
- // throw '';
29
- // let cmd;
30
28
  let content = '';
31
29
  switch (type) {
32
- case 'create-js-module':
33
- // node bin/file './src/client/components/core/progress bar.js'
34
- content = `const ${name} = {}; export { ${name} }`;
35
- setTimeout(() => shellExec(`prettier --write ${buildPath}`));
36
- break;
37
-
38
30
  case 'update-template':
39
31
  case 'copy-src':
40
32
  console.log({ rawPath, toPath });
@@ -77,10 +69,9 @@ try {
77
69
  fs.copySync(`./.github`, `../pwa-microservices-template/.github`);
78
70
  fs.copySync(`./src/client/public/default`, `../pwa-microservices-template/src/client/public/default`);
79
71
 
80
- shellCd('../pwa-microservices-template');
81
- for (const deletePath of ['README.md', 'package-lock.json', 'package.json']) {
82
- shellExec(`git checkout ${deletePath}`);
83
- }
72
+ for (const checkoutPath of ['README.md', 'package-lock.json', 'package.json'])
73
+ shellExec(`cd ../pwa-microservices-template && git checkout ${checkoutPath}`);
74
+
84
75
  for (const deletePath of [
85
76
  '.github/workflows/coverall.yml',
86
77
  '.github/workflows/docker-image.yml',
@@ -94,12 +85,23 @@ try {
94
85
  ]) {
95
86
  fs.removeSync('../pwa-microservices-template/' + deletePath);
96
87
  }
97
- shellCd('../engine');
98
88
  const originPackageJson = JSON.parse(fs.readFileSync('./package.json', 'utf8'));
99
89
  const templatePackageJson = JSON.parse(fs.readFileSync('../pwa-microservices-template/package.json', 'utf8'));
90
+
91
+ const name = templatePackageJson.name;
92
+ const description = templatePackageJson.description;
93
+ const dev = templatePackageJson.scripts.dev;
94
+ const build = templatePackageJson.scripts.build;
95
+
100
96
  templatePackageJson.dependencies = originPackageJson.dependencies;
101
97
  templatePackageJson.devDependencies = originPackageJson.devDependencies;
102
98
  templatePackageJson.version = originPackageJson.version;
99
+ templatePackageJson.scripts = originPackageJson.scripts;
100
+ templatePackageJson.name = name;
101
+ templatePackageJson.description = description;
102
+ templatePackageJson.scripts.dev = dev;
103
+ templatePackageJson.scripts.build = build;
104
+ delete templatePackageJson.scripts['update-template'];
103
105
  fs.writeFileSync(
104
106
  '../pwa-microservices-template/package.json',
105
107
  JSON.stringify(templatePackageJson, null, 4),
package/bin/index.js CHANGED
@@ -4,17 +4,10 @@ import dotenv from 'dotenv';
4
4
  import { Command } from 'commander';
5
5
  import { loggerFactory } from '../src/server/logger.js';
6
6
  import Underpost from '../src/index.js';
7
- import {
8
- getNpmRootPath,
9
- loadConf,
10
- newProject,
11
- repoClone,
12
- repoCommit,
13
- repoPull,
14
- repoPush,
15
- UnderpostRootEnv,
16
- } from '../src/server/conf.js';
7
+ import { getNpmRootPath, loadConf } from '../src/server/conf.js';
17
8
  import fs from 'fs-extra';
9
+ import { commitData } from '../src/client/components/core/CommonJs.js';
10
+ import UnderpostScript from '../src/cli/script.js';
18
11
 
19
12
  const npmRoot = getNpmRootPath();
20
13
  const underpostRoot = `${npmRoot}/underpost/.env`;
@@ -24,62 +17,129 @@ const logger = loggerFactory(import.meta);
24
17
 
25
18
  const program = new Command();
26
19
 
27
- program.name('underpost').description(`underpost.net ci/cd cli ${Underpost.version}`).version(Underpost.version);
20
+ program.name('underpost').description(`underpost ci/cd cli ${Underpost.version}`).version(Underpost.version);
28
21
 
29
22
  program
30
- .command('new <app-name>')
23
+ .command('new')
24
+ .argument('<app-name>', 'Application name')
31
25
  .description('Create a new project')
32
- .action((...args) => ((args[1] = Underpost.version), newProject(...args)));
26
+ .action(Underpost.repo.new);
33
27
 
34
28
  program
35
- .command('clone <uri>')
36
- .description('Clone github repository, if your GITHUB_TOKEN environment exists, it will be used')
37
- .action(repoClone);
29
+ .command('clone')
30
+ .argument(`<uri>`, 'e.g. username/repository')
31
+ .description('Clone github repository')
32
+ .action(Underpost.repo.clone);
38
33
 
39
34
  program
40
- .command('pull <path> <uri>')
41
- .description('Pull github repository, if your GITHUB_TOKEN environment exists, it will be used')
42
- .action(repoPull);
35
+ .command('pull')
36
+ .argument('<path>', 'Absolute or relative directory')
37
+ .argument(`<uri>`, 'e.g. username/repository')
38
+ .description('Pull github repository')
39
+ .action(Underpost.repo.pull);
43
40
 
44
41
  program
45
- .option('--copy')
46
- .option('--info')
47
- .option('--empty')
48
- .command('cmt <path> [commit-type] [sub-module] [message]')
49
- .description(
50
- 'Commit github repository, if your GITHUB_TOKEN environment exists, it will be used, use --copy will copy to clipboard message, use --info will see info commit types, use --empty will allow empty files',
51
- )
52
- .action((...args) => ((args[4] = options), repoCommit(...args)));
42
+ .command('cmt')
43
+ .argument('<path>', 'Absolute or relative directory')
44
+ .argument(`<commit-type>`, `Options: ${Object.keys(commitData)}`)
45
+ .argument(`[module-tag]`, 'Optional set module tag')
46
+ .argument(`[message]`, 'Optional set additional message')
47
+ .option('--empty', 'Allow empty files')
48
+ .option('--copy', 'Copy to clipboard message')
49
+ .option('--info', 'Info commit types')
50
+ .description('Commit github repository')
51
+ .action(Underpost.repo.commit);
53
52
 
54
53
  program
55
- .command('push <path> <uri>')
56
- .description('Push github repository, if your GITHUB_TOKEN environment exists, it will be used')
57
- .action(repoPush);
54
+ .command('push')
55
+ .argument('<path>', 'Absolute or relative directory')
56
+ .argument(`<uri>`, 'e.g. username/repository')
57
+ .option('-f', 'Force push overwriting repository')
58
+ .description('Push github repository')
59
+ .action(Underpost.repo.push);
58
60
 
59
61
  program
60
- .command('env <deploy-id> [env]')
62
+ .command('env')
63
+ .argument('<deploy-id>', 'deploy configuration id')
64
+ .argument('[env]', 'Optional environment, for default is production')
61
65
  .description('Set environment variables files and conf related to <deploy-id>')
62
66
  .action(loadConf);
63
67
 
64
68
  program
65
- .command('config <operator> [key] [value]')
66
- .description(`Manage configuration, operators available: ${Object.keys(UnderpostRootEnv)}`)
67
- .action((...args) => UnderpostRootEnv[args[0]](args[1], args[2]));
69
+ .command('config')
70
+ .argument('operator', `Options: ${Object.keys(Underpost.env)}`)
71
+ .argument('[key]', 'Config key')
72
+ .argument('[value]', 'Config value')
73
+ .description(`Manage configuration, operators`)
74
+ .action((...args) => Underpost.env[args[0]](args[1], args[2]));
68
75
 
69
76
  program
70
77
  .command('root')
71
78
  .description('Get npm root path')
72
79
  .action(() => console.log(getNpmRootPath()));
73
80
 
74
- program.command('test').description('Run tests').action(Underpost.runTest);
81
+ program
82
+ .command('cluster')
83
+ .option('--reset', `Delete all clusters and prune all data and caches`)
84
+ .option('--mariadb', 'Init with mariadb statefulset')
85
+ .option('--mongodb', 'Init with mongodb statefulset')
86
+ .option('--valkey', 'Init with valkey service')
87
+ .option('--contour', 'Init with project contour base HTTPProxy and envoy')
88
+ .option('--info', 'Get all kinds objects deployed')
89
+ .option('--full', 'Init with all statefulsets and services available')
90
+ .option('--ns-use <ns-name>', 'Switches current context to namespace')
91
+ .action((...args) => {
92
+ if (args[0].reset) return Underpost.cluster.reset();
93
+ return Underpost.cluster.init(args[0]);
94
+ })
95
+ .description('Manage cluster, for default initialization base kind cluster');
75
96
 
76
97
  program
77
- .command('help')
78
- .description('Display help information')
79
- .action(() => {
80
- program.outputHelp();
98
+ .command('secret')
99
+ .argument('<platform>', `Options: ${Object.keys(Underpost.secret)}`)
100
+ .option('--init', 'Init secrets platform environment')
101
+ .option('--create-from-file <path-env-file>', 'Create secret from env file')
102
+ .option('--list', 'Lists secrets')
103
+ // .option('--delete [secret-key]', 'Delete key secret, if not set, are default delete all')
104
+ // .option('--create [secret-key] [secret-value]', 'Create secret key, with secret value')
105
+ .description(`Manage secrets`)
106
+ .action((...args) => {
107
+ if (args[1].createFromFile) return Underpost.secret[args[0]].createFromEnvFile(args[1].createFromFile);
108
+ if (args[1].list) return Underpost.secret[args[0]].list();
109
+ if (args[1].init) return Underpost.secret[args[0]].init();
81
110
  });
82
111
 
83
- const options = program.opts();
112
+ program
113
+ .command('dockerfile-node-script')
114
+ .argument('<deploy-id>', 'Deploy configuration id')
115
+ .argument('[env]', 'Optional environment, for default is development')
116
+ .description('Dockerfile custom node build script')
117
+ .action(Underpost.image.dockerfile.script);
118
+
119
+ program
120
+ .command('dockerfile-image-build')
121
+ .argument('<deploy-id>', 'Deploy configuration id')
122
+ .argument('[env]', 'Optional environment, for default is development')
123
+ .argument('[path]', 'Absolute or relative directory, for default is current')
124
+ .option('--image-archive', 'Only load tar image from /images')
125
+ .description('Build image from Dockerfile')
126
+ .action(Underpost.image.dockerfile.build);
127
+
128
+ program
129
+ .command('dockerfile-pull-base-images')
130
+ .description('Pull underpost dockerfile images requirements')
131
+ .action(Underpost.image.dockerfile.pullBaseImages);
132
+
133
+ program
134
+ .command('script')
135
+ .argument('operator', `Options: ${Object.keys(UnderpostScript.API)}`)
136
+ .argument('<script-name>', 'Script name')
137
+ .argument('[script-value]', 'Literal command')
138
+ .description(
139
+ 'Supports a number of built-in underpost global scripts and their preset life cycle events as well as arbitrary scripts',
140
+ )
141
+ .action((...args) => Underpost.script[args[0]](args[1], args[2]));
142
+
143
+ program.command('test').description('Run tests').action(Underpost.test.run);
84
144
 
85
145
  program.parse();
@@ -58,7 +58,7 @@ services:
58
58
  cpus: '0.25'
59
59
  memory: 20M
60
60
  labels: # labels in Compose file instead of Dockerfile
61
- engine.version: '2.8.44'
61
+ engine.version: '2.8.451'
62
62
  networks:
63
63
  - load-balancer
64
64
 
@@ -0,0 +1,16 @@
1
+ apiVersion: v1
2
+ kind: Pod
3
+ metadata:
4
+ name: backup-access
5
+ spec:
6
+ containers:
7
+ - name: busybox
8
+ image: busybox
9
+ command: ['sh', '-c', 'sleep 3600']
10
+ volumeMounts:
11
+ - name: backup-storage
12
+ mountPath: /backup
13
+ volumes:
14
+ - name: backup-storage
15
+ persistentVolumeClaim:
16
+ claimName: backup-pvc
@@ -0,0 +1,40 @@
1
+ apiVersion: batch/v1
2
+ kind: CronJob
3
+ metadata:
4
+ name: mongodb-backup
5
+ spec:
6
+ schedule: '*/5 * * * *' # Runs backup every five minutes
7
+ jobTemplate:
8
+ spec:
9
+ template:
10
+ spec:
11
+ containers:
12
+ - name: mongodump
13
+ image: docker.io/library/mongo:latest
14
+ command:
15
+ - sh
16
+ - -c
17
+ - |
18
+ # Perform backup
19
+ mongodump -u $MONGO_INITDB_ROOT_USERNAME -p $MONGO_INITDB_ROOT_PASSWORD --host=mongodb-service --port=27017 --out=/backup/$(date +\%Y-\%m-\%dT\%H-\%M-\%S)
20
+ # Remove backups older than 7 days
21
+ find /backup -type d -mtime +7 -exec rm -rf {} +
22
+ volumeMounts:
23
+ - name: backup-storage
24
+ mountPath: /backup
25
+ env:
26
+ - name: MONGO_INITDB_ROOT_USERNAME
27
+ valueFrom:
28
+ secretKeyRef:
29
+ name: mongodb-secret
30
+ key: username
31
+ - name: MONGO_INITDB_ROOT_PASSWORD
32
+ valueFrom:
33
+ secretKeyRef:
34
+ name: mongodb-secret
35
+ key: password
36
+ restartPolicy: Never
37
+ volumes:
38
+ - name: backup-storage
39
+ persistentVolumeClaim:
40
+ claimName: backup-pvc
@@ -0,0 +1,22 @@
1
+ apiVersion: v1
2
+ kind: PersistentVolume
3
+ metadata:
4
+ name: backup-pv
5
+ spec:
6
+ capacity:
7
+ storage: 5Gi
8
+ accessModes:
9
+ - ReadWriteOnce
10
+ hostPath:
11
+ path: /mnt/backup
12
+ ---
13
+ apiVersion: v1
14
+ kind: PersistentVolumeClaim
15
+ metadata:
16
+ name: backup-pvc
17
+ spec:
18
+ accessModes:
19
+ - ReadWriteOnce
20
+ resources:
21
+ requests:
22
+ storage: 5Gi
@@ -0,0 +1,26 @@
1
+ # origin conf: /etc/mongod.conf
2
+ apiVersion: v1
3
+ kind: ConfigMap
4
+ metadata:
5
+ name: mongodb-config-file
6
+ namespace: default
7
+ data:
8
+ mongod.conf: |
9
+ storage:
10
+ dbPath: /data/db
11
+ systemLog:
12
+ destination: file
13
+ logAppend: true
14
+ path: /var/log/mongodb/mongod.log
15
+ replication:
16
+ replSetName: rs0
17
+ net:
18
+ bindIp: 127.0.0.1
19
+ port: 27017
20
+ processManagement:
21
+ fork: true
22
+ setParameter:
23
+ enableLocalhostAuthBypass: false
24
+ security:
25
+ authorization: enabled
26
+ keyFile: /etc/mongodb-keyfile
@@ -0,0 +1,10 @@
1
+ apiVersion: v1
2
+ kind: Service
3
+ metadata:
4
+ name: mongodb-service
5
+ spec:
6
+ clusterIP: None
7
+ selector:
8
+ app: mongodb
9
+ ports:
10
+ - port: 27017
@@ -0,0 +1,11 @@
1
+ ---
2
+ # kubectl apply -k core/.
3
+ apiVersion: kustomize.config.k8s.io/v1beta1
4
+ kind: Kustomization
5
+ resources:
6
+ - pv-pvc.yaml
7
+ - headless-service.yaml
8
+ - statefulset.yaml
9
+ - backup-pv-pvc.yaml
10
+ - backup-cronjob.yaml
11
+ - backup-access.yaml
@@ -0,0 +1,23 @@
1
+ apiVersion: v1
2
+ kind: PersistentVolume
3
+ metadata:
4
+ name: mongodb-pv
5
+ spec:
6
+ capacity:
7
+ storage: 5Gi
8
+ accessModes:
9
+ - ReadWriteOnce
10
+ hostPath:
11
+ path: /data/mongodb
12
+ ---
13
+ apiVersion: v1
14
+ kind: PersistentVolumeClaim
15
+ metadata:
16
+ name: mongodb-pvc
17
+ spec:
18
+ storageClassName: ''
19
+ accessModes:
20
+ - ReadWriteOnce
21
+ resources:
22
+ requests:
23
+ storage: 5Gi
@@ -0,0 +1,125 @@
1
+ apiVersion: apps/v1
2
+ kind: StatefulSet
3
+ metadata:
4
+ name: mongodb # Specifies the name of the statefulset
5
+ spec:
6
+ serviceName: 'mongodb-service' # Specifies the service to use
7
+ replicas: 2
8
+ selector:
9
+ matchLabels:
10
+ app: mongodb
11
+ template:
12
+ metadata:
13
+ labels:
14
+ app: mongodb
15
+ spec:
16
+ containers:
17
+ - name: mongodb
18
+ image: docker.io/library/mongo:latest
19
+ command:
20
+ - mongod
21
+ - '--replSet'
22
+ - 'rs0'
23
+ # - '--config'
24
+ # - '-f'
25
+ # - '/etc/mongod.conf'
26
+ # - '--auth'
27
+ # - '--clusterAuthMode'
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'
40
+ - '--bind_ip_all'
41
+ # command: ['sh', '-c']
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
75
+ ports:
76
+ - containerPort: 27017
77
+ volumeMounts:
78
+ - name: mongodb-storage
79
+ 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
+ env:
90
+ - name: MONGO_INITDB_ROOT_USERNAME
91
+ valueFrom:
92
+ secretKeyRef:
93
+ name: mongodb-secret
94
+ key: username
95
+ - name: MONGO_INITDB_ROOT_PASSWORD
96
+ valueFrom:
97
+ secretKeyRef:
98
+ name: mongodb-secret
99
+ key: password
100
+ resources:
101
+ requests:
102
+ cpu: '100m'
103
+ memory: '256Mi'
104
+ limits:
105
+ cpu: '500m'
106
+ memory: '512Mi'
107
+ volumes:
108
+ - name: keyfile
109
+ secret:
110
+ secretName: mongodb-keyfile
111
+ defaultMode: 0400
112
+ # - name: mongodb-configuration-file
113
+ # configMap:
114
+ # name: mongodb-config-file
115
+ # - name: mongodb-config
116
+ # configMap:
117
+ # name: mongodb-config
118
+ volumeClaimTemplates:
119
+ - metadata:
120
+ name: mongodb-storage
121
+ spec:
122
+ accessModes: ['ReadWriteOnce']
123
+ resources:
124
+ requests:
125
+ storage: 5Gi
@@ -3,5 +3,5 @@
3
3
  apiVersion: kustomize.config.k8s.io/v1beta1
4
4
  kind: Kustomization
5
5
  resources:
6
- - underpost-engine-valkey-service.yaml
7
- - underpost-engine-valkey-statefulset.yaml
6
+ - service.yaml
7
+ - statefulset.yaml
@@ -0,0 +1,17 @@
1
+ ---
2
+ apiVersion: v1
3
+ kind: Service
4
+ metadata:
5
+ name: service-valkey
6
+ namespace: default
7
+ spec:
8
+ ports:
9
+ - port: 6379
10
+ targetPort: 6379
11
+ selector:
12
+ app: service-valkey
13
+ ipFamilyPolicy: PreferDualStack
14
+ ipFamilies:
15
+ - IPv4
16
+ # - IPv6
17
+ type: ClusterIP