underpost 2.8.75 → 2.8.78

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.75
71
+ ## underpost ci/cd cli v2.8.78
72
72
 
73
73
  ### Usage: `underpost [options] [command]`
74
74
  ```
@@ -80,17 +80,17 @@ Commands:
80
80
  new <app-name> Create a new project
81
81
  start [options] <deploy-id> [env] Start up server, build pipelines, or services
82
82
  clone [options] <uri> Clone github repository
83
- pull <path> <uri> Pull github repository
83
+ pull [options] <path> <uri> Pull github repository
84
84
  cmt [options] <path> <commit-type> [module-tag] [message] Commit github repository
85
85
  push [options] <path> <uri> Push github repository
86
86
  env <deploy-id> [env] Set environment variables files and conf related to <deploy-id>
87
87
  config <operator> [key] [value] Manage configuration, operators
88
88
  root Get npm root path
89
89
  cluster [options] [pod-name] Manage cluster, for default initialization base kind cluster
90
- deploy [options] <deploy-list> [env] Manage deployment, for default deploy development pods
90
+ deploy [options] [deploy-list] [env] Manage deployment, for default deploy development pods
91
91
  secret [options] <platform> Manage secrets
92
92
  dockerfile-image-build [options] Build image from Dockerfile
93
- dockerfile-pull-base-images Pull underpost dockerfile images requirements
93
+ dockerfile-pull-base-images [options] Pull underpost dockerfile images requirements
94
94
  install Fast import underpost npm dependencies
95
95
  db [options] <deploy-list> Manage databases
96
96
  script [options] <operator> <script-name> [script-value] Supports a number of built-in underpost global scripts and their preset life cycle events as well as arbitrary scripts
@@ -98,6 +98,7 @@ Commands:
98
98
  fs [options] [path] File storage management, for default upload file
99
99
  test [options] [deploy-list] Manage Test, for default run current underpost default test
100
100
  monitor [options] <deploy-id> [env] Monitor health server management
101
+ lxd [options] Lxd management
101
102
  help [command] display help for command
102
103
 
103
104
  ```
package/bin/deploy.js CHANGED
@@ -2367,7 +2367,7 @@ nvidia/gpu-operator \
2367
2367
  --create-namespace \
2368
2368
  --wait`);
2369
2369
 
2370
- const image = `spark:3.5.3`;
2370
+ const image = `spark:3.5.5`;
2371
2371
  shellExec(`sudo docker pull ${image}`);
2372
2372
  if (!process.argv.includes('kubeadm'))
2373
2373
  shellExec(
package/cli.md CHANGED
@@ -1,4 +1,4 @@
1
- ## underpost ci/cd cli v2.8.75
1
+ ## underpost ci/cd cli v2.8.78
2
2
 
3
3
  ### Usage: `underpost [options] [command]`
4
4
  ```
@@ -10,17 +10,17 @@ Commands:
10
10
  new <app-name> Create a new project
11
11
  start [options] <deploy-id> [env] Start up server, build pipelines, or services
12
12
  clone [options] <uri> Clone github repository
13
- pull <path> <uri> Pull github repository
13
+ pull [options] <path> <uri> Pull github repository
14
14
  cmt [options] <path> <commit-type> [module-tag] [message] Commit github repository
15
15
  push [options] <path> <uri> Push github repository
16
16
  env <deploy-id> [env] Set environment variables files and conf related to <deploy-id>
17
17
  config <operator> [key] [value] Manage configuration, operators
18
18
  root Get npm root path
19
19
  cluster [options] [pod-name] Manage cluster, for default initialization base kind cluster
20
- deploy [options] <deploy-list> [env] Manage deployment, for default deploy development pods
20
+ deploy [options] [deploy-list] [env] Manage deployment, for default deploy development pods
21
21
  secret [options] <platform> Manage secrets
22
22
  dockerfile-image-build [options] Build image from Dockerfile
23
- dockerfile-pull-base-images Pull underpost dockerfile images requirements
23
+ dockerfile-pull-base-images [options] Pull underpost dockerfile images requirements
24
24
  install Fast import underpost npm dependencies
25
25
  db [options] <deploy-list> Manage databases
26
26
  script [options] <operator> <script-name> [script-value] Supports a number of built-in underpost global scripts and their preset life cycle events as well as arbitrary scripts
