underpost 2.8.78 → 2.8.82
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/.github/workflows/ghpkg.yml +23 -21
- package/.github/workflows/npmpkg.yml +16 -11
- package/.github/workflows/pwa-microservices-template.page.yml +12 -3
- package/.github/workflows/pwa-microservices-template.test.yml +20 -17
- package/.vscode/extensions.json +1 -2
- package/.vscode/settings.json +3 -0
- package/Dockerfile +14 -33
- package/README.md +25 -24
- package/bin/db.js +1 -0
- package/bin/deploy.js +91 -796
- package/bin/vs.js +10 -3
- package/cli.md +340 -191
- package/conf.js +4 -0
- package/docker-compose.yml +1 -1
- package/manifests/deployment/dd-template-development/deployment.yaml +167 -0
- package/manifests/deployment/dd-template-development/proxy.yaml +46 -0
- package/manifests/lxd/lxd-admin-profile.yaml +17 -0
- package/manifests/lxd/lxd-preseed.yaml +30 -0
- package/manifests/lxd/underpost-setup.sh +163 -0
- package/manifests/maas/device-scan.sh +43 -0
- package/manifests/maas/lxd-preseed.yaml +32 -0
- package/manifests/maas/maas-setup.sh +120 -0
- package/manifests/maas/nat-iptables.sh +26 -0
- package/manifests/mariadb/statefulset.yaml +2 -1
- package/manifests/mariadb/storage-class.yaml +10 -0
- package/manifests/mongodb-4.4/service-deployment.yaml +2 -2
- package/manifests/valkey/service.yaml +3 -9
- package/manifests/valkey/statefulset.yaml +10 -12
- package/package.json +1 -1
- package/src/cli/baremetal.js +1248 -0
- package/src/cli/cloud-init.js +528 -0
- package/src/cli/cluster.js +459 -232
- package/src/cli/deploy.js +34 -10
- package/src/cli/env.js +2 -2
- package/src/cli/image.js +57 -9
- package/src/cli/index.js +256 -218
- package/src/cli/lxd.js +380 -4
- package/src/index.js +40 -14
- package/src/runtime/lampp/Dockerfile +41 -47
- package/src/server/conf.js +58 -0
- package/src/server/logger.js +3 -3
- package/src/server/runtime.js +1 -6
- package/src/server/ssl.js +1 -12
- package/src/server/valkey.js +3 -3
- package/supervisord-openssh-server.conf +0 -5
package/src/cli/deploy.js
CHANGED
|
@@ -81,14 +81,14 @@ spec:
|
|
|
81
81
|
spec:
|
|
82
82
|
containers:
|
|
83
83
|
- name: ${deployId}-${env}-${suffix}
|
|
84
|
-
image: localhost/
|
|
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}"
|
|
84
|
+
image: localhost/rockylinux9-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}"
|
|
92
92
|
command:
|
|
93
93
|
- /bin/sh
|
|
94
94
|
- -c
|
|
@@ -256,8 +256,8 @@ kubectl rollout restart deployment/deployment-name
|
|
|
256
256
|
kubectl rollout undo deployment/deployment-name
|
|
257
257
|
kubectl scale statefulsets <stateful-set-name> --replicas=<new-replicas>
|
|
258
258
|
kubectl get pods -w
|
|
259
|
-
kubectl patch statefulset service
|
|
260
|
-
kubectl patch statefulset service
|
|
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"}]}}}}'
|
|
261
261
|
kubectl logs -f <pod-name>
|
|
262
262
|
kubectl describe pod <pod-name>
|
|
263
263
|
kubectl exec -it <pod-name> -- bash
|
|
@@ -273,6 +273,29 @@ kubectl patch ippool default-ipv4-ippool --type='json' -p='[{"op": "replace", "p
|
|
|
273
273
|
kubectl patch ippool default-ipv4-ippool --type='json' -p='[{"op": "replace", "path": "/spec/cidr", "value": "192.168.0.0/24"}]'
|
|
274
274
|
sudo podman run --rm localhost/<image-name>:<image-version> <command>
|
|
275
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
|
|
276
299
|
`);
|
|
277
300
|
if (deployList === 'dd' && fs.existsSync(`./engine-private/deploy/dd.router`))
|
|
278
301
|
deployList = fs.readFileSync(`./engine-private/deploy/dd.router`, 'utf8');
|
|
@@ -308,6 +331,7 @@ kubectl get configmap kubelet-config -n kube-system -o yaml > kubelet-config.yam
|
|
|
308
331
|
if (options.restoreHosts === true) {
|
|
309
332
|
renderHosts = etcHost(concatHots);
|
|
310
333
|
fs.writeFileSync(`/etc/hosts`, renderHosts, 'utf8');
|
|
334
|
+
logger.info(renderHosts);
|
|
311
335
|
return;
|
|
312
336
|
}
|
|
313
337
|
|
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
|
@@ -12,24 +12,63 @@ const logger = loggerFactory(import.meta);
|
|
|
12
12
|
class UnderpostImage {
|
|
13
13
|
static API = {
|
|
14
14
|
dockerfile: {
|
|
15
|
+
/**
|
|
16
|
+
* @method pullBaseImages
|
|
17
|
+
* @description Pulls base images and builds a 'rockylinux9-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
|
+
*/
|
|
15
26
|
pullBaseImages(
|
|
16
27
|
options = {
|
|
17
28
|
kindLoad: false,
|
|
18
29
|
kubeadmLoad: false,
|
|
30
|
+
k3sLoad: false,
|
|
19
31
|
path: false,
|
|
20
32
|
version: '',
|
|
21
33
|
},
|
|
22
34
|
) {
|
|
23
|
-
shellExec(`sudo podman pull docker.io/library/debian:buster`);
|
|
24
|
-
|
|
35
|
+
// shellExec(`sudo podman pull docker.io/library/debian:buster`);
|
|
36
|
+
shellExec(`sudo podman pull docker.io/library/rockylinux:9`);
|
|
37
|
+
const IMAGE_NAME = `rockylinux9-underpost`;
|
|
25
38
|
const IMAGE_NAME_FULL = `${IMAGE_NAME}:${options.version ?? Underpost.version}`;
|
|
26
|
-
|
|
39
|
+
let LOAD_TYPE = '';
|
|
40
|
+
if (options.kindLoad === true) {
|
|
41
|
+
LOAD_TYPE = `--kind-load`;
|
|
42
|
+
} else if (options.kubeadmLoad === true) {
|
|
43
|
+
LOAD_TYPE = `--kubeadm-load`;
|
|
44
|
+
} else if (options.k3sLoad === true) {
|
|
45
|
+
// Handle K3s load type
|
|
46
|
+
LOAD_TYPE = `--k3s-load`;
|
|
47
|
+
}
|
|
48
|
+
|
|
27
49
|
shellExec(
|
|
28
|
-
`underpost dockerfile-image-build --podman-save --
|
|
50
|
+
`underpost dockerfile-image-build --podman-save --reset --image-path=. --path ${
|
|
29
51
|
options.path ?? getUnderpostRootPath()
|
|
30
52
|
} --image-name=${IMAGE_NAME_FULL} ${LOAD_TYPE}`,
|
|
31
53
|
);
|
|
32
54
|
},
|
|
55
|
+
/**
|
|
56
|
+
* @method build
|
|
57
|
+
* @description Builds a Docker image using Podman, optionally saves it as a tar archive,
|
|
58
|
+
* and loads it into a specified Kubernetes cluster (Kind, Kubeadm, or K3s).
|
|
59
|
+
* @param {object} options - Options for building and loading images.
|
|
60
|
+
* @param {string} [options.path=''] - The path to the directory containing the Dockerfile.
|
|
61
|
+
* @param {string} [options.imageName=''] - The name and tag for the image (e.g., 'my-app:latest').
|
|
62
|
+
* @param {string} [options.imagePath=''] - Directory to save the image tar file.
|
|
63
|
+
* @param {string} [options.dockerfileName=''] - Name of the Dockerfile (defaults to 'Dockerfile').
|
|
64
|
+
* @param {boolean} [options.podmanSave=false] - If true, save the image as a tar archive using Podman.
|
|
65
|
+
* @param {boolean} [options.kindLoad=false] - If true, load the image archive into a Kind cluster.
|
|
66
|
+
* @param {boolean} [options.kubeadmLoad=false] - If true, load the image archive into a Kubeadm cluster (uses 'ctr').
|
|
67
|
+
* @param {boolean} [options.k3sLoad=false] - If true, load the image archive into a K3s cluster (uses 'k3s ctr').
|
|
68
|
+
* @param {boolean} [options.secrets=false] - If true, load secrets from the .env file for the build.
|
|
69
|
+
* @param {string} [options.secretsPath=''] - Custom path to the .env file for secrets.
|
|
70
|
+
* @param {boolean} [options.reset=false] - If true, perform a no-cache build.
|
|
71
|
+
*/
|
|
33
72
|
build(
|
|
34
73
|
options = {
|
|
35
74
|
path: '',
|
|
@@ -39,9 +78,10 @@ class UnderpostImage {
|
|
|
39
78
|
podmanSave: false,
|
|
40
79
|
kindLoad: false,
|
|
41
80
|
kubeadmLoad: false,
|
|
81
|
+
k3sLoad: false,
|
|
42
82
|
secrets: false,
|
|
43
83
|
secretsPath: '',
|
|
44
|
-
|
|
84
|
+
reset: false,
|
|
45
85
|
},
|
|
46
86
|
) {
|
|
47
87
|
const {
|
|
@@ -53,8 +93,9 @@ class UnderpostImage {
|
|
|
53
93
|
secrets,
|
|
54
94
|
secretsPath,
|
|
55
95
|
kindLoad,
|
|
56
|
-
noCache,
|
|
57
96
|
kubeadmLoad,
|
|
97
|
+
k3sLoad,
|
|
98
|
+
reset,
|
|
58
99
|
} = options;
|
|
59
100
|
const podManImg = `localhost/${imageName}`;
|
|
60
101
|
if (imagePath && typeof imagePath === 'string' && !fs.existsSync(imagePath))
|
|
@@ -71,11 +112,11 @@ class UnderpostImage {
|
|
|
71
112
|
),
|
|
72
113
|
);
|
|
73
114
|
for (const key of Object.keys(envObj)) {
|
|
74
|
-
secretsInput += ` && export ${key}="${envObj[key]}" `; // $(cat gitlab-token.txt)
|
|
115
|
+
secretsInput += ` && export ${key}="${envObj[key]}" `; // Example: $(cat gitlab-token.txt)
|
|
75
116
|
secretDockerInput += ` --secret id=${key},env=${key} \ `;
|
|
76
117
|
}
|
|
77
118
|
}
|
|
78
|
-
if (
|
|
119
|
+
if (reset === true) cache += ' --rm --no-cache';
|
|
79
120
|
if (path && typeof path === 'string')
|
|
80
121
|
shellExec(
|
|
81
122
|
`cd ${path}${secretsInput}&& sudo podman build -f ./${
|
|
@@ -85,7 +126,14 @@ class UnderpostImage {
|
|
|
85
126
|
|
|
86
127
|
if (podmanSave === true) shellExec(`podman save -o ${tarFile} ${podManImg}`);
|
|
87
128
|
if (kindLoad === true) shellExec(`sudo kind load image-archive ${tarFile}`);
|
|
88
|
-
if (kubeadmLoad === true)
|
|
129
|
+
if (kubeadmLoad === true) {
|
|
130
|
+
// Use 'ctr' for Kubeadm
|
|
131
|
+
shellExec(`sudo ctr -n k8s.io images import ${tarFile}`);
|
|
132
|
+
}
|
|
133
|
+
if (k3sLoad === true) {
|
|
134
|
+
// Use 'k3s ctr' for K3s
|
|
135
|
+
shellExec(`sudo k3s ctr images import ${tarFile}`);
|
|
136
|
+
}
|
|
89
137
|
},
|
|
90
138
|
},
|
|
91
139
|
};
|