underpost 2.8.852 → 2.8.854

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/cli.md CHANGED
@@ -1,4 +1,4 @@
1
- ## underpost ci/cd cli v2.8.852
1
+ ## underpost ci/cd cli v2.8.854
2
2
 
3
3
  ### Usage: `underpost [options] [command]`
4
4
  ```
@@ -23,6 +23,7 @@ Commands:
23
23
  dockerfile-pull-base-images [options] Pulls required Underpost Dockerfile base images and optionally loads them into clusters.
24
24
  install Quickly imports Underpost npm dependencies by copying them.
25
25
  db [options] <deploy-list> Manages database operations, including import, export, and collection management.
26
+ metadata [options] [deploy-id] [host] [path] Manages cluster metadata operations, including import and export.
26
27
  script [options] <operator> <script-name> [script-value] Supports a variety of built-in Underpost global scripts, their preset lifecycle events, and arbitrary custom scripts.
27
28
  cron [options] [deploy-list] [job-list] Manages cron jobs, including initialization, execution, and configuration updates.
28
29
  fs [options] [path] Manages file storage, defaulting to file upload operations.
@@ -235,6 +236,9 @@ Options:
235
236
  specified namespace.
236
237
  --kubeadm Initializes the cluster using kubeadm for control
237
238
  plane management.
239
+ --grafana Initializes the cluster with a Grafana deployment.
240
+ --prom [hosts] Initializes the cluster with a Prometheus Operator
241
+ deployment and monitor scrap for specified hosts.
238
242
  --dev Initializes a development-specific cluster
239
243
  configuration.
240
244
  --list-pods Displays detailed information about all pods.
@@ -288,8 +292,6 @@ Options:
288
292
  --build-manifest Builds Kubernetes YAML manifests, including
289
293
  deployments, services, proxies, and
290
294
  secrets.
291
- --dashboard-update Updates dashboard instance data with the
292
- current router configuration.
293
295
  --replicas <replicas> Sets a custom number of replicas for
294
296
  deployments.
295
297
  --versions <deployment-versions> A comma-separated list of custom deployment
@@ -302,9 +304,6 @@ Options:
302
304
  --kubeadm Enables the kubeadm context for deployment
303
305
  operations.
304
306
  --restore-hosts Restores default `/etc/hosts` entries.
305
- --rebuild-clients-bundle Inside the container, rebuilds client
306
- bundles (only static public or storage
307
- client files).
308
307
  -h, --help display help for command
309
308
 
310
309
  ```
@@ -427,6 +426,27 @@ Options:
427
426
  ```
428
427
 
429
428
 
429
+ ### `metadata` :
430
+ ```
431
+ Usage: underpost metadata [options] [deploy-id] [host] [path]
432
+
433
+ Manages cluster metadata operations, including import and export.
434
+
435
+ Arguments:
436
+ deploy-id The deployment ID to manage metadata.
437
+ host The host to manage metadata.
438
+ path The path to manage metadata.
439
+
440
+ Options:
441
+ --import Imports from local storage.
442
+ --export Exports to local storage.
443
+ --crons Apply to cron data collection
444
+ --instances Apply to instance data collection
445
+ -h, --help display help for command
446
+
447
+ ```
448
+
449
+
430
450
  ### `script` :
431
451
  ```
432
452
  Usage: underpost script [options] <operator> <script-name> [script-value]
@@ -461,19 +481,16 @@ Manages cron jobs, including initialization, execution, and configuration
461
481
  updates.
462
482
 
463
483
  Arguments:
464
- deploy-list A comma-separated list of deployment IDs (e.g.,
465
- "default-a,default-b").
466
- job-list A comma-separated list of job IDs. Options: callback,
467
- updateDashboardData. Defaults to all available jobs.
484
+ deploy-list A comma-separated list of deployment IDs (e.g.,
485
+ "default-a,default-b").
486
+ job-list A comma-separated list of job IDs. Options: callback. Defaults
487
+ to all available jobs.
468
488
 
469
489
  Options:
