underpost 2.8.784 → 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.784
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.784
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,6 +481,7 @@ 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
483
487
  --info-vm <vm-id> Get all info vm
@@ -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.784'
61
+ engine.version: '2.8.785'
62
62
  networks:
63
63
  - load-balancer
64
64
 
@@ -25,8 +25,6 @@ EOF
25
25
  resize2fs /dev/sda2
26
26
 
27
27
  echo "Disk and filesystem resized successfully."
28
-
29
- mkdir -p /home/dd
30
28
  sudo dnf install -y tar
31
29
  sudo dnf install -y bzip2
32
30
  curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash
@@ -34,6 +32,61 @@ NVM_DIR="$([ -z "${XDG_CONFIG_HOME-}" ] && printf %s "${HOME}/.nvm" || printf %s
34
32
  [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
35
33
  nvm install 23.8.0
36
34
  nvm use 23.8.0
35
+ echo "
36
+ ██╗░░░██╗███╗░░██╗██████╗░███████╗██████╗░██████╗░░█████╗░░██████╗████████╗
37
+ ██║░░░██║████╗░██║██╔══██╗██╔════╝██╔══██╗██╔══██╗██╔══██╗██╔════╝╚══██╔══╝
38
+ ██║░░░██║██╔██╗██║██║░░██║█████╗░░██████╔╝██████╔╝██║░░██║╚█████╗░░░░██║░░░
39
+ ██║░░░██║██║╚████║██║░░██║██╔══╝░░██╔══██╗██╔═══╝░██║░░██║░╚═══██╗░░░██║░░░
40
+ ╚██████╔╝██║░╚███║██████╔╝███████╗██║░░██║██║░░░░░╚█████╔╝██████╔╝░░░██║░░░
41
+ ░╚═════╝░╚═╝░░╚══╝╚═════╝░╚══════╝╚═╝░░╚═╝╚═╝░░░░░░╚════╝░╚═════╝░░░░╚═╝░░░
42
+
43
+ Installing underpost k8s node ...
44
+
45
+ "
37
46
  npm install -g underpost
38
47
  chmod +x /root/.nvm/versions/node/v23.8.0/bin/underpost
39
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.784",
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,31 +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(`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`);
119
109
  // https://docs.tigera.io/calico/latest/getting-started/kubernetes/quickstart
120
110
  shellExec(
121
111
  `sudo kubectl create -f https://raw.githubusercontent.com/projectcalico/calico/v3.29.3/manifests/tigera-operator.yaml`,
@@ -140,8 +130,8 @@ class UnderpostCluster {
140
130
  }.yaml`,
141
131
  );
142
132
  }
143
- shellExec(`sudo chown $(id -u):$(id -g) $HOME/.kube/config**`);
144
133
  }
134
+ UnderpostCluster.API.postConfig({ postConfig: true });
145
135
  } else logger.warn('Cluster already initialized');
146
136
 
147
137
  // shellExec(`sudo kubectl apply -f ${underpostRoot}/manifests/kubelet-config.yaml`);
@@ -288,6 +278,27 @@ class UnderpostCluster {
288
278
  shellExec(`sudo kubectl apply -f ${underpostRoot}/manifests/${letsEncName}.yaml`);
289
279
  }
290
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
+ },
291
302
  // This function performs a comprehensive reset of Kubernetes and container environments
292
303
  // on the host machine. Its primary goal is to clean up cluster components, temporary files,
293
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,6 +278,7 @@ 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')
280
284
  .option('--info-vm <vm-id>', 'Get all info vm')
package/src/cli/lxd.js CHANGED
@@ -10,7 +10,9 @@ 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: '',
15
17
  infoVm: '',
16
18
  rootSize: '',
@@ -51,7 +53,8 @@ ipv6.address=none`);
51
53
  );
52
54
  }
53
55
  if (options.initVm && typeof options.initVm === 'string') {
54
- 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}`);
55
58
  }
56
59
  if (options.infoVm && typeof options.infoVm === 'string') {
57
60
  shellExec(`lxc config show ${options.infoVm}`);
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.784';
34
+ static version = 'v2.8.785';
35
35
  /**
36
36
  * Repository cli API
37
37
  * @static