underpost 2.8.783 → 2.8.785

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.783
71
+ ## underpost ci/cd cli v2.8.785
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.783
1
+ ## underpost ci/cd cli v2.8.785
2
2
 
3
3
  ### Usage: `underpost [options] [command]`
4
4
  ```
@@ -219,6 +219,9 @@ Options:
219
219
  --pull-image Set optional pull associated image
220
220
  --init-host Install k8s node necessary cli env: kind, kubeadm,
221
221
  docker, podman, helm
222
+ --config Set k8s base node config
223
+ --post-config Set k8s base node post config
224
+ --worker Set worker node context
222
225
  -h, --help display help for command
223
226
 
224
227
  ```
@@ -478,8 +481,11 @@ Options:
478
481
  --dev Set dev context env
479
482
  --create-virtual-network Create lxd virtual network bridge
480
483
  --create-admin-profile Create admin profile for lxd management
484
+ --control set control node vm context
481
485
  --create-vm <vm-id> Create default virtual machines
482
486
  --init-vm <vm-id> Get init vm underpost script
487
+ --info-vm <vm-id> Get all info vm
488
+ --root-size <gb-size> Set root size vm
483
489
  -h, --help display help for command
484
490
 
485
491
  ```
@@ -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.783'
61
+ engine.version: '2.8.785'
62
62
  networks:
63
63
  - load-balancer
64
64
 
@@ -1,4 +1,30 @@
1
- mkdir -p /home/dd
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."
2
28
  sudo dnf install -y tar
3
29
  sudo dnf install -y bzip2
4
30
  curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash
@@ -6,6 +32,61 @@ NVM_DIR="$([ -z "${XDG_CONFIG_HOME-}" ] && printf %s "${HOME}/.nvm" || printf %s
6
32
  [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
7
33
  nvm install 23.8.0
8
34
  nvm use 23.8.0
35
+ echo "
36
+ ██╗░░░██╗███╗░░██╗██████╗░███████╗██████╗░██████╗░░█████╗░░██████╗████████╗
37
+ ██║░░░██║████╗░██║██╔══██╗██╔════╝██╔══██╗██╔══██╗██╔══██╗██╔════╝╚══██╔══╝
38
+ ██║░░░██║██╔██╗██║██║░░██║█████╗░░██████╔╝██████╔╝██║░░██║╚█████╗░░░░██║░░░
39
+ ██║░░░██║██║╚████║██║░░██║██╔══╝░░██╔══██╗██╔═══╝░██║░░██║░╚═══██╗░░░██║░░░
40
+ ╚██████╔╝██║░╚███║██████╔╝███████╗██║░░██║██║░░░░░╚█████╔╝██████╔╝░░░██║░░░
41
+ ░╚═════╝░╚═╝░░╚══╝╚═════╝░╚══════╝╚═╝░░╚═╝╚═╝░░░░░░╚════╝░╚═════╝░░░░╚═╝░░░
42
+
43
+ Installing underpost k8s node ...
44
+
45
+ "
9
46
  npm install -g underpost
10
47
  chmod +x /root/.nvm/versions/node/v23.8.0/bin/underpost
11
48
  sudo modprobe br_netfilter
49
+ mkdir -p /home/dd
50
+ cd $(underpost root)/underpost
51
+ underpost cluster --init-host
52
+
53
+ # Default flags
54
+ USE_KUBEADM=false
55
+ USE_KIND=false
56
+ USE_WORKER=false
57
+
58
+ # Loop through arguments
59
+ for arg in "$@"; do
60
+ case "$arg" in
61
+ --kubeadm)
62
+ USE_KUBEADM=true
63
+ ;;
64
+ --kind)
65
+ USE_KIND=true
66
+ ;;
67
+ --worker)
68
+ USE_WORKER=true
69
+ ;;
70
+ esac
71
+ done
72
+
73
+ underpost cluster --kubeadm
74
+ underpost --reset
75
+
76
+ # Behavior based on flags
77
+ if $USE_KUBEADM; then
78
+ echo "Running control node with kubeadm..."
79
+ underpost cluster --kubeadm
80
+ kubectl get pods --all-namespaces -o wide -w
81
+ fi
82
+
83
+ if $USE_KIND; then
84
+ echo "Running control node with kind..."
85
+ underpost cluster
86
+ kubectl get pods --all-namespaces -o wide -w
87
+ fi
88
+
89
+ if $USE_WORKER; then
90
+ echo "Running worker..."
91
+ underpost cluster --worker --config --post-config
92
+ fi
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.783",
5
+ "version": "2.8.785",
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",
@@ -32,6 +32,9 @@ class UnderpostCluster {
32
32
  dedicatedGpu: false,
33
33
  kubeadm: false,
34
34
  initHost: false,
35
+ config: false,
36
+ postConfig: false,
37
+ worker: false,
35
38
  },
36
39
  ) {
37
40
  // sudo dnf update
@@ -41,6 +44,8 @@ class UnderpostCluster {
41
44
  // 4) Install LXD with MAAS from Rocky Linux docs
42
45
  // 5) Install MAAS src from snap
43
46
  if (options.initHost === true) return UnderpostCluster.API.initHost();
47
+ if (options.config) UnderpostCluster.API.config();
48
+ if (options.postConfig) UnderpostCluster.API.postConfig();
44
49
  const npmRoot = getNpmRootPath();
45
50
  const underpostRoot = options?.dev === true ? '.' : `${npmRoot}/underpost`;
46
51
  if (options.infoCapacityPod === true) return logger.info('', UnderpostDeploy.API.resourcesFactory());
@@ -91,30 +96,16 @@ class UnderpostCluster {
91
96
  UnderpostDeploy.API.get('calico-kube-controllers')[0];
92
97
 
93
98
  if (
99
+ !options.worker &&
94
100
  !alrreadyCluster &&
95
101
  ((!options.kubeadm && !UnderpostDeploy.API.get('kube-apiserver-kind-control-plane')[0]) ||
96
102
  (options.kubeadm === true && !UnderpostDeploy.API.get('calico-kube-controllers')[0]))
97
103
  ) {
98
- shellExec(`sudo setenforce 0`);
99
- shellExec(`sudo sed -i 's/^SELINUX=enforcing$/SELINUX=permissive/' /etc/selinux/config`);
100
- shellExec(`sudo systemctl enable --now docker`);
101
- shellExec(`sudo systemctl enable --now kubelet`);
102
- shellExec(`containerd config default > /etc/containerd/config.toml`);
103
- shellExec(`sed -i -e "s/SystemdCgroup = false/SystemdCgroup = true/g" /etc/containerd/config.toml`);
104
- // shellExec(`cp /etc/kubernetes/admin.conf ~/.kube/config`);
105
- // shellExec(`sudo systemctl restart kubelet`);
106
- shellExec(`sudo service docker restart`);
107
- shellExec(`sudo systemctl enable --now containerd.service`);
108
- shellExec(`sudo swapoff -a; sudo sed -i '/swap/d' /etc/fstab`);
109
- shellExec(`sudo systemctl daemon-reload`);
110
- shellExec(`sudo systemctl restart containerd`);
104
+ UnderpostCluster.API.config();
111
105
  if (options.kubeadm === true) {
112
- shellExec(`sysctl net.bridge.bridge-nf-call-iptables=1`);
113
106
  shellExec(
114
107
  `sudo kubeadm init --pod-network-cidr=192.168.0.0/16 --control-plane-endpoint="${os.hostname()}:6443"`,
115
108
  );
116
- shellExec(`sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config`);
117
- shellExec(`sudo chown $(id -u):$(id -g) $HOME/.kube/config**`);
118
109
  // https://docs.tigera.io/calico/latest/getting-started/kubernetes/quickstart
119
110
  shellExec(
120
111
  `sudo kubectl create -f https://raw.githubusercontent.com/projectcalico/calico/v3.29.3/manifests/tigera-operator.yaml`,