@@ -28,6 +28,7 @@ Commands:
28
28
  fs [options] [path] File storage management, for default upload file
29
29
  test [options] [deploy-list] Manage Test, for default run current underpost default test
30
30
  monitor [options] <deploy-id> [env] Monitor health server management
31
+ lxd [options] Lxd management
31
32
  help [command] display help for command
32
33
 
33
34
  ```
@@ -79,6 +80,7 @@ Arguments:
79
80
 
80
81
  Options:
81
82
  --bare Clone only .git files
83
+ -g8 Use g8 repo extension
82
84
  -h, --help display help for command
83
85
 
84
86
  ```
@@ -95,6 +97,7 @@ Arguments:
95
97
  uri e.g. username/repository
96
98
 
97
99
  Options:
100
+ -g8 Use g8 repo extension
98
101
  -h, --help display help for command
99
102
 
100
103
  ```
@@ -134,6 +137,7 @@ Arguments:
134
137
 
135
138
  Options:
136
139
  -f Force push overwriting repository
140
+ -g8 Use g8 repo extension
137
141
  -h, --help display help for command
138
142
 
139
143
  ```
@@ -196,6 +200,7 @@ Arguments:
196
200
  Options:
197
201
  --reset Delete all clusters and prune all data and caches
198
202
  --mariadb Init with mariadb statefulset
203
+ --mysql Init with mysql statefulset
199
204
  --mongodb Init with mongodb statefulset
200
205
  --postgresql Init with postgresql statefulset
201
206
  --mongodb4 Init with mongodb 4.4 service
@@ -220,7 +225,7 @@ Options:
220
225
 
221
226
  ### `deploy` :
222
227
  ```
223
- Usage: underpost deploy [options] <deploy-list> [env]
228
+ Usage: underpost deploy [options] [deploy-list] [env]
224
229
 
225
230
  Manage deployment, for default deploy development pods
226
231
 
@@ -246,6 +251,8 @@ Options:
246
251
  --disable-update-deployment Disable update deployments
247
252
  --info-traffic get traffic conf form current resources
248
253
  deployments
254
+ --kubeadm Enable kubeadm context
255
+ --restore-hosts Restore defautl etc hosts
249
256
  --rebuild-clients-bundle Inside container, rebuild clients bundle,
250
257
  only static public or storage client files
251
258
  -h, --help display help for command
@@ -300,7 +307,11 @@ Options:
300
307
  Pull underpost dockerfile images requirements
301
308
 
302
309
  Options:
303
- -h, --help display help for command
310
+ --path [path] Dockerfile path
311
+ --kind-load Import tar image to Kind cluster
312
+ --kubeadm-load Import tar image to Kubeadm cluster
313
+ --version Set custom version
314
+ -h, --help display help for command
304
315
 
305
316
  ```
306
317
 
@@ -451,4 +462,19 @@ Options:
451
462
  -h, --help display help for command
452
463
 
