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/conf.js
CHANGED
package/docker-compose.yml
CHANGED
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
---
|
|
2
|
+
apiVersion: apps/v1
|
|
3
|
+
kind: Deployment
|
|
4
|
+
metadata:
|
|
5
|
+
name: dd-template-development-blue
|
|
6
|
+
labels:
|
|
7
|
+
app: dd-template-development-blue
|
|
8
|
+
spec:
|
|
9
|
+
replicas: 1
|
|
10
|
+
selector:
|
|
11
|
+
matchLabels:
|
|
12
|
+
app: dd-template-development-blue
|
|
13
|
+
template:
|
|
14
|
+
metadata:
|
|
15
|
+
labels:
|
|
16
|
+
app: dd-template-development-blue
|
|
17
|
+
spec:
|
|
18
|
+
containers:
|
|
19
|
+
- name: dd-template-development-blue
|
|
20
|
+
image: localhost/rockylinux9-underpost:v2.8.82
|
|
21
|
+
# resources:
|
|
22
|
+
# requests:
|
|
23
|
+
# memory: "124Ki"
|
|
24
|
+
# cpu: "100m"
|
|
25
|
+
# limits:
|
|
26
|
+
# memory: "1992Ki"
|
|
27
|
+
# cpu: "1600m"
|
|
28
|
+
command:
|
|
29
|
+
- /bin/sh
|
|
30
|
+
- -c
|
|
31
|
+
- >
|
|
32
|
+
npm install -g npm@11.2.0 &&
|
|
33
|
+
npm install -g underpost &&
|
|
34
|
+
cd $(underpost root)/underpost &&
|
|
35
|
+
node bin/deploy update-default-conf template &&
|
|
36
|
+
mkdir -p /home/dd &&
|
|
37
|
+
cd /home/dd &&
|
|
38
|
+
underpost new engine
|
|
39
|
+
---
|
|
40
|
+
apiVersion: v1
|
|
41
|
+
kind: Service
|
|
42
|
+
metadata:
|
|
43
|
+
name: dd-template-development-blue-service
|
|
44
|
+
spec:
|
|
45
|
+
selector:
|
|
46
|
+
app: dd-template-development-blue
|
|
47
|
+
ports:
|
|
48
|
+
- name: 'tcp-4001'
|
|
49
|
+
protocol: TCP
|
|
50
|
+
port: 4001
|
|
51
|
+
targetPort: 4001
|
|
52
|
+
- name: 'udp-4001'
|
|
53
|
+
protocol: UDP
|
|
54
|
+
port: 4001
|
|
55
|
+
targetPort: 4001
|
|
56
|
+
|
|
57
|
+
- name: 'tcp-4002'
|
|
58
|
+
protocol: TCP
|
|
59
|
+
port: 4002
|
|
60
|
+
targetPort: 4002
|
|
61
|
+
- name: 'udp-4002'
|
|
62
|
+
protocol: UDP
|
|
63
|
+
port: 4002
|
|
64
|
+
targetPort: 4002
|
|
65
|
+
|
|
66
|
+
- name: 'tcp-4003'
|
|
67
|
+
protocol: TCP
|
|
68
|
+
port: 4003
|
|
69
|
+
targetPort: 4003
|
|
70
|
+
- name: 'udp-4003'
|
|
71
|
+
protocol: UDP
|
|
72
|
+
port: 4003
|
|
73
|
+
targetPort: 4003
|
|
74
|
+
|
|
75
|
+
- name: 'tcp-4004'
|
|
76
|
+
protocol: TCP
|
|
77
|
+
port: 4004
|
|
78
|
+
targetPort: 4004
|
|
79
|
+
- name: 'udp-4004'
|
|
80
|
+
protocol: UDP
|
|
81
|
+
port: 4004
|
|
82
|
+
targetPort: 4004
|
|
83
|
+
type: LoadBalancer
|
|
84
|
+
---
|
|
85
|
+
apiVersion: apps/v1
|
|
86
|
+
kind: Deployment
|
|
87
|
+
metadata:
|
|
88
|
+
name: dd-template-development-green
|
|
89
|
+
labels:
|
|
90
|
+
app: dd-template-development-green
|
|
91
|
+
spec:
|
|
92
|
+
replicas: 1
|
|
93
|
+
selector:
|
|
94
|
+
matchLabels:
|
|
95
|
+
app: dd-template-development-green
|
|
96
|
+
template:
|
|
97
|
+
metadata:
|
|
98
|
+
labels:
|
|
99
|
+
app: dd-template-development-green
|
|
100
|
+
spec:
|
|
101
|
+
containers:
|
|
102
|
+
- name: dd-template-development-green
|
|
103
|
+
image: localhost/rockylinux9-underpost:v2.8.82
|
|
104
|
+
# resources:
|
|
105
|
+
# requests:
|
|
106
|
+
# memory: "124Ki"
|
|
107
|
+
# cpu: "100m"
|
|
108
|
+
# limits:
|
|
109
|
+
# memory: "1992Ki"
|
|
110
|
+
# cpu: "1600m"
|
|
111
|
+
command:
|
|
112
|
+
- /bin/sh
|
|
113
|
+
- -c
|
|
114
|
+
- >
|
|
115
|
+
npm install -g npm@11.2.0 &&
|
|
116
|
+
npm install -g underpost &&
|
|
117
|
+
cd $(underpost root)/underpost &&
|
|
118
|
+
node bin/deploy update-default-conf template &&
|
|
119
|
+
mkdir -p /home/dd &&
|
|
120
|
+
cd /home/dd &&
|
|
121
|
+
underpost new engine
|
|
122
|
+
|
|
123
|
+
---
|
|
124
|
+
apiVersion: v1
|
|
125
|
+
kind: Service
|
|
126
|
+
metadata:
|
|
127
|
+
name: dd-template-development-green-service
|
|
128
|
+
spec:
|
|
129
|
+
selector:
|
|
130
|
+
app: dd-template-development-green
|
|
131
|
+
ports:
|
|
132
|
+
- name: 'tcp-4001'
|
|
133
|
+
protocol: TCP
|
|
134
|
+
port: 4001
|
|
135
|
+
targetPort: 4001
|
|
136
|
+
- name: 'udp-4001'
|
|
137
|
+
protocol: UDP
|
|
138
|
+
port: 4001
|
|
139
|
+
targetPort: 4001
|
|
140
|
+
|
|
141
|
+
- name: 'tcp-4002'
|
|
142
|
+
protocol: TCP
|
|
143
|
+
port: 4002
|
|
144
|
+
targetPort: 4002
|
|
145
|
+
- name: 'udp-4002'
|
|
146
|
+
protocol: UDP
|
|
147
|
+
port: 4002
|
|
148
|
+
targetPort: 4002
|
|
149
|
+
|
|
150
|
+
- name: 'tcp-4003'
|
|
151
|
+
protocol: TCP
|
|
152
|
+
port: 4003
|
|
153
|
+
targetPort: 4003
|
|
154
|
+
- name: 'udp-4003'
|
|
155
|
+
protocol: UDP
|
|
156
|
+
port: 4003
|
|
157
|
+
targetPort: 4003
|
|
158
|
+
|
|
159
|
+
- name: 'tcp-4004'
|
|
160
|
+
protocol: TCP
|
|
161
|
+
port: 4004
|
|
162
|
+
targetPort: 4004
|
|
163
|
+
- name: 'udp-4004'
|
|
164
|
+
protocol: UDP
|
|
165
|
+
port: 4004
|
|
166
|
+
targetPort: 4004
|
|
167
|
+
type: LoadBalancer
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
# "http://default.net:4001/socket.io": "http://localhost:4001/socket.io",
|
|
2
|
+
# "http://default.net:4002/peer": "http://localhost:4002/peer",
|
|
3
|
+
# "http://default.net:4001/": "http://localhost:4001/",
|
|
4
|
+
# "http://www.default.net:4003/": "http://localhost:4003/"
|
|
5
|
+
|
|
6
|
+
---
|
|
7
|
+
apiVersion: projectcontour.io/v1
|
|
8
|
+
kind: HTTPProxy
|
|
9
|
+
metadata:
|
|
10
|
+
name: default.net
|
|
11
|
+
spec:
|
|
12
|
+
virtualhost:
|
|
13
|
+
fqdn: default.net
|
|
14
|
+
routes:
|
|
15
|
+
- conditions:
|
|
16
|
+
- prefix: /
|
|
17
|
+
enableWebsockets: true
|
|
18
|
+
services:
|
|
19
|
+
- name: dd-template-development-blue-service
|
|
20
|
+
port: 4001
|
|
21
|
+
weight: 100
|
|
22
|
+
|
|
23
|
+
- conditions:
|
|
24
|
+
- prefix: /peer
|
|
25
|
+
enableWebsockets: true
|
|
26
|
+
services:
|
|
27
|
+
- name: dd-template-development-blue-service
|
|
28
|
+
port: 4002
|
|
29
|
+
weight: 100
|
|
30
|
+
|
|
31
|
+
---
|
|
32
|
+
apiVersion: projectcontour.io/v1
|
|
33
|
+
kind: HTTPProxy
|
|
34
|
+
metadata:
|
|
35
|
+
name: www.default.net
|
|
36
|
+
spec:
|
|
37
|
+
virtualhost:
|
|
38
|
+
fqdn: www.default.net
|
|
39
|
+
routes:
|
|
40
|
+
- conditions:
|
|
41
|
+
- prefix: /
|
|
42
|
+
enableWebsockets: true
|
|
43
|
+
services:
|
|
44
|
+
- name: dd-template-development-blue-service
|
|
45
|
+
port: 4003
|
|
46
|
+
weight: 100
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
config:
|
|
2
|
+
limits.cpu: "2"
|
|
3
|
+
limits.memory: 4GB
|
|
4
|
+
description: vm nat network
|
|
5
|
+
devices:
|
|
6
|
+
eth0:
|
|
7
|
+
name: eth0
|
|
8
|
+
network: lxdbr0
|
|
9
|
+
type: nic
|
|
10
|
+
ipv4.address: 10.250.250.100
|
|
11
|
+
root:
|
|
12
|
+
path: /
|
|
13
|
+
pool: local # lxc storage list
|
|
14
|
+
size: 100GB
|
|
15
|
+
type: disk
|
|
16
|
+
name: admin-profile
|
|
17
|
+
used_by: []
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
config:
|
|
2
|
+
core.https_address: 127.0.0.1:8443
|
|
3
|
+
networks: []
|
|
4
|
+
storage_pools:
|
|
5
|
+
- config:
|
|
6
|
+
size: 100GiB
|
|
7
|
+
description: ""
|
|
8
|
+
name: local
|
|
9
|
+
driver: zfs
|
|
10
|
+
storage_volumes: []
|
|
11
|
+
profiles:
|
|
12
|
+
- config: {}
|
|
13
|
+
description: ""
|
|
14
|
+
devices:
|
|
15
|
+
root:
|
|
16
|
+
path: /
|
|
17
|
+
pool: local
|
|
18
|
+
type: disk
|
|
19
|
+
name: default
|
|
20
|
+
projects: []
|
|
21
|
+
cluster:
|
|
22
|
+
server_name: lxd-node1
|
|
23
|
+
enabled: true
|
|
24
|
+
member_config: []
|
|
25
|
+
cluster_address: ""
|
|
26
|
+
cluster_certificate: ""
|
|
27
|
+
server_address: ""
|
|
28
|
+
cluster_password: ""
|
|
29
|
+
cluster_token: ""
|
|
30
|
+
cluster_certificate_path: ""
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
|
|
3
|
+
# Exit immediately if a command exits with a non-zero status.
|
|
4
|
+
set -e
|
|
5
|
+
|
|
6
|
+
echo "Starting Underpost Kubernetes Node Setup for Production (Kubeadm/K3s Use Case)..."
|
|
7
|
+
|
|
8
|
+
# --- Disk Partition Resizing (Keep as is, seems functional) ---
|
|
9
|
+
echo "Expanding /dev/sda2 partition and resizing filesystem..."
|
|
10
|
+
|
|
11
|
+
# Check if parted is installed
|
|
12
|
+
if ! command -v parted &>/dev/null; then
|
|
13
|
+
echo "parted not found, installing..."
|
|
14
|
+
sudo dnf install -y parted
|
|
15
|
+
fi
|
|
16
|
+
|
|
17
|
+
# Get start sector of /dev/sda2
|
|
18
|
+
START_SECTOR=$(sudo parted /dev/sda -ms unit s print | awk -F: '/^2:/{print $2}' | sed 's/s//')
|
|
19
|
+
|
|
20
|
+
# Resize the partition
|
|
21
|
+
# Using 'sudo' for parted commands
|
|
22
|
+
sudo parted /dev/sda ---pretend-input-tty <<EOF
|
|
23
|
+
unit s
|
|
24
|
+
resizepart 2 100%
|
|
25
|
+
Yes
|
|
26
|
+
quit
|
|
27
|
+
EOF
|
|
28
|
+
|
|
29
|
+
# Resize the filesystem
|
|
30
|
+
sudo resize2fs /dev/sda2
|
|
31
|
+
|
|
32
|
+
echo "Disk and filesystem resized successfully."
|
|
33
|
+
|
|
34
|
+
# --- Essential System Package Installation ---
|
|
35
|
+
echo "Installing essential system packages..."
|
|
36
|
+
sudo dnf install -y tar bzip2 git epel-release
|
|
37
|
+
|
|
38
|
+
# Perform a system update to ensure all packages are up-to-date
|
|
39
|
+
sudo dnf -y update
|
|
40
|
+
|
|
41
|
+
# --- NVM and Node.js Installation ---
|
|
42
|
+
echo "Installing NVM and Node.js v23.8.0..."
|
|
43
|
+
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash
|
|
44
|
+
|
|
45
|
+
# Load nvm for the current session
|
|
46
|
+
export NVM_DIR="$([ -z "${XDG_CONFIG_HOME-}" ] && printf %s "${HOME}/.nvm" || printf %s "${XDG_CONFIG_HOME}/nvm")"
|
|
47
|
+
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
|
|
48
|
+
|
|
49
|
+
nvm install 23.8.0
|
|
50
|
+
nvm use 23.8.0
|
|
51
|
+
|
|
52
|
+
echo "
|
|
53
|
+
██╗░░░██╗███╗░░██╗██████╗░███████╗██████╗░██████╗░░█████╗░░██████╗████████╗
|
|
54
|
+
██║░░░██║████╗░██║██╔══██╗██╔════╝██╔══██╗██╔══██╗██╔══██╗██╔════╝╚══██╔══╝
|
|
55
|
+
██║░░░██║██╔██╗██║██║░░██║█████╗░░██████╔╝██████╔╝██║░░██║╚█████╗░░░░██║░░░
|
|
56
|
+
██║░░░██║██║╚████║██║░░██║██╔══╝░░██╔══██╗██╔═══╝░██║░░██║░╚═══██╗░░░██║░░░
|
|
57
|
+
╚██████╔╝██║░╚███║██████╔╝███████╗██║░░██║██║░░░░░╚█████╔╝██████╔╝░░░██║░░░
|
|
58
|
+
░╚═════╝░╚═╝░░╚══╝╚═════╝░╚══════╝╚═╝░░╚═╝╚═╝░░░░░░╚════╝░╚═════╝░░░░╚═╝░░░
|
|
59
|
+
|
|
60
|
+
Installing underpost k8s node...
|
|
61
|
+
"
|
|
62
|
+
|
|
63
|
+
# Install underpost globally
|
|
64
|
+
npm install -g underpost
|
|
65
|
+
|
|
66
|
+
# Ensure underpost executable is in PATH and has execute permissions
|
|
67
|
+
# Adjusting this for global npm install which usually handles permissions
|
|
68
|
+
# If you still face issues, ensure /root/.nvm/versions/node/v23.8.0/bin is in your PATH
|
|
69
|
+
# For global installs, it's usually handled automatically.
|
|
70
|
+
# chmod +x /root/.nvm/versions/node/v23.8.0/bin/underpost # This might not be necessary for global npm installs
|
|
71
|
+
|
|
72
|
+
# --- Kernel Module for Bridge Filtering ---
|
|
73
|
+
# This is crucial for Kubernetes networking (CNI)
|
|
74
|
+
echo "Loading br_netfilter kernel module..."
|
|
75
|
+
sudo modprobe br_netfilter
|
|
76
|
+
|
|
77
|
+
# --- Initial Host Setup for Kubernetes Prerequisites ---
|
|
78
|
+
# This calls the initHost method in cluster.js to install Docker, Podman, Kind, Kubeadm, Helm.
|
|
79
|
+
echo "Running initial host setup for Kubernetes prerequisites..."
|
|
80
|
+
# Ensure the current directory is where 'underpost' expects its root, or use absolute paths.
|
|
81
|
+
# Assuming 'underpost root' correctly points to the base directory of your project.
|
|
82
|
+
cd "$(underpost root)/underpost"
|
|
83
|
+
underpost cluster --init-host
|
|
84
|
+
|
|
85
|
+
# --- Argument Parsing for Kubeadm/Kind/K3s/Worker ---
|
|
86
|
+
USE_KUBEADM=false
|
|
87
|
+
USE_KIND=false # Not the primary focus for this request, but keeping the logic
|
|
88
|
+
USE_K3S=false # New K3s option
|
|
89
|
+
USE_WORKER=false
|
|
90
|
+
|
|
91
|
+
for arg in "$@"; do
|
|
92
|
+
case "$arg" in
|
|
93
|
+
--kubeadm)
|
|
94
|
+
USE_KUBEADM=true
|
|
95
|
+
;;
|
|
96
|
+
--kind)
|
|
97
|
+
USE_KIND=true
|
|
98
|
+
;;
|
|
99
|
+
--k3s) # New K3s argument
|
|
100
|
+
USE_K3S=true
|
|
101
|
+
;;
|
|
102
|
+
--worker)
|
|
103
|
+
USE_WORKER=true
|
|
104
|
+
;;
|
|
105
|
+
esac
|
|
106
|
+
done
|
|
107
|
+
|
|
108
|
+
echo "USE_KUBEADM = $USE_KUBEADM"
|
|
109
|
+
echo "USE_KIND = $USE_KIND"
|
|
110
|
+
echo "USE_K3S = $USE_K3S" # Display K3s flag status
|
|
111
|
+
echo "USE_WORKER = $USE_WORKER"
|
|
112
|
+
|
|
113
|
+
# --- Kubernetes Cluster Initialization Logic ---
|
|
114
|
+
|
|
115
|
+
# Apply host configuration (SELinux, Containerd, Sysctl, and now firewalld disabling)
|
|
116
|
+
echo "Applying Kubernetes host configuration (SELinux, Containerd, Sysctl, Firewalld)..."
|
|
117
|
+
underpost cluster --config
|
|
118
|
+
|
|
119
|
+
if $USE_KUBEADM; then
|
|
120
|
+
if $USE_WORKER; then
|
|
121
|
+
echo "Running worker node setup for kubeadm..."
|
|
122
|
+
# For worker nodes, the 'underpost cluster --worker' command will handle joining
|
|
123
|
+
# the cluster. The join command itself needs to be provided from the control plane.
|
|
124
|
+
# This script assumes the join command will be executed separately or passed in.
|
|
125
|
+
# Example: underpost cluster --worker --join-command "kubeadm join ..."
|
|
126
|
+
# For now, this just runs the worker-specific config.
|
|
127
|
+
underpost cluster --worker
|
|
128
|
+
underpost cluster --chown
|
|
129
|
+
echo "Worker node setup initiated. You will need to manually join this worker to your control plane."
|
|
130
|
+
echo "On your control plane, run 'kubeadm token create --print-join-command' and execute the output here."
|
|
131
|
+
else
|
|
132
|
+
echo "Running control plane setup with kubeadm..."
|
|
133
|
+
# This will initialize the kubeadm control plane and install Calico
|
|
134
|
+
underpost cluster --kubeadm
|
|
135
|
+
echo "Kubeadm control plane initialized. Check cluster status with 'kubectl get nodes'."
|
|
136
|
+
fi
|
|
137
|
+
elif $USE_K3S; then # New K3s initialization block
|
|
138
|
+
if $USE_WORKER; then
|
|
139
|
+
echo "Running worker node setup for K3s..."
|
|
140
|
+
# For K3s worker nodes, the 'underpost cluster --worker' command will handle joining
|
|
141
|
+
# the cluster. The K3s join command (k3s agent --server ...) needs to be provided.
|
|
142
|
+
underpost cluster --worker --k3s
|
|
143
|
+
underpost cluster --chown
|
|
144
|
+
echo "K3s Worker node setup initiated. You will need to manually join this worker to your control plane."
|
|
145
|
+
echo "On your K3s control plane, get the K3S_TOKEN from /var/lib/rancher/k3s/server/node-token"
|
|
146
|
+
echo "and the K3S_URL (e.g., https://<control-plane-ip>:6443)."
|
|
147
|
+
echo "Then execute: K3S_URL=${K3S_URL} K3S_TOKEN=${K3S_TOKEN} curl -sfL https://get.k3s.io | sh -"
|
|
148
|
+
else
|
|
149
|
+
echo "Running control plane setup with K3s..."
|
|
150
|
+
underpost cluster --k3s
|
|
151
|
+
echo "K3s control plane initialized. Check cluster status with 'kubectl get nodes'."
|
|
152
|
+
fi
|
|
153
|
+
elif $USE_KIND; then
|
|
154
|
+
echo "Running control node with kind..."
|
|
155
|
+
underpost cluster
|
|
156
|
+
echo "Kind cluster initialized. Check cluster status with 'kubectl get nodes'."
|
|
157
|
+
else
|
|
158
|
+
echo "No specific cluster role (--kubeadm, --kind, --k3s, --worker) specified. Please provide one."
|
|
159
|
+
exit 1
|
|
160
|
+
fi
|
|
161
|
+
|
|
162
|
+
echo "Underpost Kubernetes Node Setup completed."
|
|
163
|
+
echo "Remember to verify cluster health with 'kubectl get nodes' and 'kubectl get pods --all-namespaces'."
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
|
|
3
|
+
for iface_path in /sys/class/net/*; do
|
|
4
|
+
name=$(basename "$iface_path")
|
|
5
|
+
mac=$(< "$iface_path/address")
|
|
6
|
+
ip=$(ip -4 addr show dev "$name" \
|
|
7
|
+
| grep -oP '(?<=inet\s)\d+(\.\d+){3}' || echo "—")
|
|
8
|
+
operstate=$(< "$iface_path/operstate")
|
|
9
|
+
mtu=$(< "$iface_path/mtu")
|
|
10
|
+
|
|
11
|
+
# Driver: módulo kernel que maneja esta interfaz
|
|
12
|
+
if [ -L "$iface_path/device/driver" ]; then
|
|
13
|
+
driver=$(basename "$(readlink -f "$iface_path/device/driver")")
|
|
14
|
+
else
|
|
15
|
+
driver="—"
|
|
16
|
+
fi
|
|
17
|
+
|
|
18
|
+
# Vendor:Device ID PCI
|
|
19
|
+
pci_dev="$iface_path/device"
|
|
20
|
+
if [ -f "$pci_dev/vendor" ] && [ -f "$pci_dev/device" ]; then
|
|
21
|
+
vendor_id=$(< "$pci_dev/vendor")
|
|
22
|
+
device_id=$(< "$pci_dev/device")
|
|
23
|
+
# pasamos de 0x8086 a 8086, etc.
|
|
24
|
+
vendor_id=${vendor_id#0x}
|
|
25
|
+
device_id=${device_id#0x}
|
|
26
|
+
pci="${vendor_id}:${device_id}"
|
|
27
|
+
else
|
|
28
|
+
pci="—"
|
|
29
|
+
fi
|
|
30
|
+
|
|
31
|
+
# Link Speed: lectura directa de /sys/class/net/<iface>/speed
|
|
32
|
+
speed=$(cat "$iface_path/speed" 2>/dev/null || echo "—")
|
|
33
|
+
|
|
34
|
+
echo "Interface: $name"
|
|
35
|
+
echo " MAC: $mac"
|
|
36
|
+
echo " IPv4: $ip"
|
|
37
|
+
echo " State: $operstate"
|
|
38
|
+
echo " MTU: $mtu"
|
|
39
|
+
echo " Driver: $driver"
|
|
40
|
+
echo " PCI Vendor:Device ID: $pci"
|
|
41
|
+
echo " Link Speed: ${speed}Mb/s"
|
|
42
|
+
echo
|
|
43
|
+
done
|
|
@@ -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,120 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
set -euo pipefail
|
|
3
|
+
|
|
4
|
+
# Install jq for JSON parsing
|
|
5
|
+
sudo snap install jq
|
|
6
|
+
|
|
7
|
+
# Install MAAS
|
|
8
|
+
sudo snap install maas
|
|
9
|
+
|
|
10
|
+
# Get default interface and IP address
|
|
11
|
+
INTERFACE=$(ip route | grep default | awk '{print $5}')
|
|
12
|
+
IP_ADDRESS=$(ip -4 addr show dev "$INTERFACE" | grep -oP '(?<=inet\s)\d+(\.\d+){3}')
|
|
13
|
+
|
|
14
|
+
# Change to the engine directory (assuming this is where your MAAS related configs are)
|
|
15
|
+
cd /home/dd/engine
|
|
16
|
+
|
|
17
|
+
# Load secrets for MAAS database and admin credentials
|
|
18
|
+
underpost secret underpost --create-from-file /home/dd/engine/engine-private/conf/dd-cron/.env.production
|
|
19
|
+
|
|
20
|
+
# Extract configuration values from secrets
|
|
21
|
+
DB_PG_MAAS_USER=$(node bin config get --plain DB_PG_MAAS_USER)
|
|
22
|
+
DB_PG_MAAS_PASS=$(node bin config get --plain DB_PG_MAAS_PASS)
|
|
23
|
+
DB_PG_MAAS_HOST=$(node bin config get --plain DB_PG_MAAS_HOST)
|
|
24
|
+
DB_PG_MAAS_NAME=$(node bin config get --plain DB_PG_MAAS_NAME)
|
|
25
|
+
|
|
26
|
+
MAAS_ADMIN_USERNAME=$(node bin config get --plain MAAS_ADMIN_USERNAME)
|
|
27
|
+
MAAS_ADMIN_EMAIL=$(node bin config get --plain MAAS_ADMIN_EMAIL)
|
|
28
|
+
MAAS_ADMIN_PASS=$(node bin config get --plain MAAS_ADMIN_PASS)
|
|
29
|
+
|
|
30
|
+
# Initialize MAAS region+rack controller
|
|
31
|
+
maas init region+rack \
|
|
32
|
+
--database-uri "postgres://${DB_PG_MAAS_USER}:${DB_PG_MAAS_PASS}@${DB_PG_MAAS_HOST}/${DB_PG_MAAS_NAME}" \
|
|
33
|
+
--maas-url http://${IP_ADDRESS}:5240/MAAS
|
|
34
|
+
|
|
35
|
+
# Allow MAAS to initialize (wait for services to come up)
|
|
36
|
+
echo "Waiting for MAAS to initialize..."
|
|
37
|
+
sleep 30
|
|
38
|
+
|
|
39
|
+
# Create MAAS administrator account
|
|
40
|
+
maas createadmin \
|
|
41
|
+
--username "$MAAS_ADMIN_USERNAME" \
|
|
42
|
+
--password "$MAAS_ADMIN_PASS" \
|
|
43
|
+
--email "$MAAS_ADMIN_EMAIL"
|
|
44
|
+
|
|
45
|
+
# Get the API key for the admin user
|
|
46
|
+
APIKEY=$(maas apikey --username "$MAAS_ADMIN_USERNAME")
|
|
47
|
+
|
|
48
|
+
# Login to MAAS using the admin profile
|
|
49
|
+
echo "Logging into MAAS..."
|
|
50
|
+
maas login "$MAAS_ADMIN_USERNAME" "http://localhost:5240/MAAS/" "$APIKEY"
|
|
51
|
+
|
|
52
|
+
# Set upstream DNS for MAAS
|
|
53
|
+
echo "Setting upstream DNS to 8.8.8.8..."
|
|
54
|
+
maas "$MAAS_ADMIN_USERNAME" maas set-config name=upstream_dns value=8.8.8.8
|
|
55
|
+
|
|
56
|
+
# echo "Downloading Ubuntu Noble amd64/ga-24.04 image..."
|
|
57
|
+
# maas $MAAS_ADMIN_USERNAME boot-source-selections create 1 \
|
|
58
|
+
# os="ubuntu" release="noble" arches="amd64" \
|
|
59
|
+
# subarches="ga-24.04" labels="*"
|
|
60
|
+
|
|
61
|
+
echo "Downloading Ubuntu Noble arm64/ga-24.04 image..."
|
|
62
|
+
maas $MAAS_ADMIN_USERNAME boot-source-selections create 1 \
|
|
63
|
+
os="ubuntu" release="noble" arches="arm64" \
|
|
64
|
+
subarches="ga-24.04" labels="*"
|
|
65
|
+
|
|
66
|
+
# Import the newly selected boot images
|
|
67
|
+
echo "Importing boot images (this may take some time)..."
|
|
68
|
+
maas "$MAAS_ADMIN_USERNAME" boot-resources import
|
|
69
|
+
|
|
70
|
+
# Disable the MAAS HTTP proxy
|
|
71
|
+
echo "Disabling MAAS HTTP proxy..."
|
|
72
|
+
maas "$MAAS_ADMIN_USERNAME" maas set-config name=enable_http_proxy value=false
|
|
73
|
+
|
|
74
|
+
# Disable DNSSEC validation
|
|
75
|
+
echo "Disabling DNSSEC validation..."
|
|
76
|
+
maas "$MAAS_ADMIN_USERNAME" maas set-config name=dnssec_validation value=no
|
|
77
|
+
|
|
78
|
+
# Set network discovery interval to 10 minutes (600 seconds)
|
|
79
|
+
echo "Setting network discovery interval to 10 minutes..."
|
|
80
|
+
maas "$MAAS_ADMIN_USERNAME" maas set-config name=active_discovery_interval value=600
|
|
81
|
+
|
|
82
|
+
SSH_KEY=$(cat ~/.ssh/id_rsa.pub)
|
|
83
|
+
maas $MAAS_ADMIN_USERNAME sshkeys create "key=$SSH_KEY"
|
|
84
|
+
|
|
85
|
+
echo "MAAS setup script completed with new configurations."
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
# maas $MAAS_ADMIN_USERNAME maas set-config name=default_storage_layout value=lvm
|
|
89
|
+
# maas $MAAS_ADMIN_USERNAME maas set-config name=network_discovery value=disabled
|
|
90
|
+
# maas $MAAS_ADMIN_USERNAME maas set-config name=enable_analytics value=false
|
|
91
|
+
# maas $MAAS_ADMIN_USERNAME maas set-config name=enable_third_party_drivers value=false
|
|
92
|
+
# maas $MAAS_ADMIN_USERNAME maas set-config name=curtin_verbose value=true
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
echo "Configuring DHCP for fabric-1 (untagged VLAN)..."
|
|
97
|
+
|
|
98
|
+
# Get the FABRIC_ID for "fabric-1"
|
|
99
|
+
SUBNET_CIDR="192.168.1.0/24"
|
|
100
|
+
SUBNET_ID=$(maas "$MAAS_ADMIN_USERNAME" subnets read | jq -r '.[] | select(.cidr == "'"$SUBNET_CIDR"'") | .id')
|
|
101
|
+
FABRIC_ID=$(maas "$MAAS_ADMIN_USERNAME" fabrics read | jq -r '.[] | select(.name == "fabric-1") | .id')
|
|
102
|
+
RACK_CONTROLLER_ID=$(maas "$MAAS_ADMIN_USERNAME" rack-controllers read | jq -r '.[] | select(.ip_addresses[] == "'"$IP_ADDRESS"'") | .system_id')
|
|
103
|
+
START_IP="192.168.1.191"
|
|
104
|
+
END_IP="192.168.1.254"
|
|
105
|
+
|
|
106
|
+
if [ -z "$FABRIC_ID" ]; then
|
|
107
|
+
echo "Error: Could not find FABRIC_ID for 'fabric-1'. Please ensure 'fabric-1' exists in MAAS."
|
|
108
|
+
exit 1
|
|
109
|
+
fi
|
|
110
|
+
|
|
111
|
+
# Enable DHCP on the untagged VLAN (VLAN tag 0)
|
|
112
|
+
echo "Enabling DHCP on VLAN 0 for fabric-1 (ID: $FABRIC_ID)..."
|
|
113
|
+
maas "$MAAS_ADMIN_USERNAME" vlan update "$FABRIC_ID" 0 dhcp_on=true primary_rack="$RACK_CONTROLLER_ID"
|
|
114
|
+
|
|
115
|
+
# Create a Dynamic IP Range for enlistment, commissioning, and deployment
|
|
116
|
+
echo "Creating dynamic IP range from $START_IP to $END_IP..."
|
|
117
|
+
maas "$MAAS_ADMIN_USERNAME" ipranges create type=dynamic start_ip="$START_IP" end_ip="$END_IP"
|
|
118
|
+
|
|
119
|
+
echo "Setting gateway IP for subnet $SUBNET_CIDR (ID: $SUBNET_ID) to $IP_ADDRESS..."
|
|
120
|
+
maas "$MAAS_ADMIN_USERNAME" subnet update $SUBNET_ID gateway_ip=$IP_ADDRESS
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
set -euo pipefail
|
|
3
|
+
|
|
4
|
+
# Disable firewalld
|
|
5
|
+
sudo systemctl disable --now iptables
|
|
6
|
+
sudo systemctl disable --now ufw
|
|
7
|
+
sudo systemctl disable --now firewalld
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
# Remove any existing entries, then append exactly one
|
|
11
|
+
sudo sed -i '/^net.ipv4.ip_forward/d' /etc/sysctl.conf
|
|
12
|
+
sudo sed -i '/^net.ipv6.conf.all.forwarding/d' /etc/sysctl.conf
|
|
13
|
+
echo "net.ipv4.ip_forward = 1" | sudo tee -a /etc/sysctl.conf
|
|
14
|
+
echo "net.ipv6.conf.all.forwarding = 1" | sudo tee -a /etc/sysctl.conf
|
|
15
|
+
# ---
|
|
16
|
+
|
|
17
|
+
sudo sysctl -p
|
|
18
|
+
|
|
19
|
+
# Accept all traffic
|
|
20
|
+
sudo iptables -P INPUT ACCEPT
|
|
21
|
+
sudo iptables -P FORWARD ACCEPT
|
|
22
|
+
sudo iptables -P OUTPUT ACCEPT
|
|
23
|
+
|
|
24
|
+
# List iptables rules and forwarding flag
|
|
25
|
+
sudo iptables -L -n
|
|
26
|
+
sysctl net.ipv4.ip_forward net.ipv6.conf.all.forwarding
|