underpost 2.8.788 → 2.8.791

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.788
71
+ ## underpost ci/cd cli v2.8.791
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.788
1
+ ## underpost ci/cd cli v2.8.791
2
2
 
3
3
  ### Usage: `underpost [options] [command]`
4
4
  ```
@@ -475,19 +475,26 @@ Options:
475
475
  Lxd management
476
476
 
477
477
  Options:
478
- --init Init lxd
479
- --reset Reset lxd on current machine
480
- --install Install lxd on current machine
481
- --dev Set dev context env
482
- --create-virtual-network Create lxd virtual network bridge
483
- --create-admin-profile Create admin profile for lxd management
484
- --control set control node vm context
485
- --worker set worker node context
486
- --create-vm <vm-id> Create default virtual machines
487
- --init-vm <vm-id> Get init vm underpost script
488
- --info-vm <vm-id> Get all info vm
489
- --root-size <gb-size> Set root size vm
490
- -h, --help display help for command
478
+ --init Init lxd
479
+ --reset Reset lxd on current machine
480
+ --install Install lxd on current machine
481
+ --dev Set dev context env
482
+ --create-virtual-network Create lxd virtual network bridge
483
+ --create-admin-profile Create admin profile for lxd management
484
+ --control set control node vm context
485
+ --worker set worker node context
486
+ --create-vm <vm-id> Create default virtual machines
487
+ --init-vm <vm-id> Get init vm underpost script
488
+ --info-vm <vm-id> Get all info vm
489
+ --root-size <gb-size> Set root size vm
490
+ --join-node <nodes> Comma separated worker and control node e.
491
+ g. k8s-worker-1,k8s-control
492
+ --expose <vm-name-ports> Vm name and : separated with Comma separated
493
+ vm port to expose e. g. k8s-control:80,443
494
+ --delete-expose <vm-name-ports> Vm name and : separated with Comma separated
495
+ vm port to remove expose e. g.
496
+ k8s-control:80,443
497
+ -h, --help display help for command
491
498
 
492
499
  ```
493
500
 
@@ -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.788'
61
+ engine.version: '2.8.791'
62
62
  networks:
63
63
  - load-balancer
64
64
 
@@ -7,6 +7,7 @@ devices:
7
7
  name: eth0
8
8
  network: lxdbr0
9
9
  type: nic
10
+ ipv4.address: 10.250.250.100
10
11
  root:
11
12
  path: /
12
13
  pool: local # lxc storage list
@@ -27,6 +27,11 @@ resize2fs /dev/sda2
27
27
  echo "Disk and filesystem resized successfully."
28
28
  sudo dnf install -y tar
29
29
  sudo dnf install -y bzip2
30
+ sudo dnf install -y git
31
+ sudo dnf -y update
32
+ sudo dnf -y install epel-release
33
+ sudo dnf install -y ufw
34
+ sudo systemctl enable --now ufw
30
35
  curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash
31
36
  NVM_DIR="$([ -z "${XDG_CONFIG_HOME-}" ] && printf %s "${HOME}/.nvm" || printf %s "${XDG_CONFIG_HOME}/nvm")"
32
37
  [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
@@ -77,17 +82,62 @@ echo "USE_WORKER = $USE_WORKER"
77
82
  underpost cluster --kubeadm
78
83
  underpost cluster --reset
79
84
 
85
+ PORTS=(
86
+ 22 # SSH
87
+ 80 # HTTP
88
+ 443 # HTTPS
89
+ 53 # DNS (TCP/UDP)
90
+ 66 # TFTP
91
+ 67 # DHCP
92
+ 69 # TFTP
93
+ 111 # rpcbind
94
+ 179 # Calico BGP
95
+ 2049 # NFS
96
+ 20048 # NFS mountd
97
+ 4011 # PXE boot
98
+ 5240 # snapd API
99
+ 5248 # Juju controller
100
+ 6443 # Kubernetes API
101
+ 9153 # CoreDNS metrics
102
+ 10250 # Kubelet API
103
+ 10251 # kube-scheduler
104
+ 10252 # kube-controller-manager
105
+ 10255 # Kubelet read-only (deprecated)
106
+ 10257 # controller-manager (v1.23+)
107
+ 10259 # scheduler (v1.23+)
108
+ )
109
+
110
+ PORT_RANGES=(
111
+ 2379:2380 # etcd
112
+ # 30000:32767 # NodePort range
113
+ # 3000:3100 # App node ports
114
+ 32765:32766 # Ephemeral ports
115
+ 6783:6784 # Weave Net
116
+ )
117
+
118
+ # Open individual ports
119
+ for PORT in "${PORTS[@]}"; do
120
+ ufw allow ${PORT}/tcp
121
+ ufw allow ${PORT}/udp
122
+ done
123
+
124
+ # Open port ranges
125
+ for RANGE in "${PORT_RANGES[@]}"; do
126
+ ufw allow ${RANGE}/tcp
127
+ ufw allow ${RANGE}/udp
128
+ done
129
+
80
130
  # Behavior based on flags
81
131
  if $USE_KUBEADM; then
82
132
  echo "Running control node with kubeadm..."
83
133
  underpost cluster --kubeadm
84
- kubectl get pods --all-namespaces -o wide -w
134
+ # kubectl get pods --all-namespaces -o wide -w
85
135
  fi
86
136
 
87
137
  if $USE_KIND; then
88
138
  echo "Running control node with kind..."
89
139
  underpost cluster
90
- kubectl get pods --all-namespaces -o wide -w
140
+ # kubectl get pods --all-namespaces -o wide -w
91
141
  fi
92
142
 
93
143
  if $USE_WORKER; then
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.788",
5
+ "version": "2.8.791",
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",
@@ -475,9 +475,6 @@ Allocatable:
475
475
  return resources;
476
476
  },
