underpost 2.8.799 → 2.8.812

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.
@@ -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.799'
61
+ engine.version: '2.8.812'
62
62
  networks:
63
63
  - load-balancer
64
64
 
@@ -17,7 +17,7 @@ spec:
17
17
  spec:
18
18
  containers:
19
19
  - name: dd-template-development-blue
20
- image: localhost/debian-underpost:v2.8.799
20
+ image: localhost/rockylinux9-underpost:v2.8.812
21
21
  # resources:
22
22
  # requests:
23
23
  # memory: "124Ki"
@@ -45,38 +45,38 @@ spec:
45
45
  selector:
46
46
  app: dd-template-development-blue
47
47
  ports:
48
- - name: "tcp-4001"
48
+ - name: 'tcp-4001'
49
49
  protocol: TCP
50
50
  port: 4001
51
51
  targetPort: 4001
52
- - name: "udp-4001"
52
+ - name: 'udp-4001'
53
53
  protocol: UDP
54
54
  port: 4001
55
55
  targetPort: 4001
56
56
 
57
- - name: "tcp-4002"
57
+ - name: 'tcp-4002'
58
58
  protocol: TCP
59
59
  port: 4002
60
60
  targetPort: 4002
61
- - name: "udp-4002"
61
+ - name: 'udp-4002'
62
62
  protocol: UDP
63
63
  port: 4002
64
64
  targetPort: 4002
65
65
 
66
- - name: "tcp-4003"
66
+ - name: 'tcp-4003'
67
67
  protocol: TCP
68
68
  port: 4003
69
69
  targetPort: 4003
70
- - name: "udp-4003"
70
+ - name: 'udp-4003'
71
71
  protocol: UDP
72
72
  port: 4003
73
73
  targetPort: 4003
74
74
 
75
- - name: "tcp-4004"
75
+ - name: 'tcp-4004'
76
76
  protocol: TCP
77
77
  port: 4004
78
78
  targetPort: 4004
79
- - name: "udp-4004"
79
+ - name: 'udp-4004'
80
80
  protocol: UDP
81
81
  port: 4004
82
82
  targetPort: 4004
@@ -100,7 +100,7 @@ spec:
100
100
  spec:
101
101
  containers:
102
102
  - name: dd-template-development-green
103
- image: localhost/debian-underpost:v2.8.799
103
+ image: localhost/rockylinux9-underpost:v2.8.812
104
104
  # resources:
105
105
  # requests:
106
106
  # memory: "124Ki"
@@ -129,38 +129,38 @@ spec:
129
129
  selector:
130
130
  app: dd-template-development-green
131
131
  ports:
132
- - name: "tcp-4001"
132
+ - name: 'tcp-4001'
133
133
  protocol: TCP
134
134
  port: 4001
135
135
  targetPort: 4001
136
- - name: "udp-4001"
136
+ - name: 'udp-4001'
137
137
  protocol: UDP
138
138
  port: 4001
139
139
  targetPort: 4001
140
140
 
141
- - name: "tcp-4002"
141
+ - name: 'tcp-4002'
142
142
  protocol: TCP
143
143
  port: 4002
144
144
  targetPort: 4002
145
- - name: "udp-4002"
145
+ - name: 'udp-4002'
146
146
  protocol: UDP
147
147
  port: 4002
148
148
  targetPort: 4002
149
149
 
150
- - name: "tcp-4003"
150
+ - name: 'tcp-4003'
151
151
  protocol: TCP
152
152
  port: 4003
153
153
  targetPort: 4003
154
- - name: "udp-4003"
154
+ - name: 'udp-4003'
155
155
  protocol: UDP
156
156
  port: 4003
157
157
  targetPort: 4003
158
158
 
159
- - name: "tcp-4004"
159
+ - name: 'tcp-4004'
160
160
  protocol: TCP
161
161
  port: 4004
162
162
  targetPort: 4004
163
- - name: "udp-4004"
163
+ - name: 'udp-4004'
164
164
  protocol: UDP
165
165
  port: 4004
166
166
  targetPort: 4004
@@ -53,7 +53,7 @@ echo "
53
53
  ██╗░░░██╗███╗░░██╗██████╗░███████╗██████╗░██████╗░░█████╗░░██████╗████████╗
54
54
  ██║░░░██║████╗░██║██╔══██╗██╔════╝██╔══██╗██╔══██╗██╔══██╗██╔════╝╚══██╔══╝
55
55
  ██║░░░██║██╔██╗██║██║░░██║█████╗░░██████╔╝██████╔╝██║░░██║╚█████╗░░░░██║░░░