453
464
  ```
465
+
466
+
467
+ ### `lxd` :
468
+ ```
469
+ Usage: underpost lxd [options]
470
+
471
+ Lxd management
472
+
473
+ Options:
474
+ --init Init lxd
475
+ --reset Reset lxd on current machine
476
+ --install Install lxd on current machine
477
+ -h, --help display help for command
478
+
479
+ ```
454
480
 
@@ -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.75'
61
+ engine.version: '2.8.78'
62
62
  networks:
63
63
  - load-balancer
64
64
 
@@ -7,10 +7,10 @@ spec:
7
7
  type: Python
8
8
  pythonVersion: '3'
9
9
  mode: cluster
10
- image: spark:3.5.3
10
+ image: spark:3.5.5
11
11
  imagePullPolicy: IfNotPresent
12
12
  mainApplicationFile: local:///opt/spark/examples/src/main/python/pi.py
13
- sparkVersion: 3.5.3
13
+ sparkVersion: 3.5.5
14
14
  driver:
15
15
  cores: 1
16
16
  memory: 512m
@@ -0,0 +1,23 @@
1
+ apiVersion: v1
2
+ kind: Service
3
+ metadata:
4
+ labels:
5
+ app: envoy
6
+ name: envoy
7
+ namespace: projectcontour
8
+ spec:
9
+ externalTrafficPolicy: Cluster
10
+ ports:
11
+ - name: http
12
+ nodePort: 30080
13
+ port: 80
14
+ protocol: TCP
15
+ targetPort: 8080
16
+ - name: https
17
+ nodePort: 30443
18
+ port: 443
19
+ protocol: TCP
20
+ targetPort: 8443
21
+ selector:
22
+ app: envoy
23
+ type: NodePort
@@ -6,6 +6,6 @@ resources:
6
6
  - pv-pvc.yaml
7
7
  - headless-service.yaml
8
8
  - statefulset.yaml
9
- - backup-pv-pvc.yaml
9
+ # - backup-pv-pvc.yaml
10
10
  # - backup-cronjob.yaml
11
11
  # - backup-access.yaml
@@ -3,7 +3,7 @@ kind: StatefulSet
3
3
  metadata:
4
4
  name: mongodb # Specifies the name of the statefulset
5
5
  spec:
6
- serviceName: 'mongodb-service' # Specifies the service to use
6
+ serviceName: "mongodb-service" # Specifies the service to use
7
7
  replicas: 2
8
8
  selector:
9
9
  matchLabels:
@@ -18,8 +18,8 @@ spec:
18
18
  image: docker.io/library/mongo:latest
19
19
  command:
20
20
  - mongod
21
- - '--replSet'
22
- - 'rs0'
21
+ - "--replSet"
22
+ - "rs0"
23
23
  # - '--config'
24
24
  # - '-f'
25
25
  # - '/etc/mongod.conf'
@@ -35,9 +35,9 @@ spec:
35
35
  # - '--setParameter'
36
36
  # - 'authenticationMechanisms=SCRAM-SHA-1'
37
37
  # - '--fork'
38
- - '--logpath'
39
- - '/var/log/mongodb/mongod.log'
40
- - '--bind_ip_all'
38
+ - "--logpath"
39
+ - "/var/log/mongodb/mongod.log"
40
+ - "--bind_ip_all"
41
41
  # command: ['sh', '-c']
42
42
  # args:
43
43
  # - |
@@ -99,11 +99,11 @@ spec:
99
99
  key: password
100
100
  resources:
101
101
  requests:
102
- cpu: '100m'
103
- memory: '256Mi'
102
+ cpu: "100m"
103
+ memory: "256Mi"
104
104
  limits:
105
- cpu: '500m'
106
- memory: '512Mi'
105
+ cpu: "500m"
106
+ memory: "512Mi"
107
107
  volumes:
108
108
  - name: keyfile
109
109
  secret:
@@ -119,7 +119,8 @@ spec:
119
119
  - metadata:
120
120
  name: mongodb-storage
121
121
  spec:
122
- accessModes: ['ReadWriteOnce']
122
+ accessModes: ["ReadWriteOnce"]
123
+ storageClassName: mongodb-storage-class
123
124
  resources:
124
125
  requests:
125
126
  storage: 5Gi
@@ -0,0 +1,9 @@
1
+ apiVersion: storage.k8s.io/v1
2
+ kind: StorageClass
3
+ metadata:
4
+ name: mongodb-storage-class
5
+ annotations:
6
+ storageclass.kubernetes.io/is-default-class: "false"
7
+ provisioner: rancher.io/local-path
8
+ reclaimPolicy: Retain
9
+ volumeBindingMode: WaitForFirstConsumer
@@ -0,0 +1,7 @@
1
+ ---
2
+ # kubectl apply -k core/.
3
+ apiVersion: kustomize.config.k8s.io/v1beta1
4
+ kind: Kustomization
5
+ resources:
6
+ - pv-pvc.yaml
7
+ - statefulset.yaml
@@ -0,0 +1,27 @@
1
+ # pv-pvc.yaml
2
+ apiVersion: v1
3
+ kind: PersistentVolume
4
+ metadata:
5
+ name: mysql-pv
6
+ labels:
7
+ type: local
8
+ spec:
9
+ storageClassName: manual
10
+ capacity:
11
+ storage: 20Gi
12
+ accessModes:
13
+ - ReadWriteOnce
14
+ hostPath:
15
+ path: "/mnt/data"
16
+ ---
17
+ apiVersion: v1
18
+ kind: PersistentVolumeClaim
19
+ metadata:
20
+ name: mysql-pv-claim
21
+ spec:
22
+ storageClassName: manual
23
+ accessModes:
24
+ - ReadWriteOnce
25
+ resources:
26
+ requests:
27
+ storage: 20Gi
@@ -0,0 +1,55 @@
1
+ apiVersion: v1
2
+ kind: Service
3
+ metadata:
4
+ name: mysql
5
+ labels:
6
+ app: mysql
7
+ spec:
8
+ ports:
9
+ - port: 3306
10
+ name: mysql
11
+ selector:
12
+ app: mysql
13
+ clusterIP: None
14
+ ---
15
+ apiVersion: apps/v1
16
+ kind: StatefulSet
17
+ metadata:
18
+ name: mysql
19
+ spec:
20
+ serviceName: "mysql"
21
+ selector:
22
+ matchLabels:
23
+ app: mysql
24
+ replicas: 1
25
+ template:
26
+ metadata:
27
+ labels:
28
+ app: mysql
29
+ spec:
30
+ containers:
31
+ - image: mysql:9
32
+ name: mysql
33
+ env:
34
+ - name: MYSQL_ROOT_PASSWORD
35
+ valueFrom:
36
+ secretKeyRef:
37
+ name: mysql-secret
38
+ key: password
39
+ ports:
40
+ - containerPort: 3306
41
+ name: mysql
42
+ volumeMounts:
43
+ - name: mysql-persistent-storage
44
+ mountPath: /var/lib/mysql
45
+ subPath: mysql
46
+ volumeClaimTemplates:
47
+ - metadata:
48
+ name: mysql-persistent-storage
49
+ spec:
50
+ storageClassName: manual
51
+ accessModes:
52
+ - ReadWriteOnce
53
+ resources:
54
+ requests:
55
+ storage: 20Gi
@@ -19,9 +19,8 @@ spec:
19
19
 
20
20
  containers:
21
21
  - name: service-valkey
22
- image: valkey/valkey:latest
23
- # Ensure you pull only if not present (Never will error if missing)
24
- imagePullPolicy: Never
22
+ image: docker.io/valkey/valkey:latest
23
+ imagePullPolicy: IfNotPresent
25
24
  env:
26
25
  - name: TZ
27
26
  value: Europe/Zurich
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.75",
5
+ "version": "2.8.78",
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",
@@ -15,6 +15,7 @@ class UnderpostCluster {
15
15
  mongodb: false,
16
16
  mongodb4: false,
17
17
  mariadb: false,
18
+ mysql: false,
18
19
  postgresql: false,
19
20
  valkey: false,
20
21
  full: false,
@@ -83,10 +84,14 @@ class UnderpostCluster {
83
84
  shellExec(`sudo kubectl api-resources`);
84
85
  return;
85
86
  }
87
+ const alrreadyCluster =
88
+ UnderpostDeploy.API.get('kube-apiserver-kind-control-plane')[0] ||
89
+ UnderpostDeploy.API.get('calico-kube-controllers')[0];
86
90
 
87
91
  if (
88
- (!options.istio && !UnderpostDeploy.API.get('kube-apiserver-kind-control-plane')[0]) ||
89
- (options.istio === true && !UnderpostDeploy.API.get('calico-kube-controllers')[0])
92
+ !alrreadyCluster &&
93
+ ((!options.istio && !UnderpostDeploy.API.get('kube-apiserver-kind-control-plane')[0]) ||
94
+ (options.istio === true && !UnderpostDeploy.API.get('calico-kube-controllers')[0]))
90
95
  ) {
91
96
  shellExec(`sudo setenforce 0`);
92
97
  shellExec(`sudo sed -i 's/^SELINUX=enforcing$/SELINUX=permissive/' /etc/selinux/config`);
@@ -101,7 +106,9 @@ class UnderpostCluster {
101
106
  shellExec(`sudo swapoff -a; sudo sed -i '/swap/d' /etc/fstab`);
102
107
  if (options.istio === true) {
103
108
  shellExec(`sysctl net.bridge.bridge-nf-call-iptables=1`);
104
- shellExec(`sudo kubeadm init --pod-network-cidr=192.168.0.0/16`);
109
+ shellExec(
110
+ `sudo kubeadm init --pod-network-cidr=192.168.0.0/16 --control-plane-endpoint="${os.hostname()}:6443"`,
111
+ );
105
112
  shellExec(`sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config`);
106
113
  shellExec(`sudo chown $(id -u):$(id -g) $HOME/.kube/config**`);
107
114
  // https://docs.tigera.io/calico/latest/getting-started/kubernetes/quickstart
@@ -115,6 +122,9 @@ class UnderpostCluster {
115
122
  shellExec(`sudo systemctl restart containerd`);
116
123
  const nodeName = os.hostname();
117
124
  shellExec(`kubectl taint nodes ${nodeName} node-role.kubernetes.io/control-plane:NoSchedule-`);
125
+ shellExec(
126
+ `kubectl apply -f https://raw.githubusercontent.com/rancher/local-path-provisioner/master/deploy/local-path-storage.yaml`,
127
+ );
118
128
  } else {
119
129
  shellExec(`sudo systemctl restart containerd`);
120
130
  if (options.full === true || options.dedicatedGpu === true) {
@@ -142,7 +152,8 @@ class UnderpostCluster {
142
152
 
143
153
  if (options.full === true || options.valkey === true) {
144
154
  if (options.pullImage === true) {
145
- shellExec(`docker pull valkey/valkey`);
155
+ shellExec(`docker pull valkey/valkey:latest`);
156
+ shellExec(`sudo podman pull valkey/valkey:latest`);
146
157
  if (!options.kubeadm)
147
158
  shellExec(
148
159
  `sudo ${
@@ -157,12 +168,18 @@ class UnderpostCluster {
157
168
  shellExec(
158
169
  `sudo kubectl create secret generic mariadb-secret --from-file=username=/home/dd/engine/engine-private/mariadb-username --from-file=password=/home/dd/engine/engine-private/mariadb-password`,
159
170
  );
160
- shellExec(
161
- `sudo kubectl create secret generic github-secret --from-literal=GITHUB_TOKEN=${process.env.GITHUB_TOKEN}`,
162
- );
163
171
  shellExec(`kubectl delete statefulset mariadb-statefulset`);
164
172
  shellExec(`kubectl apply -k ${underpostRoot}/manifests/mariadb`);
165
173
  }
174
+ if (options.full === true || options.mysql === true) {
175
+ shellExec(
176
+ `sudo kubectl create secret generic mysql-secret --from-file=username=/home/dd/engine/engine-private/mysql-username --from-file=password=/home/dd/engine/engine-private/mysql-password`,
177
+ );
178
+ shellExec(`sudo mkdir -p /mnt/data`);
179
+ shellExec(`sudo chmod 777 /mnt/data`);
180
+ shellExec(`sudo chown -R root:root /mnt/data`);
181
+ shellExec(`kubectl apply -k ${underpostRoot}/manifests/mysql`);
182
+ }
166
183
  if (options.full === true || options.postgresql === true) {
167
184
  if (options.pullImage === true) {
168
185
  shellExec(`docker pull postgres:latest`);
@@ -210,6 +227,9 @@ class UnderpostCluster {
210
227
 
211
228
  // await UnderpostTest.API.statusMonitor('mongodb-1');
212
229
  } else if (options.full === true || options.mongodb === true) {
230
+ if (options.pullImage === true) {
231
+ shellExec(`docker pull mongo:latest`);
232
+ }
213
233
  shellExec(
214
234
  `sudo kubectl create secret generic mongodb-keyfile --from-file=/home/dd/engine/engine-private/mongodb-keyfile`,
215
235
  );
@@ -217,6 +237,8 @@ class UnderpostCluster {
217
237
  `sudo kubectl create secret generic mongodb-secret --from-file=username=/home/dd/engine/engine-private/mongodb-username --from-file=password=/home/dd/engine/engine-private/mongodb-password`,
218
238
  );
219
239
  shellExec(`kubectl delete statefulset mongodb`);
240
+ if (options.kubeadm === true)
241
+ shellExec(`kubectl apply -f ${underpostRoot}/manifests/mongodb/storage-class.yaml`);
220
242
  shellExec(`kubectl apply -k ${underpostRoot}/manifests/mongodb`);
221
243
 
222
244
  const successInstance = await UnderpostTest.API.statusMonitor('mongodb-1');
@@ -239,8 +261,12 @@ class UnderpostCluster {
239
261
  }
240
262
  }
241
263
 
242
- if (options.full === true || options.contour === true)
264
+ if (options.full === true || options.contour === true) {
243
265
  shellExec(`kubectl apply -f https://projectcontour.io/quickstart/contour.yaml`);
266
+ if (options.kubeadm === true) {
267
+ shellExec(`sudo kubectl apply -f ${underpostRoot}/manifests/envoy-service-nodeport.yaml`);
268
+ }
269
+ }
244
270
 
245
271
  if (options.full === true || options.certManager === true) {
246
272
  if (!UnderpostDeploy.API.get('cert-manager').find((p) => p.STATUS === 'Running')) {
@@ -379,6 +405,14 @@ class UnderpostCluster {
379
405
  // Step 14: Remove the 'kind' Docker network.
380
406
  // This cleans up any network bridges or configurations specifically created by Kind.
381
407
  // shellExec(`docker network rm kind`);
408
+
409
+ // Reset kubelet
410
+ shellExec(`sudo systemctl stop kubelet`);
411
+ shellExec(`sudo rm -rf /etc/kubernetes/*`);
412
+ shellExec(`sudo rm -rf /var/lib/kubelet/*`);
413
+ shellExec(`sudo rm -rf /etc/cni/net.d/*`);
414
+ shellExec(`sudo systemctl daemon-reload`);
415
+ shellExec(`sudo systemctl start kubelet`);
382
416
  },
383
417
 
384
418
  getResourcesCapacity(kubeadm = false) {
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,7 +81,7 @@ spec:
80
81
  spec:
81
82
  containers:
82
83
  - name: ${deployId}-${env}-${suffix}
83
- image: localhost/debian:underpost
84
+ image: localhost/debian-underpost:${Underpost.version}
84
85
  resources:
85
86
  requests:
86
87
  memory: "${resources.requests.memory}"
@@ -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,
@@ -297,11 +299,17 @@ kubectl get configmap kubelet-config -n kube-system -o yaml > kubelet-config.yam
297
299
  shellExec(
298
300
  `kubectl create configmap underpost-config --from-file=/home/dd/engine/engine-private/conf/dd-cron/.env.${env}`,
299
301
  );
302
+ let renderHosts = '';
303
+ let concatHots = '';
300
304
  const etcHost = (
301
305
  concat,
302
306
  ) => `127.0.0.1 ${concat} localhost localhost.localdomain localhost4 localhost4.localdomain4
303
307
  ::1 localhost localhost.localdomain localhost6 localhost6.localdomain6`;
304
- let concatHots = '';
308
+ if (options.restoreHosts === true) {
309
+ renderHosts = etcHost(concatHots);
310
+ fs.writeFileSync(`/etc/hosts`, renderHosts, 'utf8');
311
+ return;
312
+ }
305
313
 
306
314
  for (const _deployId of deployList.split(',')) {
307
315
  const deployId = _deployId.trim();
@@ -342,7 +350,6 @@ kubectl get configmap kubelet-config -n kube-system -o yaml > kubelet-config.yam
342
350
  shellExec(`sudo kubectl apply -f ./${manifestsPath}/secret.yaml`);
343
351
  }
344
352
  }
345
- let renderHosts;
346
353
  switch (process.platform) {
347
354
  case 'linux':
348
355
  {
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,8 +12,23 @@ const logger = loggerFactory(import.meta);
12
12
  class UnderpostImage {
13
13
  static API = {
14
14
  dockerfile: {
15
- pullBaseImages() {
15
+ pullBaseImages(
16
+ options = {
17
+ kindLoad: false,
18
+ kubeadmLoad: false,
19
+ path: false,
20
+ version: '',
21
+ },
22
+ ) {
16
23
  shellExec(`sudo podman pull docker.io/library/debian:buster`);
24
+ const IMAGE_NAME = `debian-underpost`;
25
+ const IMAGE_NAME_FULL = `${IMAGE_NAME}:${options.version ?? Underpost.version}`;
26
+ const LOAD_TYPE = options.kindLoad === true ? `--kin-load` : `--kubeadm-load`;
27
+ shellExec(
28
+ `underpost dockerfile-image-build --podman-save --no-cache --image-path=. --path ${
29
+ options.path ?? getUnderpostRootPath()
30
+ } --image-name=${IMAGE_NAME_FULL} ${LOAD_TYPE}`,
31
+ );
17
32
  },
18
33
  build(
19
34
  options = {
package/src/cli/index.js CHANGED
@@ -5,6 +5,7 @@ import { 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';
8
9
 
9
10
  const underpostRootPath = getUnderpostRootPath();
10
11
  fs.existsSync(`${underpostRootPath}/.env`)
@@ -34,6 +35,7 @@ program
34
35
  .command('clone')
35
36
  .argument(`<uri>`, 'e.g. username/repository')
36
37
  .option('--bare', 'Clone only .git files')
38
+ .option('-g8', 'Use g8 repo extension')
37
39
  .description('Clone github repository')
38
40
  .action(Underpost.repo.clone);
39
41
 
@@ -42,6 +44,7 @@ program
42
44
  .argument('<path>', 'Absolute or relative directory')
43
45
  .argument(`<uri>`, 'e.g. username/repository')
44
46
  .description('Pull github repository')
47
+ .option('-g8', 'Use g8 repo extension')
45
48
  .action(Underpost.repo.pull);
46
49
 
47
50
  program
@@ -61,6 +64,7 @@ program
61
64
  .argument('<path>', 'Absolute or relative directory')
62
65
  .argument(`<uri>`, 'e.g. username/repository')
63
66
  .option('-f', 'Force push overwriting repository')
67
+ .option('-g8', 'Use g8 repo extension')
64
68
  .description('Push github repository')
65
69
  .action(Underpost.repo.push);
66
70
 
@@ -89,6 +93,7 @@ program
89
93
  .argument('[pod-name]', 'Optional pod name filter')
90
94
  .option('--reset', `Delete all clusters and prune all data and caches`)
91
95
  .option('--mariadb', 'Init with mariadb statefulset')
96
+ .option('--mysql', 'Init with mysql statefulset')
92
97
  .option('--mongodb', 'Init with mongodb statefulset')
93
98
  .option('--postgresql', 'Init with postgresql statefulset')
94
99
  .option('--mongodb4', 'Init with mongodb 4.4 service')
@@ -111,7 +116,7 @@ program
111
116
 
112
117
  program
113
118
  .command('deploy')
114
- .argument('<deploy-list>', 'Deploy id list, e.g. default-a,default-b')
119
+ .argument('[deploy-list]', 'Deploy id list, e.g. default-a,default-b')
115
120
  .argument('[env]', 'Optional environment, for default is development')
116
121
  .option('--remove', 'Delete deployments and services')
117
122
  .option('--sync', 'Sync deployments env, ports, and replicas')
@@ -126,6 +131,8 @@ program
126
131
  .option('--traffic <traffic-versions>', 'Comma separated custom deployment traffic')
127
132
  .option('--disable-update-deployment', 'Disable update deployments')
128
133
  .option('--info-traffic', 'get traffic conf form current resources deployments')
134
+ .option('--kubeadm', 'Enable kubeadm context')
135
+ .option('--restore-hosts', 'Restore defautl etc hosts')
129
136
  .option(
130
137
  '--rebuild-clients-bundle',
131
138
  'Inside container, rebuild clients bundle, only static public or storage client files',
@@ -165,6 +172,10 @@ program
165
172
 
166
173
  program
167
174
  .command('dockerfile-pull-base-images')
175
+ .option('--path [path]', 'Dockerfile path')
176
+ .option('--kind-load', 'Import tar image to Kind cluster')
177
+ .option('--kubeadm-load', 'Import tar image to Kubeadm cluster')
178
+ .option('--version', 'Set custom version')
168
179
  .description('Pull underpost dockerfile images requirements')
169
180
  .action(Underpost.image.dockerfile.pullBaseImages);
170
181
 
@@ -255,6 +266,14 @@ program
255
266
  .description('Monitor health server management')
256
267
  .action(Underpost.monitor.callback);
257
268
 
269
+ program
270
+ .command('lxd')
271
+ .option('--init', 'Init lxd')
272
+ .option('--reset', 'Reset lxd on current machine')
273
+ .option('--install', 'Install lxd on current machine')
274
+ .description('Lxd management')
275
+ .action(UnderpostLxd.API.callback);
276
+
258
277
  const buildCliDoc = () => {
259
278
  let md = shellExec(`node bin help`, { silent: true, stdout: true }).split('Options:');
260
279
  const baseOptions =
package/src/cli/lxd.js ADDED
@@ -0,0 +1,19 @@
1
+ import { shellExec } from '../server/process.js';
2
+
3
+ class UnderpostLxd {
4
+ static API = {
5
+ async callback(options = { init: false, reset: false, install: false }) {
6
+ if (options.reset === true) {
7
+ shellExec(`sudo systemctl stop snap.lxd.daemon`);
8
+ shellExec(`sudo snap remove lxd --purge`);
9
+ }
10
+ if (options.install === true) shellExec(`sudo snap install lxd`);
11
+ if (options.init === true) {
12
+ shellExec(`sudo systemctl start snap.lxd.daemon`);
13
+ shellExec(`sudo systemctl status snap.lxd.daemon`);
14
+ }
15
+ },
16
+ };
17
+ }
18
+
19
+ export default UnderpostLxd;
@@ -12,23 +12,25 @@ const logger = loggerFactory(import.meta);
12
12
 
13
13
  class UnderpostRepository {
14
14
  static API = {
15
- clone(gitUri = 'underpostnet/pwa-microservices-template', options = { bare: false }) {
15
+ clone(gitUri = 'underpostnet/pwa-microservices-template', options = { bare: false, g8: false }) {
16
+ const gExtension = options.g8 === true ? '.g8' : '.git';
16
17
  const repoName = gitUri.split('/').pop();
17
18
  if (fs.existsSync(`./${repoName}`)) fs.removeSync(`./${repoName}`);
18
19
  shellExec(
19
20
  `git clone ${options?.bare === true ? ` --bare ` : ''}https://${
20
21
  process.env.GITHUB_TOKEN ? `${process.env.GITHUB_TOKEN}@` : ''
21
- }github.com/${gitUri}.git`,
22
+ }github.com/${gitUri}${gExtension}`,
22
23
  {
23
24
  disableLog: true,
24
25
  },
25
26
  );
26
27
  },
27
- pull(repoPath = './', gitUri = 'underpostnet/pwa-microservices-template') {
28
+ pull(repoPath = './', gitUri = 'underpostnet/pwa-microservices-template', options = { g8: false }) {
29
+ const gExtension = options.g8 === true ? '.g8' : '.git';
28
30
  shellExec(
29
31
  `cd ${repoPath} && git pull https://${
30
32
  process.env.GITHUB_TOKEN ? `${process.env.GITHUB_TOKEN}@` : ''
31
- }github.com/${gitUri}.git`,
33
+ }github.com/${gitUri}${gExtension}`,
32
34
  {
33
35
  disableLog: true,
34
36
  },
@@ -57,9 +59,10 @@ class UnderpostRepository {
57
59
  shellExec(`cd ${repoPath} && git commit ${options?.empty ? `--allow-empty ` : ''}-m "${_message}"`);
58
60
  },
59
61
 
60
- push(repoPath = './', gitUri = 'underpostnet/pwa-microservices-template', options = { f: false }) {
62
+ push(repoPath = './', gitUri = 'underpostnet/pwa-microservices-template', options = { f: false, g8: false }) {
63
+ const gExtension = options.g8 === true ? '.g8' : '.git';
61
64
  shellExec(
62
- `cd ${repoPath} && git push https://${process.env.GITHUB_TOKEN}@github.com/${gitUri}.git${
65
+ `cd ${repoPath} && git push https://${process.env.GITHUB_TOKEN}@github.com/${gitUri}${gExtension}${
63
66
  options?.f === true ? ' --force' : ''
64
67
  }`,
65
68
  {
package/src/index.js CHANGED
@@ -30,7 +30,7 @@ class Underpost {
30
30
  * @type {String}
31
31
  * @memberof Underpost
32
32
  */
33
- static version = 'v2.8.75';
33
+ static version = 'v2.8.78';
34
34
  /**
35
35
  * Repository cli API
36
36
  * @static
@@ -1,6 +1,6 @@
1
1
  ARG BASE_DEBIAN=buster
2
2
 
3
- USER root
3
+ # USER root
4
4
 
5
5
  FROM debian:${BASE_DEBIAN}
6
6