@@ -139,8 +130,8 @@ class UnderpostCluster {
139
130
  }.yaml`,
140
131
  );
141
132
  }
142
- shellExec(`sudo chown $(id -u):$(id -g) $HOME/.kube/config**`);
143
133
  }
134
+ UnderpostCluster.API.postConfig({ postConfig: true });
144
135
  } else logger.warn('Cluster already initialized');
145
136
 
146
137
  // shellExec(`sudo kubectl apply -f ${underpostRoot}/manifests/kubelet-config.yaml`);
@@ -287,6 +278,27 @@ class UnderpostCluster {
287
278
  shellExec(`sudo kubectl apply -f ${underpostRoot}/manifests/${letsEncName}.yaml`);
288
279
  }
289
280
  },
281
+
282
+ config(options = { postConfig: false }) {
283
+ if (options.postConfig === true) {
284
+ shellExec(`mkdir -p ~/.kube`);
285
+ shellExec(`sudo -E cp -i /etc/kubernetes/admin.conf ~/.kube/config`);
286
+ shellExec(`sudo -E chown $(id -u):$(id -g) ~/.kube/config`);
287
+ return;
288
+ }
289
+ shellExec(`sudo setenforce 0`);
290
+ shellExec(`sudo sed -i 's/^SELINUX=enforcing$/SELINUX=permissive/' /etc/selinux/config`);
291
+ shellExec(`sudo systemctl enable --now docker`);
292
+ shellExec(`sudo systemctl enable --now kubelet`);
293
+ shellExec(`containerd config default > /etc/containerd/config.toml`);
294
+ shellExec(`sed -i -e "s/SystemdCgroup = false/SystemdCgroup = true/g" /etc/containerd/config.toml`);
295
+ shellExec(`sudo service docker restart`);
296
+ shellExec(`sudo systemctl enable --now containerd.service`);
297
+ shellExec(`sudo swapoff -a; sudo sed -i '/swap/d' /etc/fstab`);
298
+ shellExec(`sudo systemctl daemon-reload`);
299
+ shellExec(`sudo systemctl restart containerd`);
300
+ shellExec(`sysctl net.bridge.bridge-nf-call-iptables=1`);
301
+ },
290
302
  // This function performs a comprehensive reset of Kubernetes and container environments
291
303
  // on the host machine. Its primary goal is to clean up cluster components, temporary files,
292
304
  // and container data, ensuring a clean state for re-initialization or fresh deployments,
package/src/cli/index.js CHANGED
@@ -112,6 +112,9 @@ program
112
112
  .option('--info-capacity-pod', 'display current machine capacity pod info')
113
113
  .option('--pull-image', 'Set optional pull associated image')
114
114
  .option('--init-host', 'Install k8s node necessary cli env: kind, kubeadm, docker, podman, helm')
115
+ .option('--config', 'Set k8s base node config')
116
+ .option('--post-config', 'Set k8s base node post config')
117
+ .option('--worker', 'Set worker node context')
115
118
  .action(Underpost.cluster.init)
116
119
  .description('Manage cluster, for default initialization base kind cluster');
117
120
 
@@ -275,8 +278,11 @@ program
275
278
  .option('--dev', 'Set dev context env')
276
279
  .option('--create-virtual-network', 'Create lxd virtual network bridge')
277
280
  .option('--create-admin-profile', 'Create admin profile for lxd management')
281
+ .option('--control', 'set control node vm context')
278
282
  .option('--create-vm <vm-id>', 'Create default virtual machines')
279
283
  .option('--init-vm <vm-id>', 'Get init vm underpost script')
284
+ .option('--info-vm <vm-id>', 'Get all info vm')
285
+ .option('--root-size <gb-size>', 'Set root size vm')
280
286
  .description('Lxd management')
281
287
  .action(UnderpostLxd.API.callback);
282
288
 
package/src/cli/lxd.js CHANGED
@@ -10,8 +10,12 @@ class UnderpostLxd {
10
10
  dev: false,
11
11
  install: false,
12
12
  createVirtualNetwork: false,
13
- initVm: false,
13
+ control: false,
14
+ worker: false,
15
+ initVm: '',
14
16
  createVm: '',
17
+ infoVm: '',
18
+ rootSize: '',
15
19
  },
16
20
  ) {
17
21
  const npmRoot = getNpmRootPath();
@@ -41,11 +45,22 @@ ipv6.address=none`);
41
45
  }