470
- --itc Executes cron jobs within the container execution
471
- context.
472
- --init Initializes cron jobs for the default deployment ID.
473
- --git Uploads cron job configurations to GitHub.
474
- --dashboard-update Updates dashboard cron data with the current job
475
- configurations.
476
- -h, --help display help for command
490
+ --itc Executes cron jobs within the container execution context.
491
+ --init Initializes cron jobs for the default deployment ID.
492
+ --git Uploads cron job configurations to GitHub.
493
+ -h, --help display help for command
477
494
 
478
495
  ```
479
496
 
@@ -574,7 +591,7 @@ Options:
574
591
  Runs a script from the specified path.
575
592
 
576
593
  Arguments:
577
- runner-id The runner ID to run. Options: spark-template, rmi, kill, secret, gpu-env, tf-gpu-test, dev-cluster, cyberia-ide, engine-ide, template-deploy, ssh-deploy, ide, monitor, db-client, cluster, deploy, tf-vae-test, deploy-job.
594
+ runner-id The runner ID to run. Options: spark-template, rmi, kill, secret, gpu-env, tf-gpu-test, dev-cluster, ssh-cluster-info, cyberia-ide, engine-ide, template-deploy, clean, upgrade, ssh-deploy, ide, monitor, db-client, cluster, deploy, tf-vae-test, deploy-job.
578
595
  path The absolute or relative directory path where the script is located.
579
596
 
580
597
  Options:
@@ -2,22 +2,22 @@
2
2
  apiVersion: apps/v1
3
3
  kind: Deployment
4
4
  metadata:
5
- name: dd-template-development-blue
5
+ name: dd-default-development-blue
6
6
  labels:
7
- app: dd-template-development-blue
7
+ app: dd-default-development-blue
8
8
  spec:
9
9
  replicas: 1
10
10
  selector:
11
11
  matchLabels:
12
- app: dd-template-development-blue
12
+ app: dd-default-development-blue
13
13
  template:
14
14
  metadata:
15
15
  labels:
16
- app: dd-template-development-blue
16
+ app: dd-default-development-blue
17
17
  spec:
18
18
  containers:
19
- - name: dd-template-development-blue
20
- image: localhost/rockylinux9-underpost:v2.8.852
19
+ - name: dd-default-development-blue
20
+ image: localhost/rockylinux9-underpost:v2.8.854
21
21
  # resources:
22
22
  # requests:
23
23
  # memory: "124Ki"
@@ -40,10 +40,10 @@ spec:
40
40
  apiVersion: v1
41
41
  kind: Service
42
42
  metadata:
43
- name: dd-template-development-blue-service
43
+ name: dd-default-development-blue-service
44
44
  spec:
45
45
  selector:
46
- app: dd-template-development-blue
46
+ app: dd-default-development-blue
47
47
  ports:
48
48
  - name: 'tcp-4001'
49
49
  protocol: TCP
@@ -85,22 +85,22 @@ spec:
85
85
  apiVersion: apps/v1
86
86
  kind: Deployment
87
87
  metadata:
88
- name: dd-template-development-green
88
+ name: dd-default-development-green
89
89
  labels:
90
- app: dd-template-development-green
90
+ app: dd-default-development-green
91
91
  spec:
92
92
  replicas: 1
93
93
  selector:
94
94
  matchLabels:
95
- app: dd-template-development-green
95
+ app: dd-default-development-green
96
96
  template:
97
97
  metadata:
98
98
  labels:
99
- app: dd-template-development-green
99
+ app: dd-default-development-green
100
100
  spec:
101
101
  containers:
102
- - name: dd-template-development-green
103
- image: localhost/rockylinux9-underpost:v2.8.852
102
+ - name: dd-default-development-green
103
+ image: localhost/rockylinux9-underpost:v2.8.854
104
104
  # resources:
105
105
  # requests:
106
106
  # memory: "124Ki"
@@ -124,10 +124,10 @@ spec:
124
124
  apiVersion: v1
125
125
  kind: Service
126
126
  metadata:
127
- name: dd-template-development-green-service
127
+ name: dd-default-development-green-service
128
128
  spec:
129
129
  selector:
130
- app: dd-template-development-green
130
+ app: dd-default-development-green
131
131
  ports:
132
132
  - name: 'tcp-4001'
133
133
  protocol: TCP
@@ -16,7 +16,7 @@ spec:
16
16
  - prefix: /
17
17
  enableWebsockets: true
18
18
  services:
19
- - name: dd-template-development-blue-service
19
+ - name: dd-default-development-blue-service
20
20
  port: 4001
21
21
  weight: 100
22
22
 
@@ -24,7 +24,7 @@ spec:
24
24
  - prefix: /peer
25
25
  enableWebsockets: true
26
26
  services:
27
- - name: dd-template-development-blue-service
27
+ - name: dd-default-development-blue-service
28
28
  port: 4002
29
29
  weight: 100
30
30
 
@@ -41,6 +41,6 @@ spec:
41
41
  - prefix: /
42
42
  enableWebsockets: true
43
43
  services:
44
- - name: dd-template-development-blue-service
44
+ - name: dd-default-development-blue-service
45
45
  port: 4003
46
46
  weight: 100
@@ -0,0 +1,57 @@
1
+ ---
2
+ apiVersion: apps/v1
3
+ kind: Deployment
4
+ metadata:
5
+ labels:
6
+ app: grafana
7
+ name: grafana
8
+ spec:
9
+ selector:
10
+ matchLabels:
11
+ app: grafana
12
+ template:
13
+ metadata:
14
+ labels:
15
+ app: grafana
16
+ spec:
17
+ securityContext:
18
+ fsGroup: 472
19
+ supplementalGroups:
20
+ - 0
21
+ containers:
22
+ - name: grafana
23
+ image: grafana/grafana:latest
24
+ imagePullPolicy: IfNotPresent
25
+ ports:
26
+ - containerPort: 3000
27
+ name: http-grafana
28
+ protocol: TCP
29
+ readinessProbe:
30
+ failureThreshold: 3
31
+ httpGet:
32
+ path: /robots.txt
33
+ port: 3000
34
+ scheme: HTTP
35
+ initialDelaySeconds: 10
36
+ periodSeconds: 30
37
+ successThreshold: 1
38
+ timeoutSeconds: 2
39
+ livenessProbe:
40
+ failureThreshold: 3
41
+ initialDelaySeconds: 30
42
+ periodSeconds: 10
43
+ successThreshold: 1
44
+ tcpSocket:
45
+ port: 3000
46
+ timeoutSeconds: 1
47
+ resources:
48
+ requests:
49
+ cpu: 250m
50
+ memory: 750Mi
51
+ volumeMounts:
52
+ - mountPath: /var/lib/grafana
53
+ name: grafana-pv
54
+ volumes:
55
+ - name: grafana-pv
56
+ persistentVolumeClaim:
57
+ claimName: grafana-pvc
@@ -0,0 +1,7 @@
1
+ ---
2
+ apiVersion: kustomize.config.k8s.io/v1beta1
3
+ kind: Kustomization
4
+ resources:
5
+ - pvc.yaml
6
+ - deployment.yaml
7
+ - service.yaml
@@ -0,0 +1,12 @@
1
+ ---
2
+ apiVersion: v1
3
+ kind: PersistentVolumeClaim
4
+ metadata:
5
+ name: grafana-pvc
6
+ spec:
7
+ accessModes:
8
+ - ReadWriteOnce
9
+ storageClassName: local-path
10
+ resources:
11
+ requests:
12
+ storage: 5Gi
@@ -0,0 +1,14 @@
1
+ ---
2
+ apiVersion: v1
3
+ kind: Service
4
+ metadata:
5
+ name: grafana
6
+ spec:
7
+ ports:
8
+ - port: 3000
9
+ protocol: TCP
10
+ targetPort: http-grafana
11
+ selector:
12
+ app: grafana
13
+ sessionAffinity: None
14
+ type: LoadBalancer
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+
4
+ REMOTE_USER=$(node bin config get --plain DEFAULT_SSH_USER)
5
+ REMOTE_HOST=$(node bin config get --plain DEFAULT_SSH_HOST)
6
+ SSH_KEY=$(node bin config get --plain DEFAULT_SSH_KEY_PATH)
7
+
8
+ chmod 600 "$SSH_KEY"
9
+
10
+ ssh -i "$SSH_KEY" -o BatchMode=yes "${REMOTE_USER}@${REMOTE_HOST}" sh <<EOF
11
+ cd /home/dd/engine
12
+ node bin deploy dd production --info-traffic
13
+ kubectl get pods -A
14
+ EOF
@@ -0,0 +1,82 @@
1
+ ---
2
+ apiVersion: v1
3
+ kind: ConfigMap
4
+ metadata:
5
+ name: prometheus-config
6
+ labels:
7
+ app: prometheus
8
+ data:
9
+ prometheus.yml: |
10
+ global:
11
+ scrape_interval: 30s
12
+ evaluation_interval: 30s
13
+
14
+ scrape_configs:
15
+ - job_name: 'scraper'
16
+ metrics_path: /metrics
17
+ scheme: https
18
+ static_configs:
19
+ - targets: []
20
+ # tls_config:
21
+ # insecure_skip_verify: true
22
+
23
+ ---
24
+ apiVersion: apps/v1
25
+ kind: Deployment
26
+ metadata:
27
+ name: prometheus
28
+ labels:
29
+ app: prometheus
30
+ spec:
31
+ replicas: 1
32
+ selector:
33
+ matchLabels:
34
+ app: prometheus
35
+ template:
36
+ metadata:
37
+ labels:
38
+ app: prometheus
39
+ spec:
40
+ containers:
41
+ - name: prometheus
42
+ image: prom/prometheus:latest
43
+ args:
44
+ - '--config.file=/etc/prometheus/prometheus.yml'
45
+ - '--storage.tsdb.path=/prometheus'
46
+ - '--web.console.libraries=/usr/share/prometheus/console_libraries'
47
+ - '--web.console.templates=/usr/share/prometheus/consoles'
48
+ ports:
49
+ - containerPort: 9090
50
+ name: web
51
+ volumeMounts:
52
+ - name: prometheus-config
53
+ mountPath: /etc/prometheus/
54
+ - name: prometheus-data
55
+ mountPath: /prometheus
56
+ resources:
57
+ requests:
58
+ memory: '200Mi'
59
+ cpu: '100m'
60
+ volumes:
61
+ - name: prometheus-config
62
+ configMap:
63
+ name: prometheus-config
64
+ - name: prometheus-data
65
+ emptyDir: {}
66
+
67
+ ---
68
+ apiVersion: v1
69
+ kind: Service
70
+ metadata:
71
+ name: prometheus
72
+ labels:
73
+ app: prometheus
74
+ spec:
75
+ ports:
76
+ - port: 9090
77
+ targetPort: 9090
78
+ protocol: TCP
79
+ name: web
80
+ selector:
81
+ app: prometheus
82
+ type: ClusterIP
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.852",
5
+ "version": "2.8.854",
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",
@@ -21,7 +21,6 @@
21
21
  "install-test": "npm install -g mocha && npm install -g c8 && npm install -g nyc && npm install -g coveralls",
22
22
  "install-underpost": "cp -a $(npm root -g)/underpost/node_modules ./node_modules && npm install --only=dev --ignore-scripts",
23
23
  "install": "npm run install-global && npm run install-test",
24
- "docker:start": "docker-compose up",
25
24
  "prettier": "prettier --write .",
26
25
  "fix": "npm audit fix --force && npm audit",
27
26
  "changelog": "auto-changelog"
@@ -5,6 +5,7 @@ import UnderpostBaremetal from './baremetal.js';
5
5
  import UnderpostDeploy from './deploy.js';
6
6
  import UnderpostTest from './test.js';
7
7
  import os from 'os';
8
+ import fs from 'fs-extra';
8
9
 
9
10
  const logger = loggerFactory(import.meta);
10
11
 
@@ -33,12 +34,13 @@ class UnderpostCluster {
33
34
  * @param {string} [options.nsUse=''] - Set the current kubectl namespace.
34
35
  * @param {boolean} [options.infoCapacity=false] - Display resource capacity information for the cluster.
35
36
  * @param {boolean} [options.infoCapacityPod=false] - Display resource capacity information for pods.
36
- * @param {boolean} [options.istio=false] - Deploy Istio service mesh.
37
37
  * @param {boolean} [options.pullImage=false] - Pull necessary Docker images before deployment.
38
38
  * @param {boolean} [options.dedicatedGpu=false] - Configure for dedicated GPU usage (e.g., NVIDIA GPU Operator).
39
39
  * @param {boolean} [options.kubeadm=false] - Initialize the cluster using Kubeadm.
40
40
  * @param {boolean} [options.k3s=false] - Initialize the cluster using K3s.
41
41
  * @param {boolean} [options.initHost=false] - Perform initial host setup (install Docker, Podman, Kind, Kubeadm, Helm).
42
+ * @param {boolean} [options.grafana=false] - Initialize the cluster with a Grafana deployment.
43
+ * @param {string} [options.prom=''] - Initialize the cluster with a Prometheus Operator deployment and monitor scrap for specified hosts.
42
44
  * @param {boolean} [options.uninstallHost=false] - Uninstall all host components.
43
45
  * @param {boolean} [options.config=false] - Apply general host configuration (SELinux, containerd, sysctl, firewalld).
44
46
  * @param {boolean} [options.worker=false] - Configure as a worker node (for Kubeadm or K3s join).
@@ -63,12 +65,13 @@ class UnderpostCluster {
63
65
  nsUse: '',
64
66
  infoCapacity: false,
65
67
  infoCapacityPod: false,
66
- istio: false,
67
68
  pullImage: false,
68
69
  dedicatedGpu: false,
69
70
  kubeadm: false,
70
71
  k3s: false,
71
72
  initHost: false,
73
+ grafana: false,
74
+ prom: '',
72
75
  uninstallHost: false,
73
76
  config: false,
74
77
  worker: false,
@@ -260,6 +263,42 @@ class UnderpostCluster {
260
263
  );
261
264
  }
262
265
 
266
+ if (options.grafana === true) {
267
+ shellExec(`kubectl delete deployment grafana --ignore-not-found`);
268
+ shellExec(`kubectl apply -k ${underpostRoot}/manifests/grafana`);
269
+ }
270
+
271
+ if (options.prom && typeof options.prom === 'string') {
272
+ shellExec(`kubectl delete deployment prometheus --ignore-not-found`);
273
+ shellExec(`kubectl delete configmap prometheus-config --ignore-not-found`);
274
+ shellExec(`kubectl delete service prometheus --ignore-not-found`);
275
+ // Prometheus server host: http://<prometheus-cluster-ip>:9090
276
+ const yaml = `${fs.readFileSync(`${underpostRoot}/manifests/prometheus/deployment.yaml`, 'utf8').replace(
277
+ '- targets: []',
278
+ `- targets: [${options.prom
279
+ .split(',')
280
+ .map((host) => `'${host}'`)
281
+ .join(',')}]`,
282
+ )}`;
283
+ console.log(yaml);
284
+ shellExec(`kubectl apply -f - <<EOF
285
+ ${yaml}
286
+ EOF
287
+ `);
288
+
289
+ // https://grafana.com/docs/grafana-cloud/monitor-infrastructure/kubernetes-monitoring/configuration/config-other-methods/prometheus/prometheus-operator/
290
+ // shellExec(
291
+ // `kubectl create -f https://raw.githubusercontent.com/prometheus-operator/prometheus-operator/master/bundle.yaml`,
292
+ // );
293
+ // shellExec(`kubectl apply -f ${underpostRoot}/manifests/prometheus/prometheus-cr.yaml`);
294
+ // shellExec(`kubectl rollout status sts prometheus-prometheus -n default`);
295
+ // shellExec(`kubectl apply -f ${underpostRoot}/manifests/prometheus/prometheus-server.yaml`);
296
+ // shellExec(`helm repo add prometheus-community https://prometheus-community.github.io/helm-charts`);
297
+ // shellExec(`helm repo update`);
298
+ // shellExec(`helm install prometheus prometheus-community/prometheus`);
299
+ // shellExec(`kubectl rollout status deployment prometheus-server -n default`);
300
+ }
301
+
263
302
  if (options.full === true || options.valkey === true) {
264
303
  if (options.pullImage === true) {
265
304
  // shellExec(`sudo podman pull valkey/valkey:latest`);
package/src/cli/cron.js CHANGED
@@ -50,7 +50,7 @@ class UnderpostCron {
50
50
  callback: async function (
51
51
  deployList = 'default',
52
52
  jobList = Object.keys(UnderpostCron.JOB),
53
- options = { itc: false, init: false, git: false, dashboardUpdate: false },
53
+ options = { itc: false, init: false, git: false },
54
54
  ) {
55
55
  if (options.init === true) {
56
56
  UnderpostCron.NETWORK = [];
@@ -61,7 +61,7 @@ class UnderpostCron {
61
61
  for (const job of Object.keys(confCronConfig.jobs)) {
62
62
  const name = `${jobDeployId}-${job}`;
63
63
  let deployId;
64
- if (!options.dashboardUpdate) shellExec(Cmd.delete(name));
64
+ shellExec(Cmd.delete(name));
65
65
  switch (job) {
66
66
  case 'dns':
67
67
  deployId = jobDeployId;
@@ -71,8 +71,7 @@ class UnderpostCron {
71
71
  deployId = deployList;
72
72
  break;
73
73
  }
74
- if (!options.dashboardUpdate)
75
- shellExec(Cmd.cron(deployId, job, name, confCronConfig.jobs[job].expression, options));
74
+ shellExec(Cmd.cron(deployId, job, name, confCronConfig.jobs[job].expression, options));
76
75
  UnderpostCron.NETWORK.push({
77
76
  deployId,
78
77
  jobId: job,
@@ -80,7 +79,6 @@ class UnderpostCron {
80
79
  });
81
80
  }
82
81
  }
83
- if (options.dashboardUpdate === true) await UnderpostCron.API.updateDashboardData();
84
82
  if (fs.existsSync(`./tmp/await-deploy`)) fs.remove(`./tmp/await-deploy`);
85
83
  return;
86
84
  }
@@ -89,32 +87,6 @@ class UnderpostCron {
89
87
  if (UnderpostCron.JOB[jobId]) await UnderpostCron.JOB[jobId].callback(deployList, options);
90
88
  }
91
89
  },
92
- async updateDashboardData() {
93
- try {
94
- const deployId = process.env.DEFAULT_DEPLOY_ID;
95
- const host = process.env.DEFAULT_DEPLOY_HOST;
96
- const path = process.env.DEFAULT_DEPLOY_PATH;
97
- const confServerPath = `./engine-private/conf/${deployId}/conf.server.json`;
98
- const confServer = JSON.parse(fs.readFileSync(confServerPath, 'utf8'));
99
- const { db } = confServer[host][path];
100
-
101
- await DataBaseProvider.load({ apis: ['cron'], host, path, db });
102
-
103
- /** @type {import('../api/cron/cron.model.js').CronModel} */
104
- const Cron = DataBaseProvider.instance[`${host}${path}`].mongoose.models.Cron;
105
-
106
- await Cron.deleteMany();
107
-
108
- for (const cronInstance of UnderpostCron.NETWORK) {
109
- logger.info('save', cronInstance);
110
- await new Cron(cronInstance).save();
111
- }
112
-
113
- await DataBaseProvider.instance[`${host}${path}`].mongoose.close();
114
- } catch (error) {
115
- logger.error(error, error.stack);
116
- }
117
- },
118
90
  };
119
91
  }
120
92