underpost 2.8.841 → 2.8.843
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/.env.development +1 -0
- package/.env.production +1 -0
- package/.env.test +1 -0
- package/README.md +6 -2
- package/bin/build.js +1 -0
- package/bin/deploy.js +0 -12
- package/bin/file.js +3 -0
- package/cli.md +3 -2
- package/docker-compose.yml +1 -1
- package/manifests/deployment/dd-template-development/deployment.yaml +2 -2
- package/package.json +2 -2
- package/src/cli/cluster.js +1 -1
- package/src/cli/deploy.js +19 -0
- package/src/cli/index.js +8 -1
- package/src/cli/monitor.js +8 -12
- package/src/cli/run.js +59 -0
- package/src/index.js +1 -1
- package/src/monitor.js +24 -0
package/.env.development
CHANGED
package/.env.production
CHANGED
package/.env.test
CHANGED
package/README.md
CHANGED
|
@@ -28,10 +28,12 @@ template
|
|
|
28
28
|
|
|
29
29
|
|
|
30
30
|
|
|
31
|
+
|
|
32
|
+
|
|
31
33
|
<!-- badges -->
|
|
32
34
|
|
|
33
35
|
|
|
34
|
-
[](https://github.com/underpostnet/engine/actions/workflows/docker-image.yml) [](https://github.com/underpostnet/engine/actions/workflows/coverall.yml) [](https://www.npmjs.com/package/underpost) [](https://github.com/underpostnet/engine/actions/workflows/docker-image.yml) [](https://github.com/underpostnet/engine/actions/workflows/coverall.yml) [](https://www.npmjs.com/package/underpost) [](https://socket.dev/npm/package/underpost/overview/2.8.843) [](https://coveralls.io/github/underpostnet/engine?branch=master) [](https://www.npmjs.org/package/underpost) [](https://www.npmjs.com/package/underpost)
|
|
35
37
|
|
|
36
38
|
|
|
37
39
|
<!-- end-badges -->
|
|
@@ -42,6 +44,8 @@ template
|
|
|
42
44
|
|
|
43
45
|
|
|
44
46
|
|
|
47
|
+
|
|
48
|
+
|
|
45
49
|
</div>
|
|
46
50
|
|
|
47
51
|
<div align="center">
|
|
@@ -86,7 +90,7 @@ Run dev client server
|
|
|
86
90
|
npm run dev
|
|
87
91
|
```
|
|
88
92
|
<!-- -->
|
|
89
|
-
## underpost ci/cd cli v2.8.
|
|
93
|
+
## underpost ci/cd cli v2.8.843
|
|
90
94
|
|
|
91
95
|
### Usage: `underpost [options] [command]`
|
|
92
96
|
```
|
package/bin/build.js
CHANGED
|
@@ -183,4 +183,5 @@ const { DefaultConf } = await import(`../conf.${confName}.js`);
|
|
|
183
183
|
fs.copyFileSync(`./manifests/deployment/${confName}-${env}/${file}`, `${basePath}/${file}`);
|
|
184
184
|
}
|
|
185
185
|
}
|
|
186
|
+
fs.copyFileSync(`./.github/workflows/deploy.${confName}.yml`, `${basePath}/.github/workflows/deploy.${confName}.yml`);
|
|
186
187
|
}
|
package/bin/deploy.js
CHANGED
|
@@ -1110,18 +1110,6 @@ EOF`);
|
|
|
1110
1110
|
break;
|
|
1111
1111
|
}
|
|
1112
1112
|
|
|
1113
|
-
case 'monitor': {
|
|
1114
|
-
shellExec(
|
|
1115
|
-
`node bin monitor ${process.argv[6] === 'sync' ? '--sync ' : ''}--type ${process.argv[3]} ${process.argv[4]} ${
|
|
1116
|
-
process.argv[5]
|
|
1117
|
-
}`,
|
|
1118
|
-
{
|
|
1119
|
-
async: true,
|
|
1120
|
-
},
|
|
1121
|
-
);
|
|
1122
|
-
break;
|
|
1123
|
-
}
|
|
1124
|
-
|
|
1125
1113
|
case 'postgresql': {
|
|
1126
1114
|
if (process.argv.includes('install')) {
|
|
1127
1115
|
shellExec(`sudo dnf install -y postgresql-server postgresql`);
|
package/bin/file.js
CHANGED
|
@@ -86,6 +86,9 @@ try {
|
|
|
86
86
|
'.github/workflows/engine.lampp.ci.yml',
|
|
87
87
|
'.github/workflows/engine.core.ci.yml',
|
|
88
88
|
'.github/workflows/engine.cyberia.ci.yml',
|
|
89
|
+
'.github/workflows/deploy.dd-core.yml',
|
|
90
|
+
'.github/workflows/deploy.dd-cyberia.yml',
|
|
91
|
+
'.github/workflows/deploy.dd-lampp.yml',
|
|
89
92
|
'./manifests/deployment/dd-lampp-development',
|
|
90
93
|
'./manifests/deployment/dd-cyberia-development',
|
|
91
94
|
'./manifests/deployment/dd-core-development',
|
package/cli.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
## underpost ci/cd cli v2.8.
|
|
1
|
+
## underpost ci/cd cli v2.8.843
|
|
2
2
|
|
|
3
3
|
### Usage: `underpost [options] [command]`
|
|
4
4
|
```
|
|
@@ -554,7 +554,7 @@ Options:
|
|
|
554
554
|
Runs a script from the specified path.
|
|
555
555
|
|
|
556
556
|
Arguments:
|
|
557
|
-
runner-id The runner ID to run. Options: spark-template, rmi, kill, secret, gpu-env, tf-gpu-test, ide, monitor, tf-vae-test, deploy-job.
|
|
557
|
+
runner-id The runner ID to run. Options: spark-template, rmi, kill, secret, gpu-env, tf-gpu-test, ide, monitor, db-client, cluster, deploy, tf-vae-test, deploy-job.
|
|
558
558
|
path The absolute or relative directory path where the script is located.
|
|
559
559
|
|
|
560
560
|
Options:
|
|
@@ -564,6 +564,7 @@ Options:
|
|
|
564
564
|
--pod-name <pod-name> Optional: Specifies the pod name for test execution.
|
|
565
565
|
--volume-host-path <volume-host-path> Optional: Specifies the volume host path for test execution.
|
|
566
566
|
--volume-mount-path <volume-mount-path> Optional: Specifies the volume mount path for test execution.
|
|
567
|
+
--volume-type <volume-type> Optional: Specifies the volume type for test execution.
|
|
567
568
|
--image-name <image-name> Optional: Specifies the image name for test execution.
|
|
568
569
|
--container-name <container-name> Optional: Specifies the container name for test execution.
|
|
569
570
|
--namespace <namespace> Optional: Specifies the namespace for test execution.
|
package/docker-compose.yml
CHANGED
|
@@ -17,7 +17,7 @@ spec:
|
|
|
17
17
|
spec:
|
|
18
18
|
containers:
|
|
19
19
|
- name: dd-template-development-blue
|
|
20
|
-
image: localhost/rockylinux9-underpost:v2.8.
|
|
20
|
+
image: localhost/rockylinux9-underpost:v2.8.843
|
|
21
21
|
# resources:
|
|
22
22
|
# requests:
|
|
23
23
|
# memory: "124Ki"
|
|
@@ -100,7 +100,7 @@ spec:
|
|
|
100
100
|
spec:
|
|
101
101
|
containers:
|
|
102
102
|
- name: dd-template-development-green
|
|
103
|
-
image: localhost/rockylinux9-underpost:v2.8.
|
|
103
|
+
image: localhost/rockylinux9-underpost:v2.8.843
|
|
104
104
|
# resources:
|
|
105
105
|
# requests:
|
|
106
106
|
# memory: "124Ki"
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"type": "module",
|
|
3
3
|
"main": "src/index.js",
|
|
4
4
|
"name": "underpost",
|
|
5
|
-
"version": "2.8.
|
|
5
|
+
"version": "2.8.843",
|
|
6
6
|
"description": "pwa api rest template",
|
|
7
7
|
"scripts": {
|
|
8
8
|
"start": "env-cmd -f .env.production node --max-old-space-size=8192 src/server",
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"dev": "env-cmd -f .env.development node src/client.dev default",
|
|
12
12
|
"dev-img": "env-cmd -f .env.development node src/server",
|
|
13
13
|
"prod-img": "env-cmd -f .env.production node src/server",
|
|
14
|
-
"monitor": "pm2 start
|
|
14
|
+
"monitor": "pm2 start src/monitor.js --name monitor -- dd production",
|
|
15
15
|
"dev-api": "env-cmd -f .env.development nodemon --watch src --ignore src/client src/api",
|
|
16
16
|
"dev-client": "env-cmd -f .env.development node src/client.dev",
|
|
17
17
|
"proxy": "node src/proxy proxy",
|
package/src/cli/cluster.js
CHANGED
|
@@ -368,7 +368,7 @@ class UnderpostCluster {
|
|
|
368
368
|
shellExec(`kubectl apply -f ${underpostRoot}/manifests/mongodb/storage-class.yaml`);
|
|
369
369
|
shellExec(`kubectl apply -k ${underpostRoot}/manifests/mongodb`);
|
|
370
370
|
|
|
371
|
-
const successInstance = await UnderpostTest.API.statusMonitor('mongodb-1');
|
|
371
|
+
const successInstance = await UnderpostTest.API.statusMonitor('mongodb-1', 'Running', 'pods', 1000, 60 * 10);
|
|
372
372
|
|
|
373
373
|
if (successInstance) {
|
|
374
374
|
const mongoConfig = {
|
package/src/cli/deploy.js
CHANGED
|
@@ -528,6 +528,25 @@ node bin/deploy build-full-client ${deployId}
|
|
|
528
528
|
}).trim(),
|
|
529
529
|
);
|
|
530
530
|
},
|
|
531
|
+
checkDeploymentReadyStatus(deployId, env, traffic) {
|
|
532
|
+
const cmd = `underpost config get container-status`;
|
|
533
|
+
const pods = UnderpostDeploy.API.get(`${deployId}-${env}-${traffic}`);
|
|
534
|
+
const readyPods = [];
|
|
535
|
+
const notReadyPods = [];
|
|
536
|
+
for (const pod of pods) {
|
|
537
|
+
const { NAME } = pod;
|
|
538
|
+
if (
|
|
539
|
+
shellExec(`sudo kubectl exec -i ${NAME} -- sh -c "${cmd}"`, { stdout: true }).match(
|
|
540
|
+
`${deployId}-${env}-running-deployment`,
|
|
541
|
+
)
|
|
542
|
+
) {
|
|
543
|
+
readyPods.push(pod);
|
|
544
|
+
} else {
|
|
545
|
+
notReadyPods.push(pod);
|
|
546
|
+
}
|
|
547
|
+
}
|
|
548
|
+
return { ready: notReadyPods.length === 0, notReadyPods, readyPods };
|
|
549
|
+
},
|
|
531
550
|
};
|
|
532
551
|
}
|
|
533
552
|
|
package/src/cli/index.js
CHANGED
|
@@ -86,7 +86,13 @@ program
|
|
|
86
86
|
.argument('<deploy-id>', `The deployment configuration ID. Use 'clean' to restore default environment settings.`)
|
|
87
87
|
.argument('[env]', 'Optional: The environment to set (e.g., "production", "development"). Defaults to "production".')
|
|
88
88
|
.description('Sets environment variables and configurations related to a specific deployment ID.')
|
|
89
|
-
.action(
|
|
89
|
+
.action((...args) => {
|
|
90
|
+
if (args[0] === 'current') {
|
|
91
|
+
console.log(process.env.DEPLOY_ID);
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
loadConf(...args);
|
|
95
|
+
});
|
|
90
96
|
|
|
91
97
|
// 'config' command: Manage Underpost configurations
|
|
92
98
|
program
|
|
@@ -326,6 +332,7 @@ program
|
|
|
326
332
|
.option('--pod-name <pod-name>', 'Optional: Specifies the pod name for test execution.')
|
|
327
333
|
.option('--volume-host-path <volume-host-path>', 'Optional: Specifies the volume host path for test execution.')
|
|
328
334
|
.option('--volume-mount-path <volume-mount-path>', 'Optional: Specifies the volume mount path for test execution.')
|
|
335
|
+
.option('--volume-type <volume-type>', 'Optional: Specifies the volume type for test execution.')
|
|
329
336
|
.option('--image-name <image-name>', 'Optional: Specifies the image name for test execution.')
|
|
330
337
|
.option('--container-name <container-name>', 'Optional: Specifies the container name for test execution.')
|
|
331
338
|
.option('--namespace <namespace>', 'Optional: Specifies the namespace for test execution.')
|
package/src/cli/monitor.js
CHANGED
|
@@ -173,19 +173,15 @@ class UnderpostMonitor {
|
|
|
173
173
|
monitorTrafficName = undefined;
|
|
174
174
|
monitorPodName = undefined;
|
|
175
175
|
}
|
|
176
|
-
const cmd = `underpost config get container-status`;
|
|
177
176
|
const checkDeploymentReadyStatus = () => {
|
|
178
|
-
const
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
monitorPodName = NAME;
|
|
187
|
-
monitorTrafficName = `${traffic}`;
|
|
188
|
-
}
|
|
177
|
+
const { ready, notReadyPods, readyPods } = UnderpostDeploy.API.checkDeploymentReadyStatus(
|
|
178
|
+
deployId,
|
|
179
|
+
env,
|
|
180
|
+
traffic,
|
|
181
|
+
);
|
|
182
|
+
if (ready) {
|
|
183
|
+
monitorPodName = readyPods[0].NAME;
|
|
184
|
+
monitorTrafficName = `${traffic}`;
|
|
189
185
|
}
|
|
190
186
|
};
|
|
191
187
|
if (!monitorPodName) {
|
package/src/cli/run.js
CHANGED
|
@@ -142,6 +142,65 @@ class UnderpostRun {
|
|
|
142
142
|
};
|
|
143
143
|
_monitor();
|
|
144
144
|
},
|
|
145
|
+
'db-client': async (path, options = UnderpostRun.DEFAULT_OPTION) => {
|
|
146
|
+
const { underpostRoot } = options;
|
|
147
|
+
shellExec(`kubectl apply -k ${underpostRoot}/manifests/deployment/adminer/.`);
|
|
148
|
+
},
|
|
149
|
+
cluster: async (path, options = UnderpostRun.DEFAULT_OPTION) => {
|
|
150
|
+
const deployList = fs.readFileSync(`./engine-private/deploy/dd.router`, 'utf8').split(',');
|
|
151
|
+
const env = 'production';
|
|
152
|
+
shellCd(`/home/dd/engine`);
|
|
153
|
+
shellExec(`underpost cluster --reset`);
|
|
154
|
+
await timer(5000);
|
|
155
|
+
shellExec(`underpost cluster --kubeadm`);
|
|
156
|
+
await timer(5000);
|
|
157
|
+
shellExec(`underpost dockerfile-pull-base-images --path /home/dd/engine/src/runtime/lampp --kubeadm-load`);
|
|
158
|
+
await timer(5000);
|
|
159
|
+
shellExec(`underpost cluster --kubeadm --pull-image --mongodb`);
|
|
160
|
+
await timer(5000);
|
|
161
|
+
shellExec(`underpost cluster --kubeadm --pull-image --mariadb`);
|
|
162
|
+
await timer(5000);
|
|
163
|
+
for (const deployId of deployList) {
|
|
164
|
+
shellExec(`underpost db ${deployId} --import --git`);
|
|
165
|
+
}
|
|
166
|
+
await timer(5000);
|
|
167
|
+
shellExec(`underpost cluster --kubeadm --pull-image --valkey`);
|
|
168
|
+
await timer(5000);
|
|
169
|
+
shellExec(`underpost cluster --kubeadm --contour`);
|
|
170
|
+
await timer(5000);
|
|
171
|
+
shellExec(`underpost cluster --kubeadm --cert-manager`);
|
|
172
|
+
for (const deployId of deployList) {
|
|
173
|
+
shellExec(`underpost deploy ${deployId} ${env} --kubeadm --cert`);
|
|
174
|
+
}
|
|
175
|
+
},
|
|
176
|
+
deploy: async (path, options = UnderpostRun.DEFAULT_OPTION) => {
|
|
177
|
+
const deployId = path;
|
|
178
|
+
const currentTraffic = UnderpostDeploy.API.getCurrentTraffic(deployId);
|
|
179
|
+
const targetTraffic = currentTraffic === 'blue' ? 'green' : 'blue';
|
|
180
|
+
const env = 'production';
|
|
181
|
+
shellExec(`sudo kubectl rollout restart deployment/${deployId}-${env}-${targetTraffic}`);
|
|
182
|
+
|
|
183
|
+
let secondsElapsed = 0;
|
|
184
|
+
logger.info('Deployment init', { deployId, env, targetTraffic });
|
|
185
|
+
|
|
186
|
+
while (!UnderpostDeploy.API.checkDeploymentReadyStatus(deployId, env, targetTraffic).ready) {
|
|
187
|
+
await timer(1000);
|
|
188
|
+
secondsElapsed++;
|
|
189
|
+
logger.info(`Deployment in progress, seconds elapsed: ${secondsElapsed}`);
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
logger.info(`Deployment ready, seconds elapsed: ${secondsElapsed}`);
|
|
193
|
+
|
|
194
|
+
UnderpostRootEnv.API.set(`${deployId}-${env}-traffic`, targetTraffic);
|
|
195
|
+
|
|
196
|
+
shellExec(
|
|
197
|
+
`node bin deploy --info-router --build-manifest --traffic ${targetTraffic} --replicas ${
|
|
198
|
+
options.replicas ? options.replicas : 1
|
|
199
|
+
} ${deployId} ${env}`,
|
|
200
|
+
);
|
|
201
|
+
shellExec(`sudo kubectl apply -f ./engine-private/conf/${deployId}/build/${env}/proxy.yaml`);
|
|
202
|
+
shellExec(`sudo kubectl rollout restart deployment/${deployId}-${env}-${currentTraffic}`);
|
|
203
|
+
},
|
|
145
204
|
'tf-vae-test': async (path, options = UnderpostRun.DEFAULT_OPTION) => {
|
|
146
205
|
const { underpostRoot } = options;
|
|
147
206
|
const podName = 'tf-vae-test';
|
package/src/index.js
CHANGED
package/src/monitor.js
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
// https://nodejs.org/api
|
|
4
|
+
// https://expressjs.com/en/4x/api.html
|
|
5
|
+
|
|
6
|
+
import dotenv from 'dotenv';
|
|
7
|
+
import { loggerFactory } from './server/logger.js';
|
|
8
|
+
import { ProcessController } from './server/process.js';
|
|
9
|
+
import { getUnderpostRootPath } from './server/conf.js';
|
|
10
|
+
import fs from 'fs-extra';
|
|
11
|
+
import UnderpostMonitor from './cli/monitor.js';
|
|
12
|
+
|
|
13
|
+
const underpostRootPath = getUnderpostRootPath();
|
|
14
|
+
fs.existsSync(`${underpostRootPath}/.env`)
|
|
15
|
+
? dotenv.config({ path: `${underpostRootPath}/.env`, override: true })
|
|
16
|
+
: dotenv.config();
|
|
17
|
+
|
|
18
|
+
const logger = loggerFactory(import.meta);
|
|
19
|
+
|
|
20
|
+
await logger.setUpInfo();
|
|
21
|
+
|
|
22
|
+
UnderpostMonitor.API.callback(process.argv[2], process.argv[3], { type: 'blue-green', sync: true });
|
|
23
|
+
|
|
24
|
+
ProcessController.init(logger);
|