underpost 2.8.782 → 2.8.784

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 CHANGED
@@ -68,7 +68,7 @@ Run dev client server
68
68
  npm run dev
69
69
  ```
70
70
  <!-- -->
71
- ## underpost ci/cd cli v2.8.782
71
+ ## underpost ci/cd cli v2.8.784
72
72
 
73
73
  ### Usage: `underpost [options] [command]`
74
74
  ```
package/cli.md CHANGED
@@ -1,4 +1,4 @@
1
- ## underpost ci/cd cli v2.8.782
1
+ ## underpost ci/cd cli v2.8.784
2
2
 
3
3
  ### Usage: `underpost [options] [command]`
4
4
  ```
@@ -472,10 +472,17 @@ Options:
472
472
  Lxd management
473
473
 
474
474
  Options:
475
- --init Init lxd
476
- --reset Reset lxd on current machine
477
- --install Install lxd on current machine
478
- -h, --help display help for command
475
+ --init Init lxd
476
+ --reset Reset lxd on current machine
477
+ --install Install lxd on current machine
478
+ --dev Set dev context env
479
+ --create-virtual-network Create lxd virtual network bridge
480
+ --create-admin-profile Create admin profile for lxd management
481
+ --create-vm <vm-id> Create default virtual machines
482
+ --init-vm <vm-id> Get init vm underpost script
483
+ --info-vm <vm-id> Get all info vm
484
+ --root-size <gb-size> Set root size vm
485
+ -h, --help display help for command
479
486
 
480
487
  ```
481
488
 
@@ -58,7 +58,7 @@ services:
58
58
  cpus: '0.25'
59
59
  memory: 20M
60
60
  labels: # labels in Compose file instead of Dockerfile
61
- engine.version: '2.8.782'
61
+ engine.version: '2.8.784'
62
62
  networks:
63
63
  - load-balancer
64
64
 
