underpost 2.8.51 → 2.8.52
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/.vscode/settings.json +1 -0
- package/bin/index.js +3 -1
- package/docker-compose.yml +1 -1
- package/package.json +1 -1
- package/src/cli/cluster.js +31 -9
- package/src/cli/deploy.js +9 -2
- package/src/cli/image.js +15 -7
- package/src/index.js +1 -1
package/.vscode/settings.json
CHANGED
package/bin/index.js
CHANGED
|
@@ -88,6 +88,7 @@ program
|
|
|
88
88
|
.option('--mongodb', 'Init with mongodb statefulset')
|
|
89
89
|
.option('--valkey', 'Init with valkey service')
|
|
90
90
|
.option('--contour', 'Init with project contour base HTTPProxy and envoy')
|
|
91
|
+
.option('--cert-manager', 'Init with letsencrypt-prod ClusterIssuer')
|
|
91
92
|
.option('--info', 'Get all kinds objects deployed')
|
|
92
93
|
.option('--full', 'Init with all statefulsets and services available')
|
|
93
94
|
.option('--ns-use <ns-name>', 'Switches current context to namespace')
|
|
@@ -136,7 +137,8 @@ program
|
|
|
136
137
|
.argument('<deploy-id>', 'Deploy configuration id')
|
|
137
138
|
.argument('[env]', 'Optional environment, for default is development')
|
|
138
139
|
.argument('[path]', 'Absolute or relative directory, for default is current')
|
|
139
|
-
.option('--image-archive', 'Only load tar image from
|
|
140
|
+
.option('--image-archive', 'Only load tar image from ./images')
|
|
141
|
+
.option('--podman-save', 'Save image from podman to ./images')
|
|
140
142
|
.description('Build image from Dockerfile')
|
|
141
143
|
.action(Underpost.image.dockerfile.build);
|
|
142
144
|
|
package/docker-compose.yml
CHANGED
package/package.json
CHANGED
package/src/cli/cluster.js
CHANGED
|
@@ -2,12 +2,23 @@ import { timer } from '../client/components/core/CommonJs.js';
|
|
|
2
2
|
import { cliSpinner } from '../server/conf.js';
|
|
3
3
|
import { loggerFactory } from '../server/logger.js';
|
|
4
4
|
import { shellExec } from '../server/process.js';
|
|
5
|
+
import UnderpostDeploy from './deploy.js';
|
|
5
6
|
|
|
6
7
|
const logger = loggerFactory(import.meta);
|
|
7
8
|
|
|
8
9
|
class UnderpostCluster {
|
|
9
10
|
static API = {
|
|
10
|
-
async init(
|
|
11
|
+
async init(
|
|
12
|
+
options = {
|
|
13
|
+
valkey: false,
|
|
14
|
+
mariadb: false,
|
|
15
|
+
valkey: false,
|
|
16
|
+
full: false,
|
|
17
|
+
info: false,
|
|
18
|
+
certManager: false,
|
|
19
|
+
nsUse: '',
|
|
20
|
+
},
|
|
21
|
+
) {
|
|
11
22
|
if (options.nsUse) {
|
|
12
23
|
shellExec(`kubectl config set-context --current --namespace=${options.nsUse}`);
|
|
13
24
|
return;
|
|
@@ -40,6 +51,7 @@ class UnderpostCluster {
|
|
|
40
51
|
logger.info('----------------------------------------------------------------');
|
|
41
52
|
shellExec(`kubectl get secrets --all-namespaces -o wide`);
|
|
42
53
|
shellExec(`docker secret ls`);
|
|
54
|
+
shellExec(`kubectl get crd --all-namespaces -o wide`);
|
|
43
55
|
return;
|
|
44
56
|
}
|
|
45
57
|
const testClusterInit = shellExec(`kubectl get pods --all-namespaces -o wide`, {
|
|
@@ -88,14 +100,7 @@ class UnderpostCluster {
|
|
|
88
100
|
const monitor = async () => {
|
|
89
101
|
cliSpinner(1000, `[cluster.js] `, ` Load mongodb instance`, 'yellow', 'material');
|
|
90
102
|
await timer(1000);
|
|
91
|
-
if (
|
|
92
|
-
shellExec(`kubectl get pods --all-namespaces -o wide`, {
|
|
93
|
-
silent: true,
|
|
94
|
-
stdout: true,
|
|
95
|
-
disableLog: true,
|
|
96
|
-
}).match(`mongodb-1 1/1 Running`)
|
|
97
|
-
)
|
|
98
|
-
return resolve();
|
|
103
|
+
if (UnderpostDeploy.API.getPods('mongodb-1').find((p) => p.STATUS === 'Running')) return resolve();
|
|
99
104
|
return monitor();
|
|
100
105
|
};
|
|
101
106
|
await monitor();
|
|
@@ -119,6 +124,23 @@ class UnderpostCluster {
|
|
|
119
124
|
|
|
120
125
|
if (options.full || options.contour)
|
|
121
126
|
shellExec(`kubectl apply -f https://projectcontour.io/quickstart/contour.yaml`);
|
|
127
|
+
|
|
128
|
+
if (options.full || options.certManager) {
|
|
129
|
+
if (!UnderpostDeploy.API.getPods('cert-manager').find((p) => p.STATUS === 'Running')) {
|
|
130
|
+
shellExec(`helm repo add jetstack https://charts.jetstack.io --force-update`);
|
|
131
|
+
shellExec(
|
|
132
|
+
`helm install cert-manager jetstack/cert-manager \
|
|
133
|
+
--namespace cert-manager \
|
|
134
|
+
--create-namespace \
|
|
135
|
+
--version v1.17.0 \
|
|
136
|
+
--set crds.enabled=true`,
|
|
137
|
+
);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
const letsEncName = 'letsencrypt-prod';
|
|
141
|
+
shellExec(`sudo kubectl delete ClusterIssuer ${letsEncName}`);
|
|
142
|
+
shellExec(`sudo kubectl apply -f ./manifests/${letsEncName}.yaml`);
|
|
143
|
+
}
|
|
122
144
|
},
|
|
123
145
|
reset() {
|
|
124
146
|
shellExec(`kind get clusters | xargs -t -n1 kind delete cluster --name`);
|
package/src/cli/deploy.js
CHANGED
|
@@ -205,12 +205,19 @@ spec:
|
|
|
205
205
|
const confServer = JSON.parse(fs.readFileSync(`./engine-private/conf/${deployId}/conf.server.json`, 'utf8'));
|
|
206
206
|
for (const host of Object.keys(confServer)) {
|
|
207
207
|
shellExec(`sudo kubectl delete HTTPProxy ${host}`);
|
|
208
|
+
if (env === 'production') shellExec(`sudo kubectl delete Certificate ${host}`);
|
|
208
209
|
if (!options.remove === true && env === 'development') concatHots += ` ${host}`;
|
|
209
210
|
}
|
|
210
211
|
|
|
212
|
+
const manifestsPath =
|
|
213
|
+
env === 'production'
|
|
214
|
+
? `engine-private/conf/${deployId}/build/production`
|
|
215
|
+
: `manifests/deployment/${deployId}-${env}`;
|
|
216
|
+
|
|
211
217
|
if (!options.remove === true) {
|
|
212
|
-
shellExec(`sudo kubectl apply -f
|
|
213
|
-
shellExec(`sudo kubectl apply -f
|
|
218
|
+
shellExec(`sudo kubectl apply -f ./${manifestsPath}/deployment.yaml`);
|
|
219
|
+
shellExec(`sudo kubectl apply -f ./${manifestsPath}/proxy.yaml`);
|
|
220
|
+
if (env === 'production') shellExec(`sudo kubectl apply -f ./${manifestsPath}/secret.yaml`);
|
|
214
221
|
}
|
|
215
222
|
|
|
216
223
|
let renderHosts;
|
package/src/cli/image.js
CHANGED
|
@@ -13,11 +13,18 @@ class UnderpostImage {
|
|
|
13
13
|
pullBaseImages() {
|
|
14
14
|
shellExec(`sudo podman pull docker.io/library/debian:buster`);
|
|
15
15
|
},
|
|
16
|
-
build(
|
|
16
|
+
build(
|
|
17
|
+
deployId = 'default',
|
|
18
|
+
env = 'development',
|
|
19
|
+
path = '.',
|
|
20
|
+
options = { imageArchive: false, podmanSave: false },
|
|
21
|
+
) {
|
|
17
22
|
const imgName = `${deployId}-${env}:${Underpost.version}`;
|
|
18
23
|
const podManImg = `localhost/${imgName}`;
|
|
19
|
-
const imagesStoragePath =
|
|
20
|
-
|
|
24
|
+
const imagesStoragePath = `/images`;
|
|
25
|
+
if (!fs.existsSync(`${path}${imagesStoragePath}`))
|
|
26
|
+
fs.mkdirSync(`${path}${imagesStoragePath}`, { recursive: true });
|
|
27
|
+
const tarFile = `.${imagesStoragePath}/${imgName.replace(':', '_')}.tar`;
|
|
21
28
|
|
|
22
29
|
let secrets = ' ';
|
|
23
30
|
let secretDockerInput = '';
|
|
@@ -36,8 +43,9 @@ class UnderpostImage {
|
|
|
36
43
|
`cd ${path}${secrets}&& sudo podman build -f ./Dockerfile -t ${imgName} --pull=never --cap-add=CAP_AUDIT_WRITE${secretDockerInput}`,
|
|
37
44
|
);
|
|
38
45
|
fs.removeSync(`${path}/.env.underpost`);
|
|
39
|
-
shellExec(`cd ${path} && podman save -o ${tarFile} ${podManImg}`);
|
|
40
46
|
}
|
|
47
|
+
if (options.imageArchive !== true || options.podmanSave === true)
|
|
48
|
+
shellExec(`cd ${path} && podman save -o ${tarFile} ${podManImg}`);
|
|
41
49
|
shellExec(`cd ${path} && sudo kind load image-archive ${tarFile}`);
|
|
42
50
|
},
|
|
43
51
|
async script(deployId = 'default', env = 'development', options = { run: false }) {
|
|
@@ -101,12 +109,12 @@ class UnderpostImage {
|
|
|
101
109
|
shellExec(`node bin/deploy conf ${deployId} ${env}`);
|
|
102
110
|
shellExec(`node bin/deploy build-full-client ${deployId}`);
|
|
103
111
|
if (options.run === true) {
|
|
104
|
-
const runCmd = env === 'production' ? '
|
|
112
|
+
const runCmd = env === 'production' ? 'start' : 'run dev-img';
|
|
105
113
|
if (fs.existsSync(`./engine-private/replica`)) {
|
|
106
114
|
const replicas = await fs.readdir(`./engine-private/replica`);
|
|
107
115
|
for (const replica of replicas) {
|
|
108
116
|
shellExec(`node bin/deploy conf ${replica} ${env}`);
|
|
109
|
-
shellExec(`npm
|
|
117
|
+
shellExec(`npm ${runCmd} ${replica} deploy`, { async: true });
|
|
110
118
|
fs.writeFileSync(`./tmp/await-deploy`, '', 'utf8');
|
|
111
119
|
const monitor = async () => {
|
|
112
120
|
await timer(1000);
|
|
@@ -116,7 +124,7 @@ class UnderpostImage {
|
|
|
116
124
|
}
|
|
117
125
|
shellExec(`node bin/deploy conf ${deployId} ${env}`);
|
|
118
126
|
}
|
|
119
|
-
shellExec(`npm
|
|
127
|
+
shellExec(`npm ${runCmd} ${deployId} deploy`);
|
|
120
128
|
}
|
|
121
129
|
},
|
|
122
130
|
},
|