underpost 2.8.782 → 2.8.783

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.783
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.783
2
2
 
3
3
  ### Usage: `underpost [options] [command]`
4
4
  ```
@@ -472,10 +472,15 @@ 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
+ -h, --help display help for command
479
484
 
480
485
  ```
481
486
 
@@ -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.783'
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,11 @@
1
+ mkdir -p /home/dd
2
+ sudo dnf install -y tar
3
+ sudo dnf install -y bzip2
4
+ curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash
5
+ NVM_DIR="$([ -z "${XDG_CONFIG_HOME-}" ] && printf %s "${HOME}/.nvm" || printf %s "${XDG_CONFIG_HOME}/nvm")"
6
+ [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
7
+ nvm install 23.8.0
8
+ nvm use 23.8.0
9
+ npm install -g underpost
10
+ chmod +x /root/.nvm/versions/node/v23.8.0/bin/underpost
11
+ 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.783",
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,6 +106,8 @@ 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(
@@ -121,14 +123,12 @@ class UnderpostCluster {
121
123
  // `wget https://raw.githubusercontent.com/projectcalico/calico/v3.25.0/manifests/custom-resources.yaml`,
122
124
  // );
123
125
  shellExec(`sudo kubectl apply -f ${underpostRoot}/manifests/kubeadm-calico-config.yaml`);
124
- shellExec(`sudo systemctl restart containerd`);
125
126
  const nodeName = os.hostname();
126
127
  shellExec(`kubectl taint nodes ${nodeName} node-role.kubernetes.io/control-plane:NoSchedule-`);
127
128
  shellExec(
128
129
  `kubectl apply -f https://raw.githubusercontent.com/rancher/local-path-provisioner/master/deploy/local-path-storage.yaml`,
129
130
  );
130
131
  } else {
131
- shellExec(`sudo systemctl restart containerd`);
132
132
  if (options.full === true || options.dedicatedGpu === true) {
133
133
  // https://kubernetes.io/docs/tasks/manage-gpus/scheduling-gpus/
134
134
  shellExec(`cd ${underpostRoot}/manifests && kind create cluster --config kind-config-cuda.yaml`);
package/src/cli/index.js CHANGED
@@ -272,6 +272,11 @@ 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')
275
280
  .description('Lxd management')
276
281
  .action(UnderpostLxd.API.callback);
277
282
 
package/src/cli/lxd.js CHANGED
@@ -1,8 +1,21 @@
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
+ },
16
+ ) {
17
+ const npmRoot = getNpmRootPath();
18
+ const underpostRoot = options?.dev === true ? '.' : `${npmRoot}/underpost`;
6
19
  if (options.reset === true) {
7
20
  shellExec(`sudo systemctl stop snap.lxd.daemon`);
8
21
  shellExec(`sudo snap remove lxd --purge`);
@@ -11,6 +24,28 @@ class UnderpostLxd {
11
24
  if (options.init === true) {
12
25
  shellExec(`sudo systemctl start snap.lxd.daemon`);
13
26
  shellExec(`sudo systemctl status snap.lxd.daemon`);
27
+ shellExec(`lxd init --preseed < ${underpostRoot}/manifests/lxd/lxd-preseed.yaml`);
28
+ shellExec(`lxc cluster list`);
29
+ }
30
+ if (options.createVirtualNetwork === true) {
31
+ shellExec(`lxc network create lxdbr0 \
32
+ ipv4.address=10.250.250.1/24 \
33
+ ipv4.nat=true \
34
+ ipv4.dhcp=true \
35
+ ipv6.address=none`);
36
+ }
37
+ if (options.createAdminProfile === true) {
38
+ pbcopy(`lxc profile create admin-profile`);
39
+ shellExec(`cat ${underpostRoot}/manifests/lxd/lxd-admin-profile.yaml | lxc profile edit admin-profile`);
40
+ shellExec(`lxc profile show admin-profile`);
41
+ }
42
+ if (options.createVm && typeof options.createVm === 'string') {
43
+ pbcopy(
44
+ `lxc launch images:rockylinux/9 ${options.createVm} --vm --target lxd-node1 -c limits.cpu=2 -c limits.memory=4GB --profile admin-profile`,
45
+ );
46
+ }
47
+ if (options.initVm && typeof options.initVm === 'string') {
48
+ pbcopy(`cat ${underpostRoot}/manifests/lxd/underpost-setup.sh | lxc exec ${options.initVm} -- bash`);
14
49
  }
15
50
  },
16
51
  };
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.783';
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;