@@ -0,0 +1,16 @@
1
+ config:
2
+ limits.cpu: "2"
3
+ limits.memory: 4GB
4
+ description: vm nat network
5
+ devices:
6
+ eth0:
7
+ name: eth0
8
+ network: lxdbr0
9
+ type: nic
10
+ root:
11
+ path: /
12
+ pool: local # lxc storage list
13
+ size: 100GB
14
+ type: disk
15
+ name: admin-profile
16
+ used_by: []
@@ -0,0 +1,30 @@
1
+ config:
2
+ core.https_address: 127.0.0.1:8443
3
+ networks: []
4
+ storage_pools:
5
+ - config:
6
+ size: 100GiB
7
+ description: ""
8
+ name: local
9
+ driver: zfs
10
+ storage_volumes: []
11
+ profiles:
12
+ - config: {}
13
+ description: ""
14
+ devices:
15
+ root:
16
+ path: /
17
+ pool: local
18
+ type: disk
19
+ name: default
20
+ projects: []
21
+ cluster:
22
+ server_name: lxd-node1
23
+ enabled: true
24
+ member_config: []
25
+ cluster_address: ""
26
+ cluster_certificate: ""
27
+ server_address: ""
28
+ cluster_password: ""
29
+ cluster_token: ""
30
+ cluster_certificate_path: ""
@@ -0,0 +1,39 @@
1
+ #!/bin/bash
2
+
3
+ set -e
4
+
5
+ # Expand /dev/sda2 partition and resize filesystem automatically
6
+
7
+ # Check if parted is installed
8
+ if ! command -v parted &>/dev/null; then
9
+ echo "parted not found, installing..."
10
+ dnf install -y parted
11
+ fi
12
+
13
+ # Get start sector of /dev/sda2
14
+ START_SECTOR=$(parted /dev/sda -ms unit s print | awk -F: '/^2:/{print $2}' | sed 's/s//')
15
+
16
+ # Resize the partition
17
+ parted /dev/sda ---pretend-input-tty <<EOF
18
+ unit s
19
+ resizepart 2 100%
20
+ Yes
21
+ quit
22
+ EOF
23
+
24
+ # Resize the filesystem
25
+ resize2fs /dev/sda2
26
+
27
+ echo "Disk and filesystem resized successfully."
28
+
29
+ mkdir -p /home/dd
30
+ sudo dnf install -y tar
31
+ sudo dnf install -y bzip2
32
+ curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash
33
+ NVM_DIR="$([ -z "${XDG_CONFIG_HOME-}" ] && printf %s "${HOME}/.nvm" || printf %s "${XDG_CONFIG_HOME}/nvm")"
34
+ [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
35
+ nvm install 23.8.0
36
+ nvm use 23.8.0
37
+ npm install -g underpost
38
+ chmod +x /root/.nvm/versions/node/v23.8.0/bin/underpost
39
+ sudo modprobe br_netfilter
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.782",
5
+ "version": "2.8.784",
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",
@@ -106,13 +106,16 @@ class UnderpostCluster {
106
106
  shellExec(`sudo service docker restart`);
107
107
  shellExec(`sudo systemctl enable --now containerd.service`);
108
108
  shellExec(`sudo swapoff -a; sudo sed -i '/swap/d' /etc/fstab`);
109
+ shellExec(`sudo systemctl daemon-reload`);
110
+ shellExec(`sudo systemctl restart containerd`);
109
111
  if (options.kubeadm === true) {
110
112
  shellExec(`sysctl net.bridge.bridge-nf-call-iptables=1`);
111
113
  shellExec(
112
114
  `sudo kubeadm init --pod-network-cidr=192.168.0.0/16 --control-plane-endpoint="${os.hostname()}:6443"`,
113
115
  );
114
- shellExec(`sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config`);
115
- shellExec(`sudo chown $(id -u):$(id -g) $HOME/.kube/config**`);
116
+ shellExec(`mkdir -p ~/.kube`);
117
+ shellExec(`sudo -E cp -i /etc/kubernetes/admin.conf ~/.kube/config`);
118
+ shellExec(`sudo -E chown $(id -u):$(id -g) ~/.kube/config`);
116
119
  // https://docs.tigera.io/calico/latest/getting-started/kubernetes/quickstart
117
120
  shellExec(
118
121
  `sudo kubectl create -f https://raw.githubusercontent.com/projectcalico/calico/v3.29.3/manifests/tigera-operator.yaml`,
@@ -121,14 +124,12 @@ class UnderpostCluster {
121
124
  // `wget https://raw.githubusercontent.com/projectcalico/calico/v3.25.0/manifests/custom-resources.yaml`,
122
125
  // );
123
126
  shellExec(`sudo kubectl apply -f ${underpostRoot}/manifests/kubeadm-calico-config.yaml`);
124
- shellExec(`sudo systemctl restart containerd`);
125
127
  const nodeName = os.hostname();
126
128
  shellExec(`kubectl taint nodes ${nodeName} node-role.kubernetes.io/control-plane:NoSchedule-`);
127
129
  shellExec(
128
130
  `kubectl apply -f https://raw.githubusercontent.com/rancher/local-path-provisioner/master/deploy/local-path-storage.yaml`,
129
131
  );
130
132
  } else {
131
- shellExec(`sudo systemctl restart containerd`);
132
133
  if (options.full === true || options.dedicatedGpu === true) {
133
134
  // https://kubernetes.io/docs/tasks/manage-gpus/scheduling-gpus/
134
135
  shellExec(`cd ${underpostRoot}/manifests && kind create cluster --config kind-config-cuda.yaml`);
package/src/cli/index.js CHANGED
@@ -272,6 +272,13 @@ program
272
272
  .option('--init', 'Init lxd')
273
273
  .option('--reset', 'Reset lxd on current machine')
274
274
  .option('--install', 'Install lxd on current machine')
275
+ .option('--dev', 'Set dev context env')
276
+ .option('--create-virtual-network', 'Create lxd virtual network bridge')
277
+ .option('--create-admin-profile', 'Create admin profile for lxd management')
278
+ .option('--create-vm <vm-id>', 'Create default virtual machines')
279
+ .option('--init-vm <vm-id>', 'Get init vm underpost script')
280
+ .option('--info-vm <vm-id>', 'Get all info vm')
281
+ .option('--root-size <gb-size>', 'Set root size vm')
275
282
  .description('Lxd management')
276
283
  .action(UnderpostLxd.API.callback);
277
284
 
package/src/cli/lxd.js CHANGED
@@ -1,8 +1,23 @@
1
- import { shellExec } from '../server/process.js';
1
+ import { getNpmRootPath } from '../server/conf.js';
2
+ import { pbcopy, shellExec } from '../server/process.js';
2
3
 
3
4
  class UnderpostLxd {
4
5
  static API = {
5
- async callback(options = { init: false, reset: false, install: false }) {
6
+ async callback(
7
+ options = {
8
+ init: false,
9
+ reset: false,
10
+ dev: false,
11
+ install: false,
12
+ createVirtualNetwork: false,
13
+ initVm: false,
14
+ createVm: '',
15
+ infoVm: '',
16
+ rootSize: '',
17
+ },
18
+ ) {
19
+ const npmRoot = getNpmRootPath();
20
+ const underpostRoot = options?.dev === true ? '.' : `${npmRoot}/underpost`;
6
21
  if (options.reset === true) {
7
22
  shellExec(`sudo systemctl stop snap.lxd.daemon`);
8
23
  shellExec(`sudo snap remove lxd --purge`);
@@ -11,6 +26,38 @@ class UnderpostLxd {
11
26
  if (options.init === true) {
12
27
  shellExec(`sudo systemctl start snap.lxd.daemon`);
13
28
  shellExec(`sudo systemctl status snap.lxd.daemon`);
29
+ shellExec(`lxd init --preseed < ${underpostRoot}/manifests/lxd/lxd-preseed.yaml`);
30
+ shellExec(`lxc cluster list`);
31
+ }
32
+ if (options.createVirtualNetwork === true) {
33
+ shellExec(`lxc network create lxdbr0 \
34
+ ipv4.address=10.250.250.1/24 \
35
+ ipv4.nat=true \
36
+ ipv4.dhcp=true \
37
+ ipv6.address=none`);
38
+ }
39
+ if (options.createAdminProfile === true) {
40
+ pbcopy(`lxc profile create admin-profile`);
41
+ shellExec(`cat ${underpostRoot}/manifests/lxd/lxd-admin-profile.yaml | lxc profile edit admin-profile`);
42
+ shellExec(`lxc profile show admin-profile`);
43
+ }
44
+ if (options.createVm && typeof options.createVm === 'string') {
45
+ pbcopy(
46
+ `lxc launch images:rockylinux/9 ${
47
+ options.createVm
48
+ } --vm --target lxd-node1 -c limits.cpu=2 -c limits.memory=4GB --profile admin-profile -d root,size=${
49
+ options.rootSize && typeof options.rootSize === 'string' ? options.rootSize + 'GiB' : '32GiB'
50
+ }`,
51
+ );
52
+ }
53
+ if (options.initVm && typeof options.initVm === 'string') {
54
+ pbcopy(`cat ${underpostRoot}/manifests/lxd/underpost-setup.sh | lxc exec ${options.initVm} -- bash`);
55
+ }
56
+ if (options.infoVm && typeof options.infoVm === 'string') {
57
+ shellExec(`lxc config show ${options.infoVm}`);
58
+ shellExec(`lxc info --show-log ${options.infoVm}`);
59
+ shellExec(`lxc info ${options.infoVm}`);
60
+ shellExec(`lxc list ${options.infoVm}`);
14
61
  }
15
62
  },
16
63
  };
package/src/index.js CHANGED
@@ -11,6 +11,7 @@ import UnderpostDeploy from './cli/deploy.js';
11
11
  import UnderpostRootEnv from './cli/env.js';
12
12
  import UnderpostFileStorage from './cli/fs.js';
13
13
  import UnderpostImage from './cli/image.js';
14
+ import UnderpostLxd from './cli/lxd.js';
14
15
  import UnderpostMonitor from './cli/monitor.js';
15
16
  import UnderpostRepository from './cli/repository.js';
16
17
  import UnderpostScript from './cli/script.js';
@@ -30,7 +31,7 @@ class Underpost {
30
31
  * @type {String}
31
32
  * @memberof Underpost
32
33
  */
33
- static version = 'v2.8.782';
34
+ static version = 'v2.8.784';
34
35
  /**
35
36
  * Repository cli API
36
37
  * @static
@@ -122,6 +123,13 @@ class Underpost {
122
123
  * @memberof Underpost
123
124
  */
124
125
  static monitor = UnderpostMonitor.API;
126
+ /**
127
+ * LXD cli API
128
+ * @static
129
+ * @type {UnderpostLxd.API}
130
+ * @memberof Underpost
131
+ */
132
+ static lxd = UnderpostLxd.API;
125
133
  }
126
134
 
127
135
  const up = Underpost;