underpost 2.8.781 → 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.781
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.781
1
+ ## underpost ci/cd cli v2.8.783
2
2
 
3
3
  ### Usage: `underpost [options] [command]`
4
4
  ```
@@ -204,7 +204,6 @@ Options:
204
204
  --mongodb Init with mongodb statefulset
205
205
  --postgresql Init with postgresql statefulset
206
206
  --mongodb4 Init with mongodb 4.4 service
207
- --istio Init base istio cluster
208
207
  --valkey Init with valkey service
209
208
  --contour Init with project contour base HTTPProxy and envoy
210
209
  --cert-manager Init with letsencrypt-prod ClusterIssuer
@@ -473,10 +472,15 @@ Options:
473
472
  Lxd management
474
473
 
475
474
  Options:
476
- --init Init lxd
477
- --reset Reset lxd on current machine
478
- --install Install lxd on current machine
479
- -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
480
484
 
481
485
  ```
482
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.781'
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.781",
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",
@@ -92,8 +92,8 @@ class UnderpostCluster {
92
92
 
93
93
  if (
94
94
  !alrreadyCluster &&
95
- ((!options.istio && !UnderpostDeploy.API.get('kube-apiserver-kind-control-plane')[0]) ||
96
- (options.istio === true && !UnderpostDeploy.API.get('calico-kube-controllers')[0]))
95
+ ((!options.kubeadm && !UnderpostDeploy.API.get('kube-apiserver-kind-control-plane')[0]) ||
96
+ (options.kubeadm === true && !UnderpostDeploy.API.get('calico-kube-controllers')[0]))
97
97
  ) {
98
98
  shellExec(`sudo setenforce 0`);
99
99
  shellExec(`sudo sed -i 's/^SELINUX=enforcing$/SELINUX=permissive/' /etc/selinux/config`);
@@ -106,7 +106,9 @@ 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
- if (options.istio === true) {
109
+ shellExec(`sudo systemctl daemon-reload`);
110
+ shellExec(`sudo systemctl restart containerd`);
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"`,
@@ -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`);
@@ -464,14 +464,14 @@ Allocatable:
464
464
  },
465
465
  initHost() {
466
466
  // Base
467
- shellExec(`sudo dnf update -y`);
468
- shellExec(`sudo dnf install epel-release -y`);
467
+ shellExec(`sudo dnf -y update`);
468
+ shellExec(`sudo dnf -y install epel-release`);
469
469
  // Install docker
470
470
  shellExec(`sudo dnf -y install dnf-plugins-core
471
471
  sudo dnf config-manager --add-repo https://download.docker.com/linux/rhel/docker-ce.repo`);
472
- shellExec(`sudo dnf install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin`);
472
+ shellExec(`sudo dnf -y install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin`);
473
473
  // Install podman
474
- shellExec(`sudo dnf install podman`);
474
+ shellExec(`sudo dnf -y install podman`);
475
475
  // Install kind
476
476
  shellExec(`[ $(uname -m) = aarch64 ] && curl -Lo ./kind https://kind.sigs.k8s.io/dl/v0.29.0/kind-linux-arm64
477
477
  chmod +x ./kind
package/src/cli/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import dotenv from 'dotenv';
2
2
  import { Command } from 'commander';
3
3
  import Underpost from '../index.js';
4
- import { getUnderpostRootPath, loadConf } from '../server/conf.js';
4
+ import { getNpmRootPath, getUnderpostRootPath, loadConf } from '../server/conf.js';
5
5
  import fs from 'fs-extra';
6
6
  import { commitData } from '../client/components/core/CommonJs.js';
7
7
  import { shellExec } from '../server/process.js';
@@ -97,7 +97,7 @@ program
97
97
  .option('--mongodb', 'Init with mongodb statefulset')
98
98
  .option('--postgresql', 'Init with postgresql statefulset')
99
99
  .option('--mongodb4', 'Init with mongodb 4.4 service')
100
- .option('--istio', 'Init base istio cluster')
100
+ // .option('--istio', 'Init base istio service mesh')
101
101
  .option('--valkey', 'Init with valkey service')
102
102
  .option('--contour', 'Init with project contour base HTTPProxy and envoy')
103
103
  .option('--cert-manager', 'Init with letsencrypt-prod ClusterIssuer')
@@ -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.781';
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;