underpost 2.8.7 → 2.8.8

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.
Files changed (47) hide show
  1. package/.vscode/extensions.json +34 -2
  2. package/README.md +7 -5
  3. package/bin/db.js +1 -0
  4. package/bin/deploy.js +259 -74
  5. package/cli.md +88 -9
  6. package/conf.js +4 -0
  7. package/docker-compose.yml +1 -1
  8. package/manifests/deployment/adminer/service.yaml +1 -1
  9. package/manifests/deployment/dd-template-development/deployment.yaml +167 -0
  10. package/manifests/deployment/dd-template-development/proxy.yaml +46 -0
  11. package/manifests/deployment/fastapi/initial_data.sh +56 -0
  12. package/manifests/deployment/spark/spark-pi-py.yaml +21 -0
  13. package/manifests/envoy-service-nodeport.yaml +23 -0
  14. package/manifests/kubelet-config.yaml +65 -0
  15. package/manifests/lxd/lxd-admin-profile.yaml +17 -0
  16. package/manifests/lxd/lxd-preseed.yaml +30 -0
  17. package/manifests/lxd/underpost-setup.sh +163 -0
  18. package/manifests/maas/lxd-preseed.yaml +32 -0
  19. package/manifests/maas/maas-setup.sh +82 -0
  20. package/manifests/mariadb/statefulset.yaml +2 -1
  21. package/manifests/mariadb/storage-class.yaml +10 -0
  22. package/manifests/mongodb/kustomization.yaml +1 -1
  23. package/manifests/mongodb/statefulset.yaml +12 -11
  24. package/manifests/mongodb/storage-class.yaml +9 -0
  25. package/manifests/mongodb-4.4/service-deployment.yaml +2 -2
  26. package/manifests/mysql/kustomization.yaml +7 -0
  27. package/manifests/mysql/pv-pvc.yaml +27 -0
  28. package/manifests/mysql/statefulset.yaml +55 -0
  29. package/manifests/postgresql/statefulset.yaml +1 -1
  30. package/manifests/valkey/service.yaml +3 -9
  31. package/manifests/valkey/statefulset.yaml +12 -15
  32. package/package.json +1 -1
  33. package/src/cli/baremetal.js +60 -0
  34. package/src/cli/cluster.js +506 -207
  35. package/src/cli/deploy.js +47 -14
  36. package/src/cli/env.js +2 -2
  37. package/src/cli/image.js +83 -9
  38. package/src/cli/index.js +68 -61
  39. package/src/cli/lxd.js +395 -0
  40. package/src/cli/repository.js +9 -6
  41. package/src/index.js +17 -1
  42. package/src/runtime/lampp/Dockerfile +1 -1
  43. package/src/server/conf.js +58 -0
  44. package/src/server/logger.js +3 -3
  45. package/src/server/runtime.js +1 -1
  46. package/src/server/valkey.js +3 -3
  47. package/manifests/calico-custom-resources.yaml +0 -25
package/src/cli/deploy.js CHANGED
@@ -15,19 +15,20 @@ import dotenv from 'dotenv';
15
15
  import { DataBaseProvider } from '../db/DataBaseProvider.js';
16
16
  import UnderpostRootEnv from './env.js';
17
17
  import UnderpostCluster from './cluster.js';
18
+ import Underpost from '../index.js';
18
19
 
19
20
  const logger = loggerFactory(import.meta);
20
21
 