56
- ██║░░░██║██║╚████║██║░░██║██╔══╝░░██╔══██╗██╔═╝░░░██║░░██║░╚═══██╗░░░██║░░░
56
+ ██║░░░██║██║╚████║██║░░██║██╔══╝░░██╔══██╗██╔═══╝░██║░░██║░╚═══██╗░░░██║░░░
57
57
  ╚██████╔╝██║░╚███║██████╔╝███████╗██║░░██║██║░░░░░╚█████╔╝██████╔╝░░░██║░░░
58
58
  ░╚═════╝░╚═╝░░╚══╝╚═════╝░╚══════╝╚═╝░░╚═╝╚═╝░░░░░░╚════╝░╚═════╝░░░░╚═╝░░░
59
59
 
@@ -0,0 +1,32 @@
1
+ config:
2
+ core.https_address: "[::]:8443"
3
+ # core.trust_password: password
4
+ networks:
5
+ - config:
6
+ ipv4.address: 10.10.10.1/24
7
+ ipv6.address: none
8
+ description: ""
9
+ name: lxdbr0
10
+ type: ""
11
+ project: default
12
+ storage_pools:
13
+ - config:
14
+ size: 500GB
15
+ description: ""
16
+ name: default
17
+ driver: zfs
18
+ profiles:
19
+ - config: {}
20
+ description: ""
21
+ devices:
22
+ eth0:
23
+ name: eth0
24
+ network: lxdbr0
25
+ type: nic
26
+ root:
27
+ path: /
28
+ pool: default
29
+ type: disk
30
+ name: default
31
+ projects: []
32
+ cluster: null
@@ -0,0 +1,64 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+
4
+ sudo snap install jq
5
+ sudo snap install maas
6
+
7
+ # Get default interface and IP address
8
+ INTERFACE=$(ip route | grep default | awk '{print $5}')
9
+ IP_ADDRESS=$(ip -4 addr show dev "$INTERFACE" | grep -oP '(?<=inet\s)\d+(\.\d+){3}')
10
+
11
+ # Disable firewalld
12
+ sudo systemctl disable --now iptables
13
+ sudo systemctl disable --now ufw
14
+ sudo systemctl disable --now firewalld
15
+
16
+ # Enable IP forwarding and configure NAT
17
+ echo "net.ipv4.ip_forward = 1" | sudo tee -a /etc/sysctl.conf
18
+ echo "net.ipv6.conf.all.forwarding = 1" | sudo tee -a /etc/sysctl.conf
19
+ sudo sysctl -p
20
+
21
+ # Accept all traffic
22
+ sudo iptables -P INPUT ACCEPT
23
+ sudo iptables -P FORWARD ACCEPT
24
+ sudo iptables -P OUTPUT ACCEPT
25
+
26
+ # List iptables rules
27
+ sudo iptables -L -n
28
+ sysctl net.ipv4.ip_forward
29
+
30
+ cd /home/dd/engine
31
+
32
+ # Load secrets
33
+ underpost secret underpost --create-from-file /home/dd/engine/engine-private/conf/dd-cron/.env.production
34
+
35
+ # Extract config values
36
+ DB_PG_MAAS_USER=$(node bin config get --plain DB_PG_MAAS_USER)
37
+ DB_PG_MAAS_PASS=$(node bin config get --plain DB_PG_MAAS_PASS)
38
+ DB_PG_MAAS_HOST=$(node bin config get --plain DB_PG_MAAS_HOST)
39
+ DB_PG_MAAS_NAME=$(node bin config get --plain DB_PG_MAAS_NAME)
40
+
41
+ MAAS_ADMIN_USERNAME=$(node bin config get --plain MAAS_ADMIN_USERNAME)
42
+ MAAS_ADMIN_EMAIL=$(node bin config get --plain MAAS_ADMIN_EMAIL)
43
+ MAAS_ADMIN_PASS=$(node bin config get --plain MAAS_ADMIN_PASS)
44
+
45
+ # Initialize MAAS
46
+ maas init region+rack \
47
+ --database-uri "postgres://${DB_PG_MAAS_USER}:${DB_PG_MAAS_PASS}@${DB_PG_MAAS_HOST}/${DB_PG_MAAS_NAME}" \
48
+ --maas-url http://${IP_ADDRESS}:5240/MAAS
49
+
50
+ # Let MAAS initialize
51
+ sleep 30
52
+
53
+ # Create admin and get API key
54
+ maas createadmin \
55
+ --username "$MAAS_ADMIN_USERNAME" \
56
+ --password "$MAAS_ADMIN_PASS" \
57
+ --email "$MAAS_ADMIN_EMAIL"
58
+
59
+ APIKEY=$(maas apikey --username "$MAAS_ADMIN_USERNAME")
60
+
61
+ # Login to MAAS
62
+ maas login "$MAAS_ADMIN_USERNAME" "http://localhost:5240/MAAS/" "$APIKEY"
63
+
64
+ maas "$MAAS_ADMIN_USERNAME" maas set-config name=upstream_dns value=8.8.8.8
@@ -49,7 +49,8 @@ spec:
49
49
  - metadata:
50
50
  name: mariadb-storage
51
51
  spec:
52
- accessModes: ['ReadWriteOnce']
52
+ accessModes: ["ReadWriteOnce"]
53
+ storageClassName: mariadb-storage-class
53
54
  resources:
54
55
  requests:
55
56
  storage: 1Gi
@@ -0,0 +1,10 @@
1
+ apiVersion: storage.k8s.io/v1
2
+ kind: StorageClass
3
+ metadata:
4
+ name: mariadb-storage-class # Renamed for clarity
5
+ annotations:
6
+ # Set this to "true" if you want this to be the default StorageClass
7
+ # storageclass.kubernetes.io/is-default-class: "true"
8
+ provisioner: rancher.io/local-path # Ensure this provisioner is installed in your cluster
9
+ reclaimPolicy: Retain # Or Delete, depending on your data retention policy
10
+ volumeBindingMode: WaitForFirstConsumer
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.799",
5
+ "version": "2.8.812",
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",
@@ -0,0 +1,99 @@
1
+ import { getNpmRootPath, getUnderpostRootPath } from '../server/conf.js';
2
+ import { shellExec } from '../server/process.js';
3
+ import dotenv from 'dotenv';
4
+ import { loggerFactory } from '../server/logger.js';
5
+ import { getLocalIPv4Address } from '../server/dns.js';
6
+
7
+ const logger = loggerFactory(import.meta);
8
+
9
+ class UnderpostBaremetal {
10
+ static API = {
11
+ callback(
12
+ options = {
13
+ dev: false,
14
+ controlServerInstall: false,
15
+ controlServerDbInit: false,
16
+ controlServerDbUninstall: false,
17
+ controlServerInit: false,
18
+ controlServerUninstall: false,
19
+ controlServerStop: false,
20
+ controlServerStart: false,
21
+ controlServerLogin: false,
22
+ getUsers: false,
23
+ newApiKey: false,
24
+ },
25
+ ) {
26
+ dotenv.config({ path: `${getUnderpostRootPath()}/.env`, override: true });
27
+ const npmRoot = getNpmRootPath();
28
+ const underpostRoot = options?.dev === true ? '.' : `${npmRoot}/underpost`;
29
+ const dbProviderId = 'postgresql-17';
30
+ if (options.controlServerLogin === true) {
31
+ shellExec(`MAAS_ADMIN_USERNAME=$(underpost config get --plain MAAS_ADMIN_USERNAME)
32
+ APIKEY=$(maas apikey --username "$MAAS_ADMIN_USERNAME")
33
+ maas login "$MAAS_ADMIN_USERNAME" "http://localhost:5240/MAAS/" "$APIKEY"`);
34
+ }
35
+ if (options.controlServerUninstall === true) {
36
+ // Stop MAAS services
37
+ shellExec(`sudo snap stop maas.pebble || true`);
38
+ shellExec(`sudo snap stop maas`);
39
+ shellExec(`sudo snap remove maas --purge || true`);
40
+
41
+ // Remove Snap residual data
42
+ shellExec(`sudo rm -rf /var/snap/maas`);
43
+ shellExec(`sudo rm -rf ~/snap/maas`);
44
+
45
+ // Remove MAAS config and data directories
46
+ shellExec(`sudo rm -rf /etc/maas`);
47
+ shellExec(`sudo rm -rf /var/lib/maas`);
48
+ shellExec(`sudo rm -rf /var/log/maas`);
49
+ }
50
+ if (options.controlServerStart === true) {
51
+ shellExec(`sudo snap restart maas`);
52
+ }
53
+ if (options.controlServerStop === true) {
54
+ shellExec(`sudo snap stop maas`);
55
+ }
56
+ if (options.controlServerDbInit === true) {
57
+ shellExec(`node ${underpostRoot}/bin/deploy ${dbProviderId} install`);
58
+ shellExec(
59
+ `node ${underpostRoot}/bin/deploy pg-drop-db ${process.env.DB_PG_MAAS_NAME} ${process.env.DB_PG_MAAS_USER}`,
60
+ );
61
+ shellExec(`node ${underpostRoot}/bin/deploy maas db`);
62
+ }
63
+ if (options.controlServerDbUninstall === true) {
64
+ shellExec(`node ${underpostRoot}/bin/deploy ${dbProviderId} uninstall`);
65
+ }
66
+ if (options.controlServerInstall === true) {
67
+ shellExec(`chmod +x ${underpostRoot}/manifests/maas/maas-setup.sh`);
68
+ shellExec(`${underpostRoot}/manifests/maas/maas-setup.sh`);
69
+ }
70
+ if (options.controlServerInit === true) {
71
+ shellExec(`node ${underpostRoot}/bin/deploy maas reset`);
72
+ }
73
+ if (options.getUsers === true) {
74
+ // <consumer_key>:<consumer_token>:<secret>
75
+ const MAAS_API_TOKEN = shellExec(`maas apikey --username ${process.env.MAAS_ADMIN_USERNAME}`, {
76
+ stdout: true,
77
+ }).trim();
78
+ const IP_ADDRESS = getLocalIPv4Address();
79
+ const [consumer_key, consumer_token, secret] = MAAS_API_TOKEN.split(`\n`)[0].split(':');
80
+ const users = shellExec(
81
+ `curl --header "Authorization: OAuth oauth_version=1.0, oauth_signature_method=PLAINTEXT, oauth_consumer_key=${consumer_key}, oauth_token=${consumer_token}, oauth_signature=&${secret}, oauth_nonce=$(uuidgen), oauth_timestamp=$(date +%s)" http://${IP_ADDRESS}:5240/MAAS/api/2.0/users/`,
82
+ {
83
+ silent: true,
84
+ },
85
+ );
86
+ logger.info('Users', JSON.parse(users));
87
+ }
88
+ if (options.newApiKey === true) {
89
+ shellExec(`maas apikey --generate --username ${process.env.MAAS_ADMIN_USERNAME}`);
90
+ // Delete api key
91
+ // maas apikey --delete 'consumer_key:consumer_token:secret' --username ${process.env.MAAS_ADMIN_USERNAME}
92
+ // List api keys
93
+ // maas apikey --with-names --username ${process.env.MAAS_ADMIN_USERNAME}
94
+ }
95
+ },
96
+ };
97
+ }
98
+
99
+ export default UnderpostBaremetal;
@@ -270,6 +270,20 @@ class UnderpostCluster {
270
270
  `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 --dry-run=client -o yaml | kubectl apply -f -`,
271
271
  );