477
477
  initHost() {
478
- // Base
479
- shellExec(`sudo dnf -y update`);
480
- shellExec(`sudo dnf -y install epel-release`);
481
478
  // Install docker
482
479
  shellExec(`sudo dnf -y install dnf-plugins-core
483
480
  sudo dnf config-manager --add-repo https://download.docker.com/linux/rhel/docker-ce.repo`);
package/src/cli/index.js CHANGED
@@ -284,6 +284,15 @@ program
284
284
  .option('--init-vm <vm-id>', 'Get init vm underpost script')
285
285
  .option('--info-vm <vm-id>', 'Get all info vm')
286
286
  .option('--root-size <gb-size>', 'Set root size vm')
287
+ .option('--join-node <nodes>', 'Comma separated worker and control node e. g. k8s-worker-1,k8s-control')
288
+ .option(
289
+ '--expose <vm-name-ports>',
290
+ 'Vm name and : separated with Comma separated vm port to expose e. g. k8s-control:80,443',
291
+ )
292
+ .option(
293
+ '--delete-expose <vm-name-ports>',
294
+ 'Vm name and : separated with Comma separated vm port to remove expose e. g. k8s-control:80,443',
295
+ )
287
296
  .description('Lxd management')
288
297
  .action(UnderpostLxd.API.callback);
289
298
 
package/src/cli/lxd.js CHANGED
@@ -18,6 +18,9 @@ class UnderpostLxd {
18
18
  createVm: '',
19
19
  infoVm: '',
20
20
  rootSize: '',
21
+ joinNode: '',
22
+ expose: '',
23
+ deleteExpose: '',
21
24
  },
22
25
  ) {
23
26
  const npmRoot = getNpmRootPath();
@@ -62,17 +65,57 @@ ipv6.address=none`);
62
65
  let flag = '';
63
66
  if (options.control === true) {
64
67
  flag = ' -s -- --kubeadm';
68
+ shellExec(`lxc exec ${options.initVm} -- bash -c 'mkdir -p /home/dd/engine'`);
69
+ shellExec(`lxc file push /home/dd/engine/engine-private ${options.initVm}/home/dd/engine --recursive`);
65
70
  } else if (options.worker == true) {
66
71
  flag = ' -s -- --worker';
67
72
  }
68
73
  pbcopy(`cat ${underpostRoot}/manifests/lxd/underpost-setup.sh | lxc exec ${options.initVm} -- bash${flag}`);
69
74
  }
75
+ if (options.joinNode && typeof options.joinNode === 'string') {
76
+ const [workerNode, controlNode] = options.joinNode.split(',');
77
+ const token = shellExec(
78
+ `echo "$(lxc exec ${controlNode} -- bash -c 'sudo kubeadm token create --print-join-command')"`,
79
+ { stdout: true },
80
+ );
81
+ shellExec(`lxc exec ${workerNode} -- bash -c '${token}'`);
82
+ }
70
83
  if (options.infoVm && typeof options.infoVm === 'string') {
71
84
  shellExec(`lxc config show ${options.infoVm}`);
72
85
  shellExec(`lxc info --show-log ${options.infoVm}`);
73
86
  shellExec(`lxc info ${options.infoVm}`);
74
87
  shellExec(`lxc list ${options.infoVm}`);
75
88
  }
89
+ if (options.expose && typeof options.expose === 'string') {
90
+ const [controlNode, ports] = options.expose.split(':');
91
+ console.log({ controlNode, ports });
92
+ const protocols = ['tcp']; // udp
93
+ const hostIp = getLocalIPv4Address();
94
+ // The vmIp will now be the static IP assigned in the admin-profile
95
+ const vmIp = shellExec(
96
+ `lxc list ${controlNode} --format json | jq -r '.[0].state.network.enp5s0.addresses[] | select(.family=="inet") | .address'`,
97
+ { stdout: true },
98
+ ).trim();
99
+ for (const port of ports.split(',')) {
100
+ for (const protocol of protocols) {
101
+ shellExec(`lxc config device remove ${controlNode} ${controlNode}-${protocol}-port-${port}`);
102
+ shellExec(
103
+ `lxc config device add ${controlNode} ${controlNode}-${protocol}-port-${port} proxy listen=${protocol}:${hostIp}:${port} connect=${protocol}:${vmIp}:${port} nat=true`,
104
+ );
105
+ }
106
+ }
107
+ }
108
+ if (options.deleteExpose && typeof options.deleteExpose === 'string') {
109
+ const [controlNode, ports] = options.deleteExpose.split(':');
110
+ console.log({ controlNode, ports });
111
+ const protocols = ['tcp']; // udp
112
+ for (const port of ports.split(',')) {
113
+ for (const protocol of protocols) {
114
+ // The device name is consistent: {controlNode}-port-{port}
115
+ shellExec(`lxc config device remove ${controlNode} ${controlNode}-${protocol}-port-${port}`);
116
+ }
117
+ }
118
+ }
76
119
  },
77
120
  };
78
121
  }
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.788';
34
+ static version = 'v2.8.791';
35
35
  /**
36
36
  * Repository cli API
37
37
  * @static