underpost 2.8.812 → 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 +235 -142
- 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,78 +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
|
-
|
|
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
|
-
`apt update`,
|
|
82
|
-
`apt install -y cloud-init systemd-sysv openssh-server sudo locales udev util-linux systemd-sysv iproute2 netplan.io ca-certificates curl wget chrony ntpdate keyboard-configuration`,
|
|
83
|
-
`ln -sf /lib/systemd/systemd /sbin/init`,
|
|
84
|
-
|
|
85
|
-
`echo 'deb http://ports.ubuntu.com/ubuntu-ports noble main restricted universe multiverse
|
|
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
|
|
75
|
+
deb http://ports.ubuntu.com/ubuntu-ports noble main restricted universe multiverse
|
|
86
76
|
deb http://ports.ubuntu.com/ubuntu-ports noble-updates main restricted universe multiverse
|
|
87
77
|
deb http://ports.ubuntu.com/ubuntu-ports noble-security main restricted universe multiverse
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
...keyboardSteps,
|
|
109
|
-
|
|
110
|
-
// Create root user
|
|
111
|
-
`useradd -m -s /bin/bash -G sudo root`,
|
|
112
|
-
`echo 'root:root' | chpasswd`,
|
|
113
|
-
`mkdir -p /home/root/.ssh`,
|
|
114
|
-
`echo '${fs.readFileSync(
|
|
115
|
-
`/home/dd/engine/engine-private/deploy/id_rsa.pub`,
|
|
116
|
-
'utf8',
|
|
117
|
-
)}' > /home/root/.ssh/authorized_keys`,
|
|
118
|
-
`chown -R root /home/root/.ssh`,
|
|
119
|
-
`chmod 700 /home/root/.ssh`,
|
|
120
|
-
`chmod 600 /home/root/.ssh/authorized_keys`,
|
|
121
|
-
];
|
|
122
|
-
|
|
123
|
-
let steps = [
|
|
124
|
-
// Configure cloud-init for MAAS
|
|
125
|
-
`cat <<EOF_MAAS_CFG > /etc/cloud/cloud.cfg.d/90_maas.cfg
|
|
78
|
+
EOF`,
|
|
79
|
+
|
|
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
|
|
126
98
|
#cloud-config
|
|
127
99
|
|
|
128
100
|
hostname: ${host}
|
|
@@ -140,37 +112,40 @@ hostname: ${host}
|
|
|
140
112
|
datasource_list: [ MAAS ]
|
|
141
113
|
datasource:
|
|
142
114
|
MAAS:
|
|
143
|
-
metadata_url: http://${IP_ADDRESS}:
|
|
115
|
+
metadata_url: http://${IP_ADDRESS}:5248/MAAS/metadata
|
|
144
116
|
consumer_key: ${consumer_key}
|
|
145
117
|
token_key: ${consumer_token}
|
|
146
118
|
token_secret: ${secret}
|
|
119
|
+
|
|
147
120
|
users:
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
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')}
|
|
154
127
|
|
|
128
|
+
# manage_resolv_conf: true
|
|
129
|
+
# resolv_conf:
|
|
130
|
+
# nameservers: [8.8.8.8]
|
|
155
131
|
|
|
156
132
|
# keyboard:
|
|
157
133
|
# layout: es
|
|
158
134
|
|
|
159
|
-
|
|
160
135
|
# check timedatectl on host
|
|
161
136
|
# timezone: America/Santiago
|
|
162
|
-
timezone: ${timezone}
|
|
163
|
-
|
|
164
|
-
ntp:
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
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
|
|
174
149
|
|
|
175
150
|
# ssh:
|
|
176
151
|
# allow-pw: false
|
|
@@ -187,21 +162,21 @@ packages:
|
|
|
187
162
|
resize_rootfs: false
|
|
188
163
|
growpart:
|
|
189
164
|
mode: off
|
|
190
|
-
network:
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
165
|
+
# network:
|
|
166
|
+
# version: 2
|
|
167
|
+
# ethernets:
|
|
168
|
+
# ${process.env.RPI4_INTERFACE_NAME}:
|
|
169
|
+
# dhcp4: true
|
|
170
|
+
# addresses:
|
|
171
|
+
# - ${ipaddr}/24
|
|
172
|
+
# routes:
|
|
173
|
+
# - to: default
|
|
174
|
+
# via: ${gatewayip}
|
|
200
175
|
|
|
201
176
|
# chpasswd:
|
|
202
177
|
# expire: false
|
|
203
178
|
# users:
|
|
204
|
-
# - {name:
|
|
179
|
+
# - {name: root, password: changeme, type: text}
|
|
205
180
|
|
|
206
181
|
final_message: "The system is up, after $UPTIME seconds"
|
|
207
182
|
|
|
@@ -214,57 +189,26 @@ bootcmd:
|
|
|
214
189
|
- echo "- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -"
|
|
215
190
|
- echo "Init bootcmd"
|
|
216
191
|
- echo "- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -"
|
|
217
|
-
- ntpdate -u ${IP_ADDRESS} || ntpdate -u ${process.env.MAAS_NTP_SERVER}
|
|
218
192
|
runcmd:
|
|
219
193
|
- echo "- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -"
|
|
220
194
|
- echo "Init runcmd"
|
|
221
195
|
- echo "- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -"
|
|
222
196
|
EOF_MAAS_CFG`,
|
|
223
|
-
|
|
197
|
+
];
|
|
224
198
|
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
199
|
+
const runSteps = (nfsHostPath, steps = []) => {
|
|
200
|
+
const script = steps
|
|
201
|
+
.map(
|
|
202
|
+
(s, i) => `echo "step ${i + 1}/${steps.length}: ${s.split('\n')[0]}"
|
|
229
203
|
${s}`,
|
|
230
|
-
|
|
231
|
-
|
|
204
|
+
)
|
|
205
|
+
.join('\n');
|
|
232
206
|
|
|
233
|
-
|
|
207
|
+
const cmd = `sudo chroot ${nfsHostPath} /usr/bin/qemu-aarch64-static /bin/bash <<'EOF_OUTER'
|
|
234
208
|
${script}
|
|
235
209
|
EOF_OUTER`;
|
|
236
210
|
|
|
237
|
-
|
|
238
|
-
};
|
|
239
|
-
|
|
240
|
-
if (update) {
|
|
241
|
-
// --reboot
|
|
242
|
-
shellExec(`sudo chroot ${nfsHostPath} /usr/bin/qemu-aarch64-static /bin/bash <<'EOF'
|
|
243
|
-
sudo cloud-init clean --logs --seed --configs all --machine-id
|
|
244
|
-
sudo rm -rf /var/lib/cloud/*
|
|
245
|
-
EOF`);
|
|
246
|
-
|
|
247
|
-
if (fs.existsSync(`${nfsHostPath}/var/log/`)) {
|
|
248
|
-
fs.writeFileSync(`${nfsHostPath}/var/log/cloud-init.log`, '', 'utf8');
|
|
249
|
-
fs.writeFileSync(`${nfsHostPath}/var/log/cloud-init-output.log`, '', 'utf8');
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
runSteps(steps);
|
|
253
|
-
} else {
|
|
254
|
-
runSteps(installSteps.concat(steps));
|
|
255
|
-
|
|
256
|
-
shellExec(`sudo chroot ${nfsHostPath} /usr/bin/qemu-aarch64-static /bin/bash <<'EOF'
|
|
257
|
-
echo "nameserver ${process.env.MAAS_DNS}" | tee /etc/resolv.conf > /dev/null
|
|
258
|
-
apt update
|
|
259
|
-
EOF`);
|
|
260
|
-
fs.writeFileSync(
|
|
261
|
-
`${nfsHostPath}/dns.sh`,
|
|
262
|
-
`rm /etc/resolv.conf
|
|
263
|
-
echo 'nameserver 8.8.8.8' > /run/systemd/resolve/stub-resolv.conf
|
|
264
|
-
ln -sf /run/systemd/resolve/stub-resolv.conf /etc/resolv.conf`,
|
|
265
|
-
'utf8',
|
|
266
|
-
);
|
|
267
|
-
}
|
|
211
|
+
shellExec(cmd);
|
|
268
212
|
};
|
|
269
213
|
|
|
270
214
|
const chronySetUp = (path) => {
|
|
@@ -328,6 +272,155 @@ logdir /var/log/chrony
|
|
|
328
272
|
];
|
|
329
273
|
};
|
|
330
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
|
+
|
|
331
424
|
try {
|
|
332
425
|
switch (operator) {
|
|
333
426
|
case 'save':
|
|
@@ -1868,7 +1961,7 @@ EOF`);
|
|
|
1868
1961
|
|
|
1869
1962
|
// identity:
|
|
1870
1963
|
// hostname: rpi4
|
|
1871
|
-
// username:
|
|
1964
|
+
// username: root
|
|
1872
1965
|
// password: "{{PASSWORD}}"
|
|
1873
1966
|
|
|
1874
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
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
|