@underpostnet/underpost 2.8.813 → 2.8.815
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/README.md +1 -1
- package/bin/deploy.js +229 -131
- package/cli.md +1 -1
- package/docker-compose.yml +1 -1
- package/manifests/deployment/dd-template-development/deployment.yaml +2 -2
- package/package.json +1 -1
- package/src/cli/cluster.js +16 -12
- package/src/index.js +1 -1
package/README.md
CHANGED
package/bin/deploy.js
CHANGED
|
@@ -51,63 +51,50 @@ logger.info('argv', process.argv);
|
|
|
51
51
|
|
|
52
52
|
const [exe, dir, operator] = process.argv;
|
|
53
53
|
|
|
54
|
-
const
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
`sudo sed -i 's/XKBLAYOUT="us"/XKBLAYOUT="es"/' /etc/default/keyboard`,
|
|
76
|
-
`sudo dpkg-reconfigure --frontend noninteractive keyboard-configuration`,
|
|
77
|
-
`sudo systemctl restart keyboard-setup.service`,
|
|
78
|
-
];
|
|
79
|
-
// # - ${JSON.stringify([...timeZoneSteps, ...chronySetUp(chronyConfPath)])}
|
|
80
|
-
const installSteps = [
|
|
81
|
-
`cat <<EOF | sudo tee /etc/apt/sources.list
|
|
54
|
+
const chronyConfPath = `/etc/chrony/chrony.conf`;
|
|
55
|
+
|
|
56
|
+
const timezone = 'America/New_York';
|
|
57
|
+
|
|
58
|
+
const timeZoneSteps = [
|
|
59
|
+
`export DEBIAN_FRONTEND=noninteractive`,
|
|
60
|
+
|
|
61
|
+
`ln -fs /usr/share/zoneinfo/${timezone} /etc/localtime`,
|
|
62
|
+
|
|
63
|
+
`sudo dpkg-reconfigure --frontend noninteractive tzdata`,
|
|
64
|
+
];
|
|
65
|
+
const keyboardSteps = [
|
|
66
|
+
`sudo locale-gen en_US.UTF-8`,
|
|
67
|
+
`sudo update-locale LANG=en_US.UTF-8`,
|
|
68
|
+
`sudo sed -i 's/XKBLAYOUT="us"/XKBLAYOUT="es"/' /etc/default/keyboard`,
|
|
69
|
+
`sudo dpkg-reconfigure --frontend noninteractive keyboard-configuration`,
|
|
70
|
+
`sudo systemctl restart keyboard-setup.service`,
|
|
71
|
+
];
|
|
72
|
+
// # - ${JSON.stringify([...timeZoneSteps, ...chronySetUp(chronyConfPath)])}
|
|
73
|
+
const installSteps = [
|
|
74
|
+
`cat <<EOF | tee /etc/apt/sources.list
|
|
82
75
|
deb http://ports.ubuntu.com/ubuntu-ports noble main restricted universe multiverse
|
|
83
76
|
deb http://ports.ubuntu.com/ubuntu-ports noble-updates main restricted universe multiverse
|
|
84
77
|
deb http://ports.ubuntu.com/ubuntu-ports noble-security main restricted universe multiverse
|
|
85
78
|
EOF`,
|
|
86
79
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
`chmod 600 /home/root/.ssh/authorized_keys`,
|
|
106
|
-
];
|
|
107
|
-
|
|
108
|
-
let steps = [
|
|
109
|
-
// Configure cloud-init for MAAS
|
|
110
|
-
`cat <<EOF_MAAS_CFG > /etc/cloud/cloud.cfg.d/90_maas.cfg
|
|
80
|
+
`apt update -qq`,
|
|
81
|
+
`apt -y full-upgrade`,
|
|
82
|
+
`apt install -y xinput x11-xkb-utils usbutils`,
|
|
83
|
+
// `apt install -y cloud-init=25.1.2-0ubuntu0~24.04.1`,
|
|
84
|
+
`apt install -y cloud-init systemd-sysv openssh-server sudo locales udev util-linux systemd-sysv iproute2 netplan.io ca-certificates curl wget chrony`,
|
|
85
|
+
`ln -sf /lib/systemd/systemd /sbin/init`,
|
|
86
|
+
|
|
87
|
+
`apt-get update`,
|
|
88
|
+
`DEBIAN_FRONTEND=noninteractive apt-get install -y apt-utils`,
|
|
89
|
+
`DEBIAN_FRONTEND=noninteractive apt-get install -y tzdata kmod keyboard-configuration console-setup iputils-ping`,
|
|
90
|
+
];
|
|
91
|
+
|
|
92
|
+
const cloudConfigFactory = (
|
|
93
|
+
{ IP_ADDRESS, architecture, host, nfsHostPath, ipaddr, update, gatewayip },
|
|
94
|
+
{ consumer_key, consumer_token, secret },
|
|
95
|
+
) => [
|
|
96
|
+
// Configure cloud-init for MAAS
|
|
97
|
+
`cat <<EOF_MAAS_CFG > /etc/cloud/cloud.cfg.d/90_maas.cfg
|
|
111
98
|
#cloud-config
|
|
112
99
|
|
|
113
100
|
hostname: ${host}
|
|
@@ -125,37 +112,40 @@ hostname: ${host}
|
|
|
125
112
|
datasource_list: [ MAAS ]
|
|
126
113
|
datasource:
|
|
127
114
|
MAAS:
|
|
128
|
-
metadata_url: http://${IP_ADDRESS}:
|
|
115
|
+
metadata_url: http://${IP_ADDRESS}:5248/MAAS/metadata
|
|
129
116
|
consumer_key: ${consumer_key}
|
|
130
117
|
token_key: ${consumer_token}
|
|
131
118
|
token_secret: ${secret}
|
|
119
|
+
|
|
132
120
|
users:
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
121
|
+
- name: root
|
|
122
|
+
sudo: ['ALL=(ALL) NOPASSWD:ALL']
|
|
123
|
+
shell: /bin/bash
|
|
124
|
+
lock_passwd: true
|
|
125
|
+
ssh_authorized_keys:
|
|
126
|
+
- ${fs.readFileSync(`/home/dd/engine/engine-private/deploy/id_rsa.pub`, 'utf8')}
|
|
139
127
|
|
|
128
|
+
# manage_resolv_conf: true
|
|
129
|
+
# resolv_conf:
|
|
130
|
+
# nameservers: [8.8.8.8]
|
|
140
131
|
|
|
141
132
|
# keyboard:
|
|
142
133
|
# layout: es
|
|
143
134
|
|
|
144
|
-
|
|
145
135
|
# check timedatectl on host
|
|
146
136
|
# timezone: America/Santiago
|
|
147
|
-
timezone: ${timezone}
|
|
148
|
-
|
|
149
|
-
ntp:
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
137
|
+
# timezone: ${timezone}
|
|
138
|
+
|
|
139
|
+
# ntp:
|
|
140
|
+
# enabled: true
|
|
141
|
+
# servers:
|
|
142
|
+
# - ${IP_ADDRESS}
|
|
143
|
+
# ntp_client: chrony
|
|
144
|
+
# config:
|
|
145
|
+
# confpath: ${chronyConfPath}
|
|
146
|
+
# packages:
|
|
147
|
+
# - chrony
|
|
148
|
+
# service_name: chrony
|
|
159
149
|
|
|
160
150
|
# ssh:
|
|
161
151
|
# allow-pw: false
|
|
@@ -172,13 +162,13 @@ packages:
|
|
|
172
162
|
resize_rootfs: false
|
|
173
163
|
growpart:
|
|
174
164
|
mode: off
|
|
175
|
-
network:
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
165
|
+
# network:
|
|
166
|
+
# version: 2
|
|
167
|
+
# ethernets:
|
|
168
|
+
# ${process.env.RPI4_INTERFACE_NAME}:
|
|
169
|
+
# dhcp4: true
|
|
170
|
+
# addresses:
|
|
171
|
+
# - ${ipaddr}/24
|
|
182
172
|
# routes:
|
|
183
173
|
# - to: default
|
|
184
174
|
# via: ${gatewayip}
|
|
@@ -186,7 +176,7 @@ network:
|
|
|
186
176
|
# chpasswd:
|
|
187
177
|
# expire: false
|
|
188
178
|
# users:
|
|
189
|
-
# - {name:
|
|
179
|
+
# - {name: root, password: changeme, type: text}
|
|
190
180
|
|
|
191
181
|
final_message: "The system is up, after $UPTIME seconds"
|
|
192
182
|
|
|
@@ -199,67 +189,26 @@ bootcmd:
|
|
|
199
189
|
- echo "- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -"
|
|
200
190
|
- echo "Init bootcmd"
|
|
201
191
|
- echo "- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -"
|
|
202
|
-
- ntpdate -u ${IP_ADDRESS} || ntpdate -u ${process.env.MAAS_NTP_SERVER}
|
|
203
192
|
runcmd:
|
|
204
193
|
- echo "- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -"
|
|
205
194
|
- echo "Init runcmd"
|
|
206
195
|
- echo "- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -"
|
|
207
196
|
EOF_MAAS_CFG`,
|
|
208
|
-
|
|
197
|
+
];
|
|
209
198
|
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
199
|
+
const runSteps = (nfsHostPath, steps = []) => {
|
|
200
|
+
const script = steps
|
|
201
|
+
.map(
|
|
202
|
+
(s, i) => `echo "step ${i + 1}/${steps.length}: ${s.split('\n')[0]}"
|
|
214
203
|
${s}`,
|
|
215
|
-
|
|
216
|
-
|
|
204
|
+
)
|
|
205
|
+
.join('\n');
|
|
217
206
|
|
|
218
|
-
|
|
207
|
+
const cmd = `sudo chroot ${nfsHostPath} /usr/bin/qemu-aarch64-static /bin/bash <<'EOF_OUTER'
|
|
219
208
|
${script}
|
|
220
209
|
EOF_OUTER`;
|
|
221
210
|
|
|
222
|
-
|
|
223
|
-
};
|
|
224
|
-
|
|
225
|
-
if (update) {
|
|
226
|
-
// --reboot
|
|
227
|
-
shellExec(`sudo chroot ${nfsHostPath} /usr/bin/qemu-aarch64-static /bin/bash <<'EOF'
|
|
228
|
-
sudo cloud-init clean --logs --seed --configs all --machine-id
|
|
229
|
-
sudo rm -rf /var/lib/cloud/*
|
|
230
|
-
EOF`);
|
|
231
|
-
|
|
232
|
-
if (fs.existsSync(`${nfsHostPath}/var/log/`)) {
|
|
233
|
-
fs.writeFileSync(`${nfsHostPath}/var/log/cloud-init.log`, '', 'utf8');
|
|
234
|
-
fs.writeFileSync(`${nfsHostPath}/var/log/cloud-init-output.log`, '', 'utf8');
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
runSteps(steps);
|
|
238
|
-
} else {
|
|
239
|
-
runSteps(installSteps.concat(steps));
|
|
240
|
-
|
|
241
|
-
shellExec(`sudo chroot ${nfsHostPath} /usr/bin/qemu-aarch64-static /bin/bash <<'EOF'
|
|
242
|
-
echo "nameserver ${process.env.MAAS_DNS}" | tee /etc/resolv.conf > /dev/null
|
|
243
|
-
apt update
|
|
244
|
-
EOF`);
|
|
245
|
-
fs.writeFileSync(
|
|
246
|
-
`${nfsHostPath}/dns.sh`,
|
|
247
|
-
`rm /etc/resolv.conf
|
|
248
|
-
echo 'nameserver 8.8.8.8' > /run/systemd/resolve/stub-resolv.conf
|
|
249
|
-
ln -sf /run/systemd/resolve/stub-resolv.conf /etc/resolv.conf`,
|
|
250
|
-
'utf8',
|
|
251
|
-
);
|
|
252
|
-
|
|
253
|
-
await timer(5000);
|
|
254
|
-
|
|
255
|
-
runSteps([
|
|
256
|
-
// `date -s "${shellExec(`date '+%Y-%m-%d %H:%M:%S'`, { stdout: true }).trim()}"`,
|
|
257
|
-
// `date`,
|
|
258
|
-
...timeZoneSteps,
|
|
259
|
-
...chronySetUp(chronyConfPath),
|
|
260
|
-
...keyboardSteps,
|
|
261
|
-
]);
|
|
262
|
-
}
|
|
211
|
+
shellExec(cmd);
|
|
263
212
|
};
|
|
264
213
|
|
|
265
214
|
const chronySetUp = (path) => {
|
|
@@ -323,6 +272,155 @@ logdir /var/log/chrony
|
|
|
323
272
|
];
|
|
324
273
|
};
|
|
325
274
|
|
|
275
|
+
const installUbuntuUnderpostTools = (nfsHostPath) => {
|
|
276
|
+
fs.mkdirSync(`${nfsHostPath}/underpost`, { recursive: true });
|
|
277
|
+
|
|
278
|
+
logger.info('Build', `${nfsHostPath}/underpost/date.sh`);
|
|
279
|
+
fs.writeFileSync(
|
|
280
|
+
`${nfsHostPath}/underpost/date.sh`,
|
|
281
|
+
`${timeZoneSteps.join('\n')}
|
|
282
|
+
${chronySetUp(chronyConfPath).join('\n')}
|
|
283
|
+
`,
|
|
284
|
+
'utf8',
|
|
285
|
+
);
|
|
286
|
+
|
|
287
|
+
logger.info('Build', `${nfsHostPath}/underpost/keyboard.sh`);
|
|
288
|
+
fs.writeFileSync(
|
|
289
|
+
`${nfsHostPath}/underpost/keyboard.sh`,
|
|
290
|
+
`${keyboardSteps.join('\n')}
|
|
291
|
+
`,
|
|
292
|
+
'utf8',
|
|
293
|
+
);
|
|
294
|
+
|
|
295
|
+
logger.info('Build', `${nfsHostPath}/underpost/dns.sh`);
|
|
296
|
+
// echo "nameserver ${process.env.MAAS_DNS}" | tee /etc/resolv.conf > /dev/null
|
|
297
|
+
fs.writeFileSync(
|
|
298
|
+
`${nfsHostPath}/underpost/dns.sh`,
|
|
299
|
+
`rm /etc/resolv.conf
|
|
300
|
+
echo 'nameserver 8.8.8.8' > /run/systemd/resolve/stub-resolv.conf
|
|
301
|
+
ln -sf /run/systemd/resolve/stub-resolv.conf /etc/resolv.conf`,
|
|
302
|
+
'utf8',
|
|
303
|
+
);
|
|
304
|
+
|
|
305
|
+
logger.info('Build', `${nfsHostPath}/underpost/help.sh`);
|
|
306
|
+
fs.writeFileSync(
|
|
307
|
+
`${nfsHostPath}/underpost/help.sh`,
|
|
308
|
+
`echo "=== Cloud init utils ==="
|
|
309
|
+
echo "sudo cloud-init --all-stages"
|
|
310
|
+
echo "sudo cloud-init init --local"
|
|
311
|
+
echo "sudo cloud-init init"
|
|
312
|
+
echo "sudo cloud-init modules --mode=config"
|
|
313
|
+
echo "sudo cloud-init modules --mode=final"`,
|
|
314
|
+
'utf8',
|
|
315
|
+
);
|
|
316
|
+
|
|
317
|
+
logger.info('Build', `${nfsHostPath}/underpost/test.sh`);
|
|
318
|
+
fs.writeFileSync(
|
|
319
|
+
`${nfsHostPath}/underpost/test.sh`,
|
|
320
|
+
`echo -e "\n=== Current date/time ==="
|
|
321
|
+
date '+%Y-%m-%d %H:%M:%S'
|
|
322
|
+
echo -e "\n=== Keyboard layout ==="
|
|
323
|
+
cat /etc/default/keyboard
|
|
324
|
+
echo -e "\n=== Registered users ==="
|
|
325
|
+
cut -d: -f1 /etc/passwd
|
|
326
|
+
`,
|
|
327
|
+
'utf8',
|
|
328
|
+
);
|
|
329
|
+
|
|
330
|
+
logger.info('Build', `${nfsHostPath}/underpost/config-path.sh`);
|
|
331
|
+
fs.writeFileSync(`${nfsHostPath}/underpost/config-path.sh`, `echo "/etc/cloud/cloud.cfg.d/90_maas.cfg"`, 'utf8');
|
|
332
|
+
|
|
333
|
+
shellExec(`sudo rm -rf ${nfsHostPath}/root/.ssh`);
|
|
334
|
+
shellExec(`sudo rm -rf ${nfsHostPath}/home/root/.ssh`);
|
|
335
|
+
|
|
336
|
+
fs.copySync(`/root/.ssh`, `${nfsHostPath}/root/.ssh`);
|
|
337
|
+
|
|
338
|
+
logger.info('Run', `${nfsHostPath}/underpost/test.sh`);
|
|
339
|
+
runSteps(nfsHostPath, [
|
|
340
|
+
`chmod +x /underpost/date.sh`,
|
|
341
|
+
`chmod +x /underpost/keyboard.sh`,
|
|
342
|
+
`chmod +x /underpost/dns.sh`,
|
|
343
|
+
`chmod +x /underpost/help.sh`,
|
|
344
|
+
`chmod +x /underpost/config-path.sh`,
|
|
345
|
+
`chmod +x /underpost/test.sh`,
|
|
346
|
+
`sudo chmod 700 ~/.ssh/`,
|
|
347
|
+
`sudo chmod 600 ~/.ssh/authorized_keys`,
|
|
348
|
+
`sudo chmod 644 ~/.ssh/known_hosts`,
|
|
349
|
+
`sudo chmod 600 ~/.ssh/id_rsa`,
|
|
350
|
+
`sudo chmod 600 /etc/ssh/ssh_host_ed25519_key`,
|
|
351
|
+
`chown -R root:root ~/.ssh`,
|
|
352
|
+
`/underpost/test.sh`,
|
|
353
|
+
]);
|
|
354
|
+
};
|
|
355
|
+
|
|
356
|
+
const updateVirtualRoot = async ({ IP_ADDRESS, architecture, host, nfsHostPath, ipaddr, update, gatewayip }) => {
|
|
357
|
+
// <consumer_key>:<consumer_token>:<secret>
|
|
358
|
+
let [consumer_key, consumer_token, secret] = process.argv.includes('reset')
|
|
359
|
+
? shellExec(`maas apikey --username ${process.env.MAAS_ADMIN_USERNAME}`, {
|
|
360
|
+
stdout: true,
|
|
361
|
+
})
|
|
362
|
+
.trim()
|
|
363
|
+
.split(`\n`)[0]
|
|
364
|
+
.split(':')
|
|
365
|
+
: shellExec(`maas apikey --generate --username ${process.env.MAAS_ADMIN_USERNAME}`, {
|
|
366
|
+
stdout: true,
|
|
367
|
+
})
|
|
368
|
+
.trim()
|
|
369
|
+
.split(':');
|
|
370
|
+
|
|
371
|
+
if (process.argv.includes('reset')) secret = '&' + secret;
|
|
372
|
+
|
|
373
|
+
logger.info('Maas api token generated', { consumer_key, consumer_token, secret });
|
|
374
|
+
|
|
375
|
+
if (update) {
|
|
376
|
+
// --reboot
|
|
377
|
+
if (process.argv.includes('reset'))
|
|
378
|
+
shellExec(`sudo chroot ${nfsHostPath} /usr/bin/qemu-aarch64-static /bin/bash <<'EOF'
|
|
379
|
+
sudo cloud-init clean --logs --seed --configs all --machine-id
|
|
380
|
+
sudo rm -rf /var/lib/cloud/*
|
|
381
|
+
EOF`);
|
|
382
|
+
|
|
383
|
+
if (fs.existsSync(`${nfsHostPath}/var/log/`)) {
|
|
384
|
+
fs.writeFileSync(`${nfsHostPath}/var/log/cloud-init.log`, '', 'utf8');
|
|
385
|
+
fs.writeFileSync(`${nfsHostPath}/var/log/cloud-init-output.log`, '', 'utf8');
|
|
386
|
+
}
|
|
387
|
+
} else {
|
|
388
|
+
runSteps(nfsHostPath, installSteps);
|
|
389
|
+
runSteps(nfsHostPath, [
|
|
390
|
+
`useradd -m -s /bin/bash -G sudo root`,
|
|
391
|
+
`echo 'root:root' | chpasswd`,
|
|
392
|
+
`mkdir -p /home/root/.ssh`,
|
|
393
|
+
`echo '${fs.readFileSync(
|
|
394
|
+
`/home/dd/engine/engine-private/deploy/id_rsa.pub`,
|
|
395
|
+
'utf8',
|
|
396
|
+
)}' > /home/root/.ssh/authorized_keys`,
|
|
397
|
+
`chown -R root /home/root/.ssh`,
|
|
398
|
+
`chmod 700 /home/root/.ssh`,
|
|
399
|
+
`chmod 600 /home/root/.ssh/authorized_keys`,
|
|
400
|
+
]);
|
|
401
|
+
runSteps(nfsHostPath, [
|
|
402
|
+
// `date -s "${shellExec(`date '+%Y-%m-%d %H:%M:%S'`, { stdout: true }).trim()}"`,
|
|
403
|
+
// `date`,
|
|
404
|
+
...timeZoneSteps,
|
|
405
|
+
...chronySetUp(chronyConfPath),
|
|
406
|
+
...keyboardSteps,
|
|
407
|
+
]);
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
runSteps(
|
|
411
|
+
nfsHostPath,
|
|
412
|
+
cloudConfigFactory(
|
|
413
|
+
{ IP_ADDRESS, architecture, host, nfsHostPath, ipaddr, update, gatewayip },
|
|
414
|
+
{
|
|
415
|
+
consumer_key,
|
|
416
|
+
consumer_token,
|
|
417
|
+
secret,
|
|
418
|
+
},
|
|
419
|
+
),
|
|
420
|
+
);
|
|
421
|
+
installUbuntuUnderpostTools(nfsHostPath);
|
|
422
|
+
};
|
|
423
|
+
|
|
326
424
|
try {
|
|
327
425
|
switch (operator) {
|
|
328
426
|
case 'save':
|
|
@@ -1863,7 +1961,7 @@ EOF`);
|
|
|
1863
1961
|
|
|
1864
1962
|
// identity:
|
|
1865
1963
|
// hostname: rpi4
|
|
1866
|
-
// username:
|
|
1964
|
+
// username: root
|
|
1867
1965
|
// password: "{{PASSWORD}}"
|
|
1868
1966
|
|
|
1869
1967
|
// ssh:
|
package/cli.md
CHANGED
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.815
|
|
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.815
|
|
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": "@underpostnet/underpost",
|
|
5
|
-
"version": "2.8.
|
|
5
|
+
"version": "2.8.815",
|
|
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",
|
package/src/cli/cluster.js
CHANGED
|
@@ -508,20 +508,24 @@ net.ipv4.ip_forward = 1' | sudo tee ${iptableConfPath}`);
|
|
|
508
508
|
logger.info('Phase 1/6: Cleaning up Kubernetes resources (PVCs, PVs) while API server is accessible...');
|
|
509
509
|
|
|
510
510
|
// Get all Persistent Volumes and identify their host paths for data deletion.
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
511
|
+
try {
|
|
512
|
+
const pvListJson = shellExec(`kubectl get pv -o json || echo '{"items":[]}'`, { stdout: true, silent: true });
|
|
513
|
+
const pvList = JSON.parse(pvListJson);
|
|
514
|
+
|
|
515
|
+
if (pvList.items && pvList.items.length > 0) {
|
|
516
|
+
for (const pv of pvList.items) {
|
|
517
|
+
// Check if the PV uses hostPath and delete its contents
|
|
518
|
+
if (pv.spec.hostPath && pv.spec.hostPath.path) {
|
|
519
|
+
const hostPath = pv.spec.hostPath.path;
|
|
520
|
+
logger.info(`Removing data from host path for PV '${pv.metadata.name}': ${hostPath}`);
|
|
521
|
+
shellExec(`sudo rm -rf ${hostPath}/* || true`);
|
|
522
|
+
}
|
|
521
523
|
}
|
|
524
|
+
} else {
|
|
525
|
+
logger.info('No Persistent Volumes found with hostPath to clean up.');
|
|
522
526
|
}
|
|
523
|
-
}
|
|
524
|
-
logger.
|
|
527
|
+
} catch (error) {
|
|
528
|
+
logger.error('Failed to clean up Persistent Volumes:', error);
|
|
525
529
|
}
|
|
526
530
|
|
|
527
531
|
// Phase 2: Stop Kubelet/K3s agent and remove CNI configuration
|