272
272
  shellExec(`kubectl delete statefulset mariadb-statefulset --ignore-not-found`);
273
+
274
+ if (options.pullImage === true) {
275
+ shellExec(`docker pull mariadb:latest`);
276
+ shellExec(`sudo podman pull mariadb:latest`);
277
+ if (!options.kubeadm && !options.k3s)
278
+ // Only load if not kubeadm/k3s (Kind needs it)
279
+ shellExec(`sudo kind load docker-image mariadb:latest`);
280
+ else if (options.kubeadm || options.k3s)
281
+ // For kubeadm/k3s, ensure it's available for containerd
282
+ shellExec(`sudo crictl pull mariadb:latest`);
283
+ }
284
+ if (options.kubeadm === true)
285
+ // This storage class is specific to kubeadm setup
286
+ shellExec(`kubectl apply -f ${underpostRoot}/manifests/mariadb/storage-class.yaml`);
273
287
  shellExec(`kubectl apply -k ${underpostRoot}/manifests/mariadb`);
274
288
  }
275
289
  if (options.full === true || options.mysql === true) {
package/src/cli/deploy.js CHANGED
@@ -81,7 +81,7 @@ spec:
81
81
  spec:
82
82
  containers:
83
83
  - name: ${deployId}-${env}-${suffix}
84
- image: localhost/debian-underpost:${Underpost.version}
84
+ image: localhost/rockylinux9-underpost:${Underpost.version}
85
85
  # resources:
86
86
  # requests:
87
87
  # memory: "${resources.requests.memory}"
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
@@ -14,7 +14,7 @@ class UnderpostImage {
14
14
  dockerfile: {
15
15
  /**
16
16
  * @method pullBaseImages
17
- * @description Pulls base images and builds a 'debian-underpost' image,
17
+ * @description Pulls base images and builds a 'rockylinux9-underpost' image,
18
18
  * then loads it into the specified Kubernetes cluster type (Kind, Kubeadm, or K3s).
19
19
  * @param {object} options - Options for pulling and loading images.
20
20
  * @param {boolean} [options.kindLoad=false] - If true, load image into Kind cluster.
@@ -32,8 +32,9 @@ class UnderpostImage {
32
32
  version: '',
33
33
  },
34
34
  ) {
35
- shellExec(`sudo podman pull docker.io/library/debian:buster`);
36
- const IMAGE_NAME = `debian-underpost`;
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`;
37
38
  const IMAGE_NAME_FULL = `${IMAGE_NAME}:${options.version ?? Underpost.version}`;
38
39
  let LOAD_TYPE = '';
39
40
  if (options.kindLoad === true) {