42
46
  if (options.createVm && typeof options.createVm === 'string') {
43
47
  pbcopy(
44
- `lxc launch images:rockylinux/9 ${options.createVm} --vm --target lxd-node1 -c limits.cpu=2 -c limits.memory=4GB --profile admin-profile`,
48
+ `lxc launch images:rockylinux/9 ${
49
+ options.createVm
50
+ } --vm --target lxd-node1 -c limits.cpu=2 -c limits.memory=4GB --profile admin-profile -d root,size=${
51
+ options.rootSize && typeof options.rootSize === 'string' ? options.rootSize + 'GiB' : '32GiB'
52
+ }`,
45
53
  );
46
54
  }
47
55
  if (options.initVm && typeof options.initVm === 'string') {
48
- pbcopy(`cat ${underpostRoot}/manifests/lxd/underpost-setup.sh | lxc exec ${options.initVm} -- bash`);
56
+ const flag = options.control === true ? '--kubeadm' : '';
57
+ pbcopy(`cat ${underpostRoot}/manifests/lxd/underpost-setup.sh | lxc exec ${options.initVm} -- bash -s ${flag}`);
58
+ }
59
+ if (options.infoVm && typeof options.infoVm === 'string') {
60
+ shellExec(`lxc config show ${options.infoVm}`);
61
+ shellExec(`lxc info --show-log ${options.infoVm}`);
62
+ shellExec(`lxc info ${options.infoVm}`);
63
+ shellExec(`lxc list ${options.infoVm}`);
49
64
  }
50
65
  },
51
66
  };
package/src/index.js CHANGED
@@ -31,7 +31,7 @@ class Underpost {
31
31
  * @type {String}
32
32
  * @memberof Underpost
33
33
  */
34
- static version = 'v2.8.783';
34
+ static version = 'v2.8.785';
35
35
  /**
36
36
  * Repository cli API
37
37
  * @static