underpost 2.8.77 → 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 +4 -3
- package/cli.md +27 -5
- package/docker-compose.yml +1 -1
- package/manifests/envoy-service-nodeport.yaml +23 -0
- package/manifests/mongodb/kustomization.yaml +1 -1
- package/manifests/mongodb/statefulset.yaml +12 -11
- package/manifests/mongodb/storage-class.yaml +9 -0
- package/manifests/mysql/kustomization.yaml +7 -0
- package/manifests/mysql/pv-pvc.yaml +27 -0
- package/manifests/mysql/statefulset.yaml +55 -0
- package/manifests/valkey/statefulset.yaml +2 -3
- package/package.json +1 -1
- package/src/cli/cluster.js +42 -8
- package/src/cli/deploy.js +10 -3
- package/src/cli/image.js +19 -4
- package/src/cli/index.js +16 -1
- package/src/cli/lxd.js +19 -0
- package/src/index.js +1 -1
- package/src/runtime/lampp/Dockerfile +1 -1
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.
|
|
71
|
+
## underpost ci/cd cli v2.8.78
|
|
72
72
|
|
|
73
73
|
### Usage: `underpost [options] [command]`
|
|
74
74
|
```
|
|
@@ -87,10 +87,10 @@ Commands:
|
|
|
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]
|
|
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
|
|
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/cli.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
## underpost ci/cd cli v2.8.
|
|
1
|
+
## underpost ci/cd cli v2.8.78
|
|
2
2
|
|
|
3
3
|
### Usage: `underpost [options] [command]`
|
|
4
4
|
```
|
|
@@ -17,10 +17,10 @@ Commands:
|
|
|
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]
|
|
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
|
|
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
|
```
|
|
@@ -199,6 +200,7 @@ Arguments:
|
|
|
199
200
|
Options:
|
|
200
201
|
--reset Delete all clusters and prune all data and caches
|
|
201
202
|
--mariadb Init with mariadb statefulset
|
|
203
|
+
--mysql Init with mysql statefulset
|
|
202
204
|
--mongodb Init with mongodb statefulset
|
|
203
205
|
--postgresql Init with postgresql statefulset
|
|
204
206
|
--mongodb4 Init with mongodb 4.4 service
|
|
@@ -223,7 +225,7 @@ Options:
|
|
|
223
225
|
|
|
224
226
|
### `deploy` :
|
|
225
227
|
```
|
|
226
|
-
Usage: underpost deploy [options]
|
|
228
|
+
Usage: underpost deploy [options] [deploy-list] [env]
|
|
227
229
|
|
|
228
230
|
Manage deployment, for default deploy development pods
|
|
229
231
|
|
|
@@ -250,6 +252,7 @@ Options:
|
|
|
250
252
|
--info-traffic get traffic conf form current resources
|
|
251
253
|
deployments
|
|
252
254
|
--kubeadm Enable kubeadm context
|
|
255
|
+
--restore-hosts Restore defautl etc hosts
|
|
253
256
|
--rebuild-clients-bundle Inside container, rebuild clients bundle,
|
|
254
257
|
only static public or storage client files
|
|
255
258
|
-h, --help display help for command
|
|
@@ -304,7 +307,11 @@ Options:
|
|
|
304
307
|
Pull underpost dockerfile images requirements
|
|
305
308
|
|
|
306
309
|
Options:
|
|
307
|
-
|
|
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
|
|
308
315
|
|
|
309
316
|
```
|
|
310
317
|
|
|
@@ -455,4 +462,19 @@ Options:
|
|
|
455
462
|
-h, --help display help for command
|
|
456
463
|
|
|
457
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
|
+
```
|
|
458
480
|
|
package/docker-compose.yml
CHANGED
|
@@ -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
|
|
@@ -3,7 +3,7 @@ kind: StatefulSet
|
|
|
3
3
|
metadata:
|
|
4
4
|
name: mongodb # Specifies the name of the statefulset
|
|
5
5
|
spec:
|
|
6
|
-
serviceName:
|
|
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
|
-
-
|
|
22
|
-
-
|
|
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
|
-
-
|
|
39
|
-
-
|
|
40
|
-
-
|
|
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:
|
|
103
|
-
memory:
|
|
102
|
+
cpu: "100m"
|
|
103
|
+
memory: "256Mi"
|
|
104
104
|
limits:
|
|
105
|
-
cpu:
|
|
106
|
-
memory:
|
|
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: [
|
|
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,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
|
-
|
|
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
package/src/cli/cluster.js
CHANGED
|
@@ -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
|
-
|
|
89
|
-
(options.istio
|
|
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(
|
|
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,6 +15,7 @@ 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
|
|
|
@@ -80,7 +81,7 @@ spec:
|
|
|
80
81
|
spec:
|
|
81
82
|
containers:
|
|
82
83
|
- name: ${deployId}-${env}-${suffix}
|
|
83
|
-
image: localhost/debian
|
|
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
|
-
|
|
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
|
|
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`)
|
|
@@ -92,6 +93,7 @@ program
|
|
|
92
93
|
.argument('[pod-name]', 'Optional pod name filter')
|
|
93
94
|
.option('--reset', `Delete all clusters and prune all data and caches`)
|
|
94
95
|
.option('--mariadb', 'Init with mariadb statefulset')
|
|
96
|
+
.option('--mysql', 'Init with mysql statefulset')
|
|
95
97
|
.option('--mongodb', 'Init with mongodb statefulset')
|
|
96
98
|
.option('--postgresql', 'Init with postgresql statefulset')
|
|
97
99
|
.option('--mongodb4', 'Init with mongodb 4.4 service')
|
|
@@ -114,7 +116,7 @@ program
|
|
|
114
116
|
|
|
115
117
|
program
|
|
116
118
|
.command('deploy')
|
|
117
|
-
.argument('
|
|
119
|
+
.argument('[deploy-list]', 'Deploy id list, e.g. default-a,default-b')
|
|
118
120
|
.argument('[env]', 'Optional environment, for default is development')
|
|
119
121
|
.option('--remove', 'Delete deployments and services')
|
|
120
122
|
.option('--sync', 'Sync deployments env, ports, and replicas')
|
|
@@ -130,6 +132,7 @@ program
|
|
|
130
132
|
.option('--disable-update-deployment', 'Disable update deployments')
|
|
131
133
|
.option('--info-traffic', 'get traffic conf form current resources deployments')
|
|
132
134
|
.option('--kubeadm', 'Enable kubeadm context')
|
|
135
|
+
.option('--restore-hosts', 'Restore defautl etc hosts')
|
|
133
136
|
.option(
|
|
134
137
|
'--rebuild-clients-bundle',
|
|
135
138
|
'Inside container, rebuild clients bundle, only static public or storage client files',
|
|
@@ -169,6 +172,10 @@ program
|
|
|
169
172
|
|
|
170
173
|
program
|
|
171
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')
|
|
172
179
|
.description('Pull underpost dockerfile images requirements')
|
|
173
180
|
.action(Underpost.image.dockerfile.pullBaseImages);
|
|
174
181
|
|
|
@@ -259,6 +266,14 @@ program
|
|
|
259
266
|
.description('Monitor health server management')
|
|
260
267
|
.action(Underpost.monitor.callback);
|
|
261
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
|
+
|
|
262
277
|
const buildCliDoc = () => {
|
|
263
278
|
let md = shellExec(`node bin help`, { silent: true, stdout: true }).split('Options:');
|
|
264
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;
|
package/src/index.js
CHANGED