underpost 2.8.52 → 2.8.56
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/ghpkg.yml +1 -1
- package/.github/workflows/npmpkg.yml +1 -1
- package/.github/workflows/pwa-microservices-template.page.yml +1 -1
- package/CHANGELOG.md +24 -0
- package/bin/build.js +29 -4
- package/bin/deploy.js +64 -52
- package/bin/hwt.js +0 -10
- package/bin/index.js +38 -16
- package/bin/util.js +0 -7
- package/conf.js +0 -2
- package/docker-compose.yml +1 -1
- package/manifests/kind-config-dev.yaml +12 -0
- package/manifests/mongodb-4.4/kustomization.yaml +7 -0
- package/manifests/mongodb-4.4/service-deployment.yaml +63 -0
- package/package.json +9 -7
- package/src/cli/cluster.js +71 -45
- package/src/cli/cron.js +1 -1
- package/src/cli/db.js +6 -4
- package/src/cli/deploy.js +43 -30
- package/src/cli/fs.js +134 -0
- package/src/cli/image.js +1 -18
- package/src/cli/repository.js +13 -0
- package/src/cli/script.js +25 -1
- package/src/cli/test.js +39 -4
- package/src/db/mongo/MongooseDB.js +17 -1
- package/src/index.js +9 -1
- package/src/server/backup.js +2 -2
- package/src/server/client-formatted.js +2 -1
- package/src/server/conf.js +4 -10
- package/src/server/dns.js +39 -46
- package/src/server/downloader.js +0 -8
- package/test/api.test.js +0 -8
- package/manifests/core/kustomization.yaml +0 -11
- package/manifests/core/underpost-engine-backup-access.yaml +0 -16
- package/manifests/core/underpost-engine-backup-pv-pvc.yaml +0 -22
- package/manifests/core/underpost-engine-headless-service.yaml +0 -10
- package/manifests/core/underpost-engine-mongodb-backup-cronjob.yaml +0 -40
- package/manifests/core/underpost-engine-mongodb-configmap.yaml +0 -26
- package/manifests/core/underpost-engine-statefulset.yaml +0 -91
- /package/manifests/{core/underpost-engine-pv-pvc.yaml → mongodb-4.4/pv-pvc.yaml} +0 -0
|
@@ -79,7 +79,19 @@ const MongooseDB = {
|
|
|
79
79
|
if (process.argv.includes('rocky')) {
|
|
80
80
|
// https://github.com/mongodb/mongodb-selinux
|
|
81
81
|
// https://www.mongodb.com/docs/v7.0/tutorial/install-mongodb-enterprise-on-red-hat/
|
|
82
|
-
|
|
82
|
+
// https://www.mongodb.com/docs/v6.0/tutorial/install-mongodb-on-red-hat/
|
|
83
|
+
// https://www.mongodb.com/docs/v4.4/tutorial/install-mongodb-on-red-hat/
|
|
84
|
+
// dnf install selinux-policy-devel
|
|
85
|
+
// git clone https://github.com/mongodb/mongodb-selinux
|
|
86
|
+
// cd mongodb-selinux
|
|
87
|
+
// make
|
|
88
|
+
// sudo make install
|
|
89
|
+
// yum list installed | grep mongo
|
|
90
|
+
// sudo yum erase $(rpm -qa | grep mongodb)
|
|
91
|
+
// remove service
|
|
92
|
+
// sudo systemctl reset-failed
|
|
93
|
+
// MongoDB 5.0+ requires a CPU with AVX support
|
|
94
|
+
// check: grep avx /proc/cpuinfo
|
|
83
95
|
}
|
|
84
96
|
logger.info('install legacy 4.4');
|
|
85
97
|
shellExec(`wget -qO - https://www.mongodb.org/static/pgp/server-4.4.asc | sudo apt-key add -`);
|
|
@@ -112,9 +124,13 @@ const MongooseDB = {
|
|
|
112
124
|
shellExec(`sudo systemctl unmask mongod`);
|
|
113
125
|
shellExec(`sudo pkill -f mongod`);
|
|
114
126
|
shellExec(`sudo systemctl enable mongod.service`);
|
|
127
|
+
|
|
115
128
|
shellExec(`sudo chown -R mongodb:mongodb /var/lib/mongodb`);
|
|
116
129
|
shellExec(`sudo chown mongodb:mongodb /tmp/mongodb-27017.sock`);
|
|
117
130
|
|
|
131
|
+
shellExec(`sudo chown -R mongod:mongod /var/lib/mongodb`);
|
|
132
|
+
shellExec(`sudo chown mongod:mongod /tmp/mongodb-27017.sock`);
|
|
133
|
+
|
|
118
134
|
logger.info('run server');
|
|
119
135
|
shellExec(`sudo service mongod restart`);
|
|
120
136
|
|
package/src/index.js
CHANGED
|
@@ -9,6 +9,7 @@ import UnderpostCron from './cli/cron.js';
|
|
|
9
9
|
import UnderpostDB from './cli/db.js';
|
|
10
10
|
import UnderpostDeploy from './cli/deploy.js';
|
|
11
11
|
import UnderpostRootEnv from './cli/env.js';
|
|
12
|
+
import UnderpostFileStorage from './cli/fs.js';
|
|
12
13
|
import UnderpostImage from './cli/image.js';
|
|
13
14
|
import UnderpostRepository from './cli/repository.js';
|
|
14
15
|
import UnderpostScript from './cli/script.js';
|
|
@@ -27,7 +28,7 @@ class Underpost {
|
|
|
27
28
|
* @type {String}
|
|
28
29
|
* @memberof Underpost
|
|
29
30
|
*/
|
|
30
|
-
static version = 'v2.8.
|
|
31
|
+
static version = 'v2.8.56';
|
|
31
32
|
/**
|
|
32
33
|
* Repository cli API
|
|
33
34
|
* @static
|
|
@@ -98,6 +99,13 @@ class Underpost {
|
|
|
98
99
|
* @memberof Underpost
|
|
99
100
|
*/
|
|
100
101
|
static cron = UnderpostCron.API;
|
|
102
|
+
/**
|
|
103
|
+
* File Storage cli API
|
|
104
|
+
* @static
|
|
105
|
+
* @type {UnderpostFileStorage.API}
|
|
106
|
+
* @memberof UnderpostFileStorage
|
|
107
|
+
*/
|
|
108
|
+
static fs = UnderpostFileStorage.API;
|
|
101
109
|
}
|
|
102
110
|
|
|
103
111
|
const up = Underpost;
|
package/src/server/backup.js
CHANGED
|
@@ -9,7 +9,7 @@ dotenv.config();
|
|
|
9
9
|
const logger = loggerFactory(import.meta);
|
|
10
10
|
|
|
11
11
|
class BackUp {
|
|
12
|
-
static callback = async function (deployList, options = {
|
|
12
|
+
static callback = async function (deployList, options = { itc: false }) {
|
|
13
13
|
if ((!deployList || deployList === 'dd') && fs.existsSync(`./engine-private/deploy/dd.router`))
|
|
14
14
|
deployList = fs.readFileSync(`./engine-private/deploy/dd.router`, 'utf8');
|
|
15
15
|
|
|
@@ -25,7 +25,7 @@ class BackUp {
|
|
|
25
25
|
const deployId = _deployId.trim();
|
|
26
26
|
if (!deployId) continue;
|
|
27
27
|
|
|
28
|
-
if (options.
|
|
28
|
+
if (!(options.itc === true)) {
|
|
29
29
|
shellExec(`underpost db --export ${deployId}`);
|
|
30
30
|
continue;
|
|
31
31
|
}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import fs from 'fs-extra';
|
|
4
4
|
import vm from 'node:vm';
|
|
5
|
+
import Underpost from '../index.js';
|
|
5
6
|
|
|
6
7
|
const srcFormatted = (src) =>
|
|
7
8
|
src
|
|
@@ -49,7 +50,7 @@ const viewFormatted = (src, dists, proxyPath, baseHost = '') => {
|
|
|
49
50
|
};
|
|
50
51
|
|
|
51
52
|
const ssrFactory = async (componentPath = `./src/client/ssr/Render.js`) => {
|
|
52
|
-
const context = { SrrComponent: () => {}, npm_package_version:
|
|
53
|
+
const context = { SrrComponent: () => {}, npm_package_version: Underpost.version };
|
|
53
54
|
vm.createContext(context);
|
|
54
55
|
vm.runInContext(await srcFormatted(fs.readFileSync(componentPath, 'utf8')), context);
|
|
55
56
|
return context.SrrComponent;
|
package/src/server/conf.js
CHANGED
|
@@ -19,17 +19,8 @@ import { DefaultConf } from '../../conf.js';
|
|
|
19
19
|
import read from 'read';
|
|
20
20
|
import splitFile from 'split-file';
|
|
21
21
|
import axios from 'axios';
|
|
22
|
-
import https from 'https';
|
|
23
22
|
import { ssrFactory } from './client-formatted.js';
|
|
24
23
|
|
|
25
|
-
// axios.defaults.baseURL = BASE_URL;
|
|
26
|
-
|
|
27
|
-
// const httpsAgent = new https.Agent({
|
|
28
|
-
// rejectUnauthorized: false,
|
|
29
|
-
// });
|
|
30
|
-
|
|
31
|
-
// axios.defaults.httpsAgent = httpsAgent;
|
|
32
|
-
|
|
33
24
|
colors.enable();
|
|
34
25
|
|
|
35
26
|
dotenv.config();
|
|
@@ -1004,7 +995,7 @@ const Cmd = {
|
|
|
1004
995
|
syncPorts: (deployGroupId) => `node bin/deploy sync-env-port ${deployGroupId}`,
|
|
1005
996
|
cron: (deployList, jobList, name, expression, options) =>
|
|
1006
997
|
`pm2 start ./bin/index.js --no-autorestart --instances 1 --cron "${expression}" --name ${name} -- cron ${
|
|
1007
|
-
options?.
|
|
998
|
+
options?.itc ? `--itc ` : ''
|
|
1008
999
|
}${deployList} ${jobList}`,
|
|
1009
1000
|
};
|
|
1010
1001
|
|
|
@@ -1082,6 +1073,8 @@ const getNpmRootPath = () =>
|
|
|
1082
1073
|
silent: true,
|
|
1083
1074
|
}).trim();
|
|
1084
1075
|
|
|
1076
|
+
const getUnderpostRootPath = () => `${getNpmRootPath()}/underpost`;
|
|
1077
|
+
|
|
1085
1078
|
const writeEnv = (envPath, envObj) =>
|
|
1086
1079
|
fs.writeFileSync(
|
|
1087
1080
|
envPath,
|
|
@@ -1127,5 +1120,6 @@ export {
|
|
|
1127
1120
|
buildPortProxyRouter,
|
|
1128
1121
|
splitFileFactory,
|
|
1129
1122
|
getNpmRootPath,
|
|
1123
|
+
getUnderpostRootPath,
|
|
1130
1124
|
writeEnv,
|
|
1131
1125
|
};
|
package/src/server/dns.js
CHANGED
|
@@ -1,17 +1,10 @@
|
|
|
1
1
|
import axios from 'axios';
|
|
2
2
|
import dotenv from 'dotenv';
|
|
3
3
|
import fs from 'fs';
|
|
4
|
-
import https from 'https';
|
|
5
4
|
import validator from 'validator';
|
|
6
5
|
import { ip } from './network.js';
|
|
7
6
|
import { loggerFactory } from './logger.js';
|
|
8
|
-
import
|
|
9
|
-
|
|
10
|
-
const httpsAgent = new https.Agent({
|
|
11
|
-
rejectUnauthorized: false,
|
|
12
|
-
});
|
|
13
|
-
|
|
14
|
-
axios.defaults.httpsAgent = httpsAgent;
|
|
7
|
+
import UnderpostRootEnv from '../cli/env.js';
|
|
15
8
|
|
|
16
9
|
dotenv.config();
|
|
17
10
|
|
|
@@ -19,8 +12,8 @@ const logger = loggerFactory(import.meta);
|
|
|
19
12
|
|
|
20
13
|
class Dns {
|
|
21
14
|
static callback = async function (deployList) {
|
|
22
|
-
//
|
|
23
|
-
// LAN
|
|
15
|
+
// Network topology configuration:
|
|
16
|
+
// LAN -> [NAT-VPS](modem/router device) -> WAN
|
|
24
17
|
// enabled DMZ Host to proxy IP 80-443 (79-444) sometimes router block first port
|
|
25
18
|
// disabled local red DHCP
|
|
26
19
|
// verify inet ip proxy server address
|
|
@@ -30,47 +23,47 @@ class Dns {
|
|
|
30
23
|
// Forward the router's TCP/UDP ports to the LAN device's IP address
|
|
31
24
|
for (const _deployId of deployList.split(',')) {
|
|
32
25
|
const deployId = _deployId.trim();
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
26
|
+
const privateCronConfPath = `./engine-private/conf/${deployId}/conf.cron.json`;
|
|
27
|
+
const confCronPath = fs.existsSync(privateCronConfPath) ? privateCronConfPath : './conf/conf.cron.json';
|
|
28
|
+
const confCronData = JSON.parse(fs.readFileSync(confCronPath, 'utf8'));
|
|
36
29
|
|
|
37
|
-
|
|
30
|
+
let testIp;
|
|
38
31
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
const currentIp =
|
|
46
|
-
? fs.readFileSync(`./engine-private/deploy/${ipFileName}`, 'utf8')
|
|
47
|
-
: undefined;
|
|
32
|
+
try {
|
|
33
|
+
testIp = await ip.public.ipv4();
|
|
34
|
+
} catch (error) {
|
|
35
|
+
logger.error(error, { testIp, stack: error.stack });
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const currentIp = UnderpostRootEnv.API.get('ip');
|
|
48
39
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
40
|
+
if (testIp && typeof testIp === 'string' && validator.isIP(testIp) && currentIp !== testIp) {
|
|
41
|
+
logger.info(`new ip`, testIp);
|
|
42
|
+
for (const recordType of Object.keys(confCronData.records)) {
|
|
43
|
+
switch (recordType) {
|
|
44
|
+
case 'A':
|
|
45
|
+
for (const dnsProvider of confCronData.records[recordType]) {
|
|
46
|
+
if (typeof Dns.services.updateIp[dnsProvider.dns] === 'function')
|
|
47
|
+
await Dns.services.updateIp[dnsProvider.dns]({ ...dnsProvider, ip: testIp });
|
|
48
|
+
}
|
|
49
|
+
break;
|
|
59
50
|
|
|
60
|
-
|
|
61
|
-
|
|
51
|
+
default:
|
|
52
|
+
break;
|
|
53
|
+
}
|
|
62
54
|
}
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
55
|
+
try {
|
|
56
|
+
const ipUrlTest = `https://${process.env.DEFAULT_DEPLOY_HOST}`;
|
|
57
|
+
const response = await axios.get(ipUrlTest);
|
|
58
|
+
const verifyIp = response.request.socket.remoteAddress;
|
|
59
|
+
logger.info(ipUrlTest + ' verify ip', verifyIp);
|
|
60
|
+
if (verifyIp === testIp) {
|
|
61
|
+
logger.info('ip updated successfully', testIp);
|
|
62
|
+
UnderpostRootEnv.API.set('ip', testIp);
|
|
63
|
+
} else logger.error('ip not updated', testIp);
|
|
64
|
+
} catch (error) {
|
|
65
|
+
logger.error(error, error.stack);
|
|
66
|
+
logger.error('ip not updated', testIp);
|
|
74
67
|
}
|
|
75
68
|
}
|
|
76
69
|
}
|
package/src/server/downloader.js
CHANGED
|
@@ -2,16 +2,8 @@ import axios from 'axios';
|
|
|
2
2
|
import fs from 'fs';
|
|
3
3
|
import { loggerFactory } from './logger.js';
|
|
4
4
|
import dotenv from 'dotenv';
|
|
5
|
-
import https from 'https';
|
|
6
|
-
|
|
7
5
|
dotenv.config();
|
|
8
6
|
|
|
9
|
-
const httpsAgent = new https.Agent({
|
|
10
|
-
rejectUnauthorized: false,
|
|
11
|
-
});
|
|
12
|
-
|
|
13
|
-
axios.defaults.httpsAgent = httpsAgent;
|
|
14
|
-
|
|
15
7
|
const logger = loggerFactory(import.meta);
|
|
16
8
|
|
|
17
9
|
const Downloader = (url, fullPath, options = { method: 'get', responseType: 'stream' }) =>
|
package/test/api.test.js
CHANGED
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
import axios from 'axios';
|
|
4
4
|
import dotenv from 'dotenv';
|
|
5
|
-
import https from 'https';
|
|
6
5
|
|
|
7
6
|
import { expect } from 'chai';
|
|
8
7
|
import { loggerFactory } from '../src/server/logger.js';
|
|
@@ -20,13 +19,6 @@ const BASE_URL =
|
|
|
20
19
|
? `http://localhost:${PORT}/${process.env.BASE_API}`
|
|
21
20
|
: `https://www.nexodev.org/api`;
|
|
22
21
|
|
|
23
|
-
axios.defaults.baseURL = BASE_URL;
|
|
24
|
-
|
|
25
|
-
const httpsAgent = new https.Agent({
|
|
26
|
-
rejectUnauthorized: false,
|
|
27
|
-
});
|
|
28
|
-
axios.defaults.httpsAgent = httpsAgent;
|
|
29
|
-
|
|
30
22
|
describe(`GET 'Test' API Request `, async () => {
|
|
31
23
|
{
|
|
32
24
|
const url = `${BASE_URL}/test/youtube-id/?url=https://www.youtube.com/watch?v=o4f42SbyDMk`;
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
# kubectl apply -k core/.
|
|
3
|
-
apiVersion: kustomize.config.k8s.io/v1beta1
|
|
4
|
-
kind: Kustomization
|
|
5
|
-
resources:
|
|
6
|
-
- underpost-engine-pv-pvc.yaml
|
|
7
|
-
- underpost-engine-headless-service.yaml
|
|
8
|
-
- underpost-engine-statefulset.yaml
|
|
9
|
-
- underpost-engine-backup-pv-pvc.yaml
|
|
10
|
-
- underpost-engine-mongodb-backup-cronjob.yaml
|
|
11
|
-
- underpost-engine-backup-access.yaml
|
|
@@ -1,16 +0,0 @@
|
|
|
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
|
|
@@ -1,22 +0,0 @@
|
|
|
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
|
|
@@ -1,40 +0,0 @@
|
|
|
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
|
|
@@ -1,26 +0,0 @@
|
|
|
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
|
|
@@ -1,91 +0,0 @@
|
|
|
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
|
-
ports:
|
|
42
|
-
- containerPort: 27017
|
|
43
|
-
volumeMounts:
|
|
44
|
-
- name: mongodb-storage
|
|
45
|
-
mountPath: /data/db
|
|
46
|
-
- name: keyfile
|
|
47
|
-
mountPath: /etc/mongodb-keyfile
|
|
48
|
-
readOnly: true
|
|
49
|
-
# - name: mongodb-configuration-file
|
|
50
|
-
# mountPath: /etc/mongod.conf
|
|
51
|
-
# subPath: mongod.conf
|
|
52
|
-
# readOnly: true
|
|
53
|
-
# - name: mongodb-config
|
|
54
|
-
# mountPath: /config
|
|
55
|
-
env:
|
|
56
|
-
- name: MONGO_INITDB_ROOT_USERNAME
|
|
57
|
-
valueFrom:
|
|
58
|
-
secretKeyRef:
|
|
59
|
-
name: mongodb-secret
|
|
60
|
-
key: username
|
|
61
|
-
- name: MONGO_INITDB_ROOT_PASSWORD
|
|
62
|
-
valueFrom:
|
|
63
|
-
secretKeyRef:
|
|
64
|
-
name: mongodb-secret
|
|
65
|
-
key: password
|
|
66
|
-
resources:
|
|
67
|
-
requests:
|
|
68
|
-
cpu: '100m'
|
|
69
|
-
memory: '256Mi'
|
|
70
|
-
limits:
|
|
71
|
-
cpu: '500m'
|
|
72
|
-
memory: '512Mi'
|
|
73
|
-
volumes:
|
|
74
|
-
- name: keyfile
|
|
75
|
-
secret:
|
|
76
|
-
secretName: mongodb-keyfile
|
|
77
|
-
defaultMode: 0400
|
|
78
|
-
# - name: mongodb-configuration-file
|
|
79
|
-
# configMap:
|
|
80
|
-
# name: mongodb-config-file
|
|
81
|
-
# - name: mongodb-config
|
|
82
|
-
# configMap:
|
|
83
|
-
# name: mongodb-config
|
|
84
|
-
volumeClaimTemplates:
|
|
85
|
-
- metadata:
|
|
86
|
-
name: mongodb-storage
|
|
87
|
-
spec:
|
|
88
|
-
accessModes: ['ReadWriteOnce']
|
|
89
|
-
resources:
|
|
90
|
-
requests:
|
|
91
|
-
storage: 5Gi
|
|
File without changes
|