21
22
  class UnderpostDeploy {
22
23
  static NETWORK = {};
23
24
  static API = {
24
- sync(deployList, { versions, replicas }) {
25
+ sync(deployList, { versions, replicas, kubeadm = false }) {
25
26
  const deployGroupId = 'dd.router';
26
27
  fs.writeFileSync(`./engine-private/deploy/${deployGroupId}`, deployList, 'utf8');
27
28
  const totalPods = deployList.split(',').length * versions.split(',').length * parseInt(replicas);
28
29
  const limitFactor = 0.8;
29
30
  const reserveFactor = 0.05;
30
- const resources = UnderpostCluster.API.getResourcesCapacity();
31
+ const resources = UnderpostCluster.API.getResourcesCapacity(kubeadm);
31
32
  const memory = parseInt(resources.memory.value / totalPods);
32
33
  const cpu = parseInt(resources.cpu.value / totalPods);
33
34
  UnderpostRootEnv.API.set(
@@ -80,14 +81,14 @@ spec:
80
81
  spec:
81
82
  containers:
82
83
  - name: ${deployId}-${env}-${suffix}
83
- image: localhost/debian:underpost
84
- resources:
85
- requests:
86
- memory: "${resources.requests.memory}"
87
- cpu: "${resources.requests.cpu}"
88
- limits:
89
- memory: "${resources.limits.memory}"
90
- cpu: "${resources.limits.cpu}"
84
+ image: localhost/debian-underpost:${Underpost.version}
85
+ # resources:
86
+ # requests:
87
+ # memory: "${resources.requests.memory}"
88
+ # cpu: "${resources.requests.cpu}"
89
+ # limits:
90
+ # memory: "${resources.limits.memory}"
91
+ # cpu: "${resources.limits.cpu}"
91
92
  command:
92
93
  - /bin/sh
93
94
  - -c
@@ -243,6 +244,7 @@ spec:
243
244
  traffic: '',
244
245
  dashboardUpdate: false,
245
246
  replicas: '',
247
+ restoreHosts: false,
246
248
  disableUpdateDeployment: false,
247
249
  infoTraffic: false,
248
250
  rebuildClientsBundle: false,
@@ -254,8 +256,8 @@ kubectl rollout restart deployment/deployment-name
254
256
  kubectl rollout undo deployment/deployment-name
255
257
  kubectl scale statefulsets <stateful-set-name> --replicas=<new-replicas>
256
258
  kubectl get pods -w
257
- kubectl patch statefulset service-valkey --type='json' -p='[{"op": "replace", "path": "/spec/template/spec/containers/0/image", "value":"valkey/valkey:latest"}]'
258
- kubectl patch statefulset service-valkey -p '{"spec":{"template":{"spec":{"containers":[{"name":"service-valkey","imagePullPolicy":"Never"}]}}}}'
259
+ kubectl patch statefulset valkey-service --type='json' -p='[{"op": "replace", "path": "/spec/template/spec/containers/0/image", "value":"valkey/valkey:latest"}]'
260
+ kubectl patch statefulset valkey-service -p '{"spec":{"template":{"spec":{"containers":[{"name":"valkey-service","imagePullPolicy":"Never"}]}}}}'
259
261
  kubectl logs -f <pod-name>
260
262
  kubectl describe pod <pod-name>
261
263
  kubectl exec -it <pod-name> -- bash
@@ -269,6 +271,31 @@ kubectl get ippools -o yaml
269
271
  kubectl get node <node-name> -o jsonpath='{.spec.podCIDR}'
270
272
  kubectl patch ippool default-ipv4-ippool --type='json' -p='[{"op": "replace", "path": "/spec/cidr", "value": "10.244.0.0/16"}]'
271
273
  kubectl patch ippool default-ipv4-ippool --type='json' -p='[{"op": "replace", "path": "/spec/cidr", "value": "192.168.0.0/24"}]'
274
+ sudo podman run --rm localhost/<image-name>:<image-version> <command>
275
+ kubectl get configmap kubelet-config -n kube-system -o yaml > kubelet-config.yaml
276
+ kubectl -n kube-system rollout restart daemonset kube-proxy
277
+ kubectl get EndpointSlice -o wide --all-namespaces -w
278
+ kubectl apply -k manifests/deployment/adminer/.
279
+ kubectl wait --for=condition=Ready pod/busybox1
280
+ kubectl wait --for=jsonpath='{.status.phase}'=Running pod/busybox1
281
+ kubectl wait --for='jsonpath={.status.conditions[?(@.type=="Ready")].status}=True' pod/busybox1
282
+ kubectl wait --for=delete pod/busybox1 --timeout=60s
283
+
284
+ kubectl run --rm -it test-dns --image=busybox:latest --restart=Never -- /bin/sh -c "
285
+ nslookup kubernetes.default.svc.cluster.local;
286
+ nslookup mongodb-service.default.svc.cluster.local;
287
+ nslookup valkey-service.default.svc.cluster.local;
288
+ nc -vz mongodb-service 27017;
289
+ nc -vz valkey-service 6379;
290
+ echo exit code: \\\$?
291
+ "
292
+
293
+ kubectl apply -f - <<EOF
294
+ apiVersion: apps/v1
295
+ kind: StatefulSet
296
+ metadata:
297
+ name: ...
298
+ EOF
272
299
  `);
273
300
  if (deployList === 'dd' && fs.existsSync(`./engine-private/deploy/dd.router`))
274
301
  deployList = fs.readFileSync(`./engine-private/deploy/dd.router`, 'utf8');
@@ -295,11 +322,18 @@ kubectl patch ippool default-ipv4-ippool --type='json' -p='[{"op": "replace", "p
295
322
  shellExec(
296
323
  `kubectl create configmap underpost-config --from-file=/home/dd/engine/engine-private/conf/dd-cron/.env.${env}`,
297
324
  );
325
+ let renderHosts = '';
326
+ let concatHots = '';
298
327
  const etcHost = (
299
328
  concat,
300
329
  ) => `127.0.0.1 ${concat} localhost localhost.localdomain localhost4 localhost4.localdomain4
301
330
  ::1 localhost localhost.localdomain localhost6 localhost6.localdomain6`;
302
- let concatHots = '';
331
+ if (options.restoreHosts === true) {
332
+ renderHosts = etcHost(concatHots);
333
+ fs.writeFileSync(`/etc/hosts`, renderHosts, 'utf8');
334
+ logger.info(renderHosts);
335
+ return;
336
+ }
303
337
 
304
338
  for (const _deployId of deployList.split(',')) {
305
339
  const deployId = _deployId.trim();
@@ -340,7 +374,6 @@ kubectl patch ippool default-ipv4-ippool --type='json' -p='[{"op": "replace", "p
340
374
  shellExec(`sudo kubectl apply -f ./${manifestsPath}/secret.yaml`);
341
375
  }
342
376
  }
343
- let renderHosts;
344
377
  switch (process.platform) {
345
378
  case 'linux':
346
379
  {
package/src/cli/env.js CHANGED
@@ -25,7 +25,7 @@ class UnderpostRootEnv {
25
25
  delete env[key];
26
26
  writeEnv(envPath, env);
27
27
  },
28
- get(key) {
28
+ get(key, value, options = { plain: false }) {
29
29
  const exeRootPath = `${getNpmRootPath()}/underpost`;
30
30
  const envPath = `${exeRootPath}/.env`;
31
31
  if (!fs.existsSync(envPath)) {
@@ -33,7 +33,7 @@ class UnderpostRootEnv {
33
33
  return undefined;
34
34
  }
35
35
  const env = dotenv.parse(fs.readFileSync(envPath, 'utf8'));
36
- logger.info(`${key}(${typeof env[key]})`, env[key]);
36
+ options?.plain === true ? console.log(env[key]) : logger.info(`${key}(${typeof env[key]})`, env[key]);
37
37
  return env[key];
38
38
  },
39
39
  list() {
package/src/cli/image.js CHANGED
@@ -1,9 +1,9 @@
1
1
  import fs from 'fs-extra';
2
- import { shellCd, shellExec } from '../server/process.js';
3
2
  import dotenv from 'dotenv';
4
- import { awaitDeployMonitor, getNpmRootPath } from '../server/conf.js';
5
3
  import { loggerFactory } from '../server/logger.js';
6
- import UnderpostMonitor from './monitor.js';
4
+ import Underpost from '../index.js';
5
+ import { getUnderpostRootPath } from '../server/conf.js';
6
+ import { shellExec } from '../server/process.js';
7
7
 
8
8
  dotenv.config();
9
9
 
@@ -12,9 +12,62 @@ const logger = loggerFactory(import.meta);
12
12
  class UnderpostImage {
13
13
  static API = {
14
14
  dockerfile: {
15
- pullBaseImages() {
15
+ /**
16
+ * @method pullBaseImages
17
+ * @description Pulls base images and builds a 'debian-underpost' image,
18
+ * then loads it into the specified Kubernetes cluster type (Kind, Kubeadm, or K3s).
19
+ * @param {object} options - Options for pulling and loading images.
20
+ * @param {boolean} [options.kindLoad=false] - If true, load image into Kind cluster.
21
+ * @param {boolean} [options.kubeadmLoad=false] - If true, load image into Kubeadm cluster.
22
+ * @param {boolean} [options.k3sLoad=false] - If true, load image into K3s cluster.
23
+ * @param {string} [options.path=false] - Path to the Dockerfile context.
24
+ * @param {string} [options.version=''] - Version tag for the image.
25
+ */
26
+ pullBaseImages(
27
+ options = {
28
+ kindLoad: false,
29
+ kubeadmLoad: false,
30
+ k3sLoad: false,
31
+ path: false,
32
+ version: '',
33
+ },
34
+ ) {
16
35
  shellExec(`sudo podman pull docker.io/library/debian:buster`);
36
+ const IMAGE_NAME = `debian-underpost`;
37
+ const IMAGE_NAME_FULL = `${IMAGE_NAME}:${options.version ?? Underpost.version}`;
38
+ let LOAD_TYPE = '';
39
+ if (options.kindLoad === true) {
40
+ LOAD_TYPE = `--kind-load`;
41
+ } else if (options.kubeadmLoad === true) {
42
+ LOAD_TYPE = `--kubeadm-load`;
43
+ } else if (options.k3sLoad === true) {
44
+ // Handle K3s load type
45
+ LOAD_TYPE = `--k3s-load`;
46
+ }
47
+
48
+ shellExec(
49
+ `underpost dockerfile-image-build --podman-save --reset --image-path=. --path ${
50
+ options.path ?? getUnderpostRootPath()
51
+ } --image-name=${IMAGE_NAME_FULL} ${LOAD_TYPE}`,
52
+ );
17
53
  },
54
+ /**
55
+ * @method build
56
+ * @description Builds a Docker image using Podman, optionally saves it as a tar archive,
57
+ * and loads it into a specified Kubernetes cluster (Kind, Kubeadm, or K3s).
58
+ * @param {object} options - Options for building and loading images.
59
+ * @param {string} [options.path=''] - The path to the directory containing the Dockerfile.
60
+ * @param {string} [options.imageName=''] - The name and tag for the image (e.g., 'my-app:latest').
61
+ * @param {string} [options.imagePath=''] - Directory to save the image tar file.
62
+ * @param {string} [options.dockerfileName=''] - Name of the Dockerfile (defaults to 'Dockerfile').
63
+ * @param {boolean} [options.podmanSave=false] - If true, save the image as a tar archive using Podman.
64
+ * @param {boolean} [options.kindLoad=false] - If true, load the image archive into a Kind cluster.
65
+ * @param {boolean} [options.kubeadmLoad=false] - If true, load the image archive into a Kubeadm cluster (uses 'ctr').
66
+ * @param {boolean} [options.k3sLoad=false] - If true, load the image archive into a K3s cluster (uses 'k3s ctr').
67
+ * @param {boolean} [options.secrets=false] - If true, load secrets from the .env file for the build.
68
+ * @param {string} [options.secretsPath=''] - Custom path to the .env file for secrets.
69
+ * @param {boolean} [options.reset=false] - If true, perform a no-cache build.
70
+ */
18
71
  build(
19
72
  options = {
20
73
  path: '',
@@ -23,13 +76,26 @@ class UnderpostImage {
23
76
  dockerfileName: '',
24
77
  podmanSave: false,
25
78
  kindLoad: false,
79
+ kubeadmLoad: false,
80
+ k3sLoad: false,
26
81
  secrets: false,
27
82
  secretsPath: '',
28
- noCache: false,
83
+ reset: false,
29
84
  },
30
85
  ) {
31
- const { path, imageName, imagePath, dockerfileName, podmanSave, secrets, secretsPath, kindLoad, noCache } =
32
- options;
86
+ const {
87
+ path,
88
+ imageName,
89
+ imagePath,
90
+ dockerfileName,
91
+ podmanSave,
92
+ secrets,
93
+ secretsPath,
94
+ kindLoad,
95
+ kubeadmLoad,
96
+ k3sLoad,
97
+ reset,
98
+ } = options;
33
99
  const podManImg = `localhost/${imageName}`;
34
100
  if (imagePath && typeof imagePath === 'string' && !fs.existsSync(imagePath))
35
101
  fs.mkdirSync(imagePath, { recursive: true });
@@ -45,11 +111,11 @@ class UnderpostImage {
45
111
  ),
46
112
  );
47
113
  for (const key of Object.keys(envObj)) {
48
- secretsInput += ` && export ${key}="${envObj[key]}" `; // $(cat gitlab-token.txt)
114
+ secretsInput += ` && export ${key}="${envObj[key]}" `; // Example: $(cat gitlab-token.txt)
49
115
  secretDockerInput += ` --secret id=${key},env=${key} \ `;
50
116
  }
51
117
  }
52
- if (noCache === true) cache += ' --rm --no-cache';
118
+ if (reset === true) cache += ' --rm --no-cache';
53
119
  if (path && typeof path === 'string')
54
120
  shellExec(
55
121
  `cd ${path}${secretsInput}&& sudo podman build -f ./${
@@ -59,6 +125,14 @@ class UnderpostImage {
59
125
 
60
126
  if (podmanSave === true) shellExec(`podman save -o ${tarFile} ${podManImg}`);
61
127
  if (kindLoad === true) shellExec(`sudo kind load image-archive ${tarFile}`);
128
+ if (kubeadmLoad === true) {
129
+ // Use 'ctr' for Kubeadm
130
+ shellExec(`sudo ctr -n k8s.io images import ${tarFile}`);
131
+ }
132
+ if (k3sLoad === true) {
133
+ // Use 'k3s ctr' for K3s
134
+ shellExec(`sudo k3s ctr images import ${tarFile}`);
135
+ }
62
136
  },
63
137
  },
64
138
  };
package/src/cli/index.js CHANGED
@@ -1,10 +1,12 @@
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';
8
+ import UnderpostLxd from './lxd.js';
9
+ import UnderpostBaremetal from './baremetal.js';
8
10
 
9
11
  const underpostRootPath = getUnderpostRootPath();
10
12
  fs.existsSync(`${underpostRootPath}/.env`)
@@ -34,6 +36,7 @@ program
34
36
  .command('clone')
35
37
  .argument(`<uri>`, 'e.g. username/repository')
36
38
  .option('--bare', 'Clone only .git files')
39
+ .option('-g8', 'Use g8 repo extension')
37
40
  .description('Clone github repository')
38
41
  .action(Underpost.repo.clone);
39
42
 
@@ -42,6 +45,7 @@ program
42
45
  .argument('<path>', 'Absolute or relative directory')
43
46
  .argument(`<uri>`, 'e.g. username/repository')
44
47
  .description('Pull github repository')
48
+ .option('-g8', 'Use g8 repo extension')
45
49
  .action(Underpost.repo.pull);
46
50
 
47
51
  program
@@ -61,6 +65,7 @@ program
61
65
  .argument('<path>', 'Absolute or relative directory')
62
66
  .argument(`<uri>`, 'e.g. username/repository')
63
67
  .option('-f', 'Force push overwriting repository')
68
+ .option('-g8', 'Use g8 repo extension')
64
69
  .description('Push github repository')
65
70
  .action(Underpost.repo.push);
66
71
 
@@ -76,8 +81,9 @@ program
76
81
  .argument('operator', `Options: ${Object.keys(Underpost.env)}`)
77
82
  .argument('[key]', 'Config key')
78
83
  .argument('[value]', 'Config value')
84
+ .option('--plain', 'Print plain value')
79
85
  .description(`Manage configuration, operators`)
80
- .action((...args) => Underpost.env[args[0]](args[1], args[2]));
86
+ .action((...args) => Underpost.env[args[0]](args[1], args[2], args[3]));
81
87
 
82
88
  program
83
89
  .command('root')
@@ -89,27 +95,35 @@ program
89
95
  .argument('[pod-name]', 'Optional pod name filter')
90
96
  .option('--reset', `Delete all clusters and prune all data and caches`)
91
97
  .option('--mariadb', 'Init with mariadb statefulset')
98
+ .option('--mysql', 'Init with mysql statefulset')
92
99
  .option('--mongodb', 'Init with mongodb statefulset')
93
100
  .option('--postgresql', 'Init with postgresql statefulset')
94
101
  .option('--mongodb4', 'Init with mongodb 4.4 service')
95
- .option('--istio', 'Init base istio cluster')
102
+ // .option('--istio', 'Init base istio service mesh')
96
103
  .option('--valkey', 'Init with valkey service')
97
104
  .option('--contour', 'Init with project contour base HTTPProxy and envoy')
98
105
  .option('--cert-manager', 'Init with letsencrypt-prod ClusterIssuer')
106
+ .option('--dedicated-gpu', 'Init with dedicated gpu base resources env')
99
107
  .option('--info', 'Get all kinds objects deployed')
100
108
  .option('--full', 'Init with all statefulsets and services available')
101
109
  .option('--ns-use <ns-name>', 'Switches current context to namespace')
110
+ .option('--kubeadm', 'Init with kubeadm controlplane management')
102
111
  .option('--dev', 'init with dev cluster')
103
112
  .option('--list-pods', 'Display list pods information')
104
113
  .option('--info-capacity', 'display current total machine capacity info')
105
114
  .option('--info-capacity-pod', 'display current machine capacity pod info')
106
115
  .option('--pull-image', 'Set optional pull associated image')
116
+ .option('--init-host', 'Install k8s node necessary cli env: kind, kubeadm, docker, podman, helm')
117
+ .option('--config', 'Set k8s base node config')
118
+ .option('--worker', 'Set worker node context')
119
+ .option('--chown', 'Set k8s kube chown')
120
+ .option('--k3s', 'Initialize the cluster using K3s')
107
121
  .action(Underpost.cluster.init)
108
122
  .description('Manage cluster, for default initialization base kind cluster');
109
123
 
110
124
  program
111
125
  .command('deploy')
112
- .argument('<deploy-list>', 'Deploy id list, e.g. default-a,default-b')
126
+ .argument('[deploy-list]', 'Deploy id list, e.g. default-a,default-b')
113
127
  .argument('[env]', 'Optional environment, for default is development')
114
128
  .option('--remove', 'Delete deployments and services')
115
129
  .option('--sync', 'Sync deployments env, ports, and replicas')
@@ -124,6 +138,8 @@ program
124
138
  .option('--traffic <traffic-versions>', 'Comma separated custom deployment traffic')
125
139
  .option('--disable-update-deployment', 'Disable update deployments')
126
140
  .option('--info-traffic', 'get traffic conf form current resources deployments')
141
+ .option('--kubeadm', 'Enable kubeadm context')
142
+ .option('--restore-hosts', 'Restore defautl etc hosts')
127
143
  .option(
128
144
  '--rebuild-clients-bundle',
129
145
  'Inside container, rebuild clients bundle, only static public or storage client files',
@@ -154,14 +170,21 @@ program
154
170
  .option('--dockerfile-name [dockerfile-name]', 'set Dockerfile name')
155
171
  .option('--podman-save', 'Export tar file from podman')
156
172
  .option('--kind-load', 'Import tar image to Kind cluster')
173
+ .option('--kubeadm-load', 'Import tar image to Kubeadm cluster')
157
174
  .option('--secrets', 'Dockerfile env secrets')
158
175
  .option('--secrets-path [secrets-path]', 'Dockerfile custom path env secrets')
159
- .option('--no-cache', 'Build without using cache')
176
+ .option('--reset', 'Build without using cache')
177
+ .option('--k3s-load', 'Load image into K3s cluster.')
160
178
  .description('Build image from Dockerfile')
161
179
  .action(Underpost.image.dockerfile.build);
162
180
 
163
181
  program
164
182
  .command('dockerfile-pull-base-images')
183
+ .option('--path [path]', 'Dockerfile path')
184
+ .option('--kind-load', 'Import tar image to Kind cluster')
185
+ .option('--kubeadm-load', 'Import tar image to Kubeadm cluster')
186
+ .option('--version', 'Set custom version')
187
+ .option('--k3s-load', 'Load image into K3s cluster.')
165
188
  .description('Pull underpost dockerfile images requirements')
166
189
  .action(Underpost.image.dockerfile.pullBaseImages);
167
190
 
@@ -252,61 +275,45 @@ program
252
275
  .description('Monitor health server management')
253
276
  .action(Underpost.monitor.callback);
254
277
 
255
- const buildCliDoc = () => {
256
- let md = shellExec(`node bin help`, { silent: true, stdout: true }).split('Options:');
257
- const baseOptions =
258
- `## ${md[0].split(`\n`)[2]}
259
-
260
- ### Usage: ` +
261
- '`' +
262
- md[0].split(`\n`)[0].split('Usage: ')[1] +
263
- '`' +
264
- `
265
- ` +
266
- '```\n Options:' +
267
- md[1] +
268
- ' \n```';
269
- md =
270
- baseOptions +
271
- `
272
-
273
- ## Commands:
274
- `;
275
- program.commands.map((o) => {
276
- md +=
277
- `
278
-
279
- ` +
280
- '### `' +
281
- o._name +
282
- '` :' +
283
- `
284
- ` +
285
- '```\n ' +
286
- shellExec(`node bin help ${o._name}`, { silent: true, stdout: true }) +
287
- ' \n```' +
288
- `
289
- `;
290
- });
291
- fs.writeFileSync(`./src/client/public/nexodev/docs/references/Command Line Interface.md`, md, 'utf8');
292
- fs.writeFileSync(`./cli.md`, md, 'utf8');
293
- const readmeSplit = `pwa-microservices-template</a>`;
294
- const readme = fs.readFileSync(`./README.md`, 'utf8').split(readmeSplit);
295
- fs.writeFileSync(
296
- './README.md',
297
- readme[0] +
298
- readmeSplit +
299
- `
278
+ program
279
+ .command('lxd')
280
+ .option('--init', 'Init lxd')
281
+ .option('--reset', 'Reset lxd on current machine')
282
+ .option('--install', 'Install lxd on current machine')
283
+ .option('--dev', 'Set dev context env')
284
+ .option('--create-virtual-network', 'Create lxd virtual network bridge')
285
+ .option('--create-admin-profile', 'Create admin profile for lxd management')
286
+ .option('--control', 'set control node vm context')
287
+ .option('--worker', 'set worker node context')
288
+ .option('--create-vm <vm-id>', 'Create default virtual machines')
289
+ .option('--init-vm <vm-id>', 'Get init vm underpost script')
290
+ .option('--info-vm <vm-id>', 'Get all info vm')
291
+ .option('--test <vm-id>', 'Test health, status and network connectivity for a VM')
292
+ .option('--root-size <gb-size>', 'Set root size vm')
293
+ .option('--k3s', 'Flag to indicate K3s cluster type for VM initialization')
294
+ .option('--join-node <nodes>', 'Comma separated worker and control node e. g. k8s-worker-1,k8s-control')
295
+ .option(
296
+ '--expose <vm-name-ports>',
297
+ 'Vm name and : separated with Comma separated vm port to expose e. g. k8s-control:80,443',
298
+ )
299
+ .option(
300
+ '--delete-expose <vm-name-ports>',
301
+ 'Vm name and : separated with Comma separated vm port to remove expose e. g. k8s-control:80,443',
302
+ )
303
+ .option('--auto-expose-k8s-ports <vm-id>', 'Automatically expose common Kubernetes ports for the VM.')
304
+ .description('Lxd management')
305
+ .action(UnderpostLxd.API.callback);
300
306
 
301
- ` +
302
- baseOptions +
303
- `
304
-
305
- <a target="_top" href="https://github.com/underpostnet/pwa-microservices-template/blob/master/cli.md">See complete CLI Docs here.</a>
306
-
307
- `,
308
- 'utf8',
309
- );
310
- };
307
+ program
308
+ .command('baremetal')
309
+ .option('--control-server-install', 'Install baremetal control server')
310
+ .option('--control-server-init-db', 'Setup database baremetal control server')
311
+ .option('--control-server-init', 'Init baremetal control server')
312
+ .option('--control-server-uninstall', 'Uninstall baremetal control server')
313
+ .option('--control-server-stop', 'Stop baremetal control server')
314
+ .option('--control-server-start', 'Start baremetal control server')
315
+ .option('--dev', 'Set dev context env')
316
+ .description('Baremetal management')
317
+ .action(UnderpostBaremetal.API.callback);
311
318
 
312
- export { program, buildCliDoc };
319
+ export { program };