underpost 2.8.784 → 2.8.786
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 +1 -1
- package/cli.md +5 -1
- package/docker-compose.yml +1 -1
- package/manifests/lxd/underpost-setup.sh +55 -2
- package/package.json +1 -1
- package/src/cli/cluster.js +29 -18
- package/src/cli/deploy.js +7 -7
- package/src/cli/index.js +4 -0
- package/src/cli/lxd.js +10 -2
- package/src/index.js +1 -1
package/README.md
CHANGED
package/cli.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
## underpost ci/cd cli v2.8.
|
|
1
|
+
## underpost ci/cd cli v2.8.786
|
|
2
2
|
|
|
3
3
|
### Usage: `underpost [options] [command]`
|
|
4
4
|
```
|
|
@@ -219,6 +219,9 @@ Options:
|
|
|
219
219
|
--pull-image Set optional pull associated image
|
|
220
220
|
--init-host Install k8s node necessary cli env: kind, kubeadm,
|
|
221
221
|
docker, podman, helm
|
|
222
|
+
--config Set k8s base node config
|
|
223
|
+
--worker Set worker node context
|
|
224
|
+
--chown Set k8s kube chown
|
|
222
225
|
-h, --help display help for command
|
|
223
226
|
|
|
224
227
|
```
|
|
@@ -478,6 +481,7 @@ Options:
|
|
|
478
481
|
--dev Set dev context env
|
|
479
482
|
--create-virtual-network Create lxd virtual network bridge
|
|
480
483
|
--create-admin-profile Create admin profile for lxd management
|
|
484
|
+
--control set control node vm context
|
|
481
485
|
--create-vm <vm-id> Create default virtual machines
|
|
482
486
|
--init-vm <vm-id> Get init vm underpost script
|
|
483
487
|
--info-vm <vm-id> Get all info vm
|
package/docker-compose.yml
CHANGED
|
@@ -25,8 +25,6 @@ EOF
|
|
|
25
25
|
resize2fs /dev/sda2
|
|
26
26
|
|
|
27
27
|
echo "Disk and filesystem resized successfully."
|
|
28
|
-
|
|
29
|
-
mkdir -p /home/dd
|
|
30
28
|
sudo dnf install -y tar
|
|
31
29
|
sudo dnf install -y bzip2
|
|
32
30
|
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash
|
|
@@ -34,6 +32,61 @@ NVM_DIR="$([ -z "${XDG_CONFIG_HOME-}" ] && printf %s "${HOME}/.nvm" || printf %s
|
|
|
34
32
|
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
|
|
35
33
|
nvm install 23.8.0
|
|
36
34
|
nvm use 23.8.0
|
|
35
|
+
echo "
|
|
36
|
+
██╗░░░██╗███╗░░██╗██████╗░███████╗██████╗░██████╗░░█████╗░░██████╗████████╗
|
|
37
|
+
██║░░░██║████╗░██║██╔══██╗██╔════╝██╔══██╗██╔══██╗██╔══██╗██╔════╝╚══██╔══╝
|
|
38
|
+
██║░░░██║██╔██╗██║██║░░██║█████╗░░██████╔╝██████╔╝██║░░██║╚█████╗░░░░██║░░░
|
|
39
|
+
██║░░░██║██║╚████║██║░░██║██╔══╝░░██╔══██╗██╔═══╝░██║░░██║░╚═══██╗░░░██║░░░
|
|
40
|
+
╚██████╔╝██║░╚███║██████╔╝███████╗██║░░██║██║░░░░░╚█████╔╝██████╔╝░░░██║░░░
|
|
41
|
+
░╚═════╝░╚═╝░░╚══╝╚═════╝░╚══════╝╚═╝░░╚═╝╚═╝░░░░░░╚════╝░╚═════╝░░░░╚═╝░░░
|
|
42
|
+
|
|
43
|
+
Installing underpost k8s node ...
|
|
44
|
+
|
|
45
|
+
"
|
|
37
46
|
npm install -g underpost
|
|
38
47
|
chmod +x /root/.nvm/versions/node/v23.8.0/bin/underpost
|
|
39
48
|
sudo modprobe br_netfilter
|
|
49
|
+
mkdir -p /home/dd
|
|
50
|
+
cd $(underpost root)/underpost
|
|
51
|
+
underpost cluster --init-host
|
|
52
|
+
|
|
53
|
+
# Default flags
|
|
54
|
+
USE_KUBEADM=false
|
|
55
|
+
USE_KIND=false
|
|
56
|
+
USE_WORKER=false
|
|
57
|
+
|
|
58
|
+
# Loop through arguments
|
|
59
|
+
for arg in "$@"; do
|
|
60
|
+
case "$arg" in
|
|
61
|
+
--kubeadm)
|
|
62
|
+
USE_KUBEADM=true
|
|
63
|
+
;;
|
|
64
|
+
--kind)
|
|
65
|
+
USE_KIND=true
|
|
66
|
+
;;
|
|
67
|
+
--worker)
|
|
68
|
+
USE_WORKER=true
|
|
69
|
+
;;
|
|
70
|
+
esac
|
|
71
|
+
done
|
|
72
|
+
|
|
73
|
+
underpost cluster --kubeadm
|
|
74
|
+
underpost --reset
|
|
75
|
+
|
|
76
|
+
# Behavior based on flags
|
|
77
|
+
if $USE_KUBEADM; then
|
|
78
|
+
echo "Running control node with kubeadm..."
|
|
79
|
+
underpost cluster --kubeadm
|
|
80
|
+
kubectl get pods --all-namespaces -o wide -w
|
|
81
|
+
fi
|
|
82
|
+
|
|
83
|
+
if $USE_KIND; then
|
|
84
|
+
echo "Running control node with kind..."
|
|
85
|
+
underpost cluster
|
|
86
|
+
kubectl get pods --all-namespaces -o wide -w
|
|
87
|
+
fi
|
|
88
|
+
|
|
89
|
+
if $USE_WORKER; then
|
|
90
|
+
echo "Running worker..."
|
|
91
|
+
underpost cluster --worker --config
|
|
92
|
+
fi
|
package/package.json
CHANGED
package/src/cli/cluster.js
CHANGED
|
@@ -32,6 +32,9 @@ class UnderpostCluster {
|
|
|
32
32
|
dedicatedGpu: false,
|
|
33
33
|
kubeadm: false,
|
|
34
34
|
initHost: false,
|
|
35
|
+
config: false,
|
|
36
|
+
worker: false,
|
|
37
|
+
chown: false,
|
|
35
38
|
},
|
|
36
39
|
) {
|
|
37
40
|
// sudo dnf update
|
|
@@ -41,6 +44,8 @@ class UnderpostCluster {
|
|
|
41
44
|
// 4) Install LXD with MAAS from Rocky Linux docs
|
|
42
45
|
// 5) Install MAAS src from snap
|
|
43
46
|
if (options.initHost === true) return UnderpostCluster.API.initHost();
|
|
47
|
+
if (options.config === true) UnderpostCluster.API.config();
|
|
48
|
+
if (options.chown === true) UnderpostCluster.API.chown();
|
|
44
49
|
const npmRoot = getNpmRootPath();
|
|
45
50
|
const underpostRoot = options?.dev === true ? '.' : `${npmRoot}/underpost`;
|
|
46
51
|
if (options.infoCapacityPod === true) return logger.info('', UnderpostDeploy.API.resourcesFactory());
|
|
@@ -91,31 +96,17 @@ class UnderpostCluster {
|
|
|
91
96
|
UnderpostDeploy.API.get('calico-kube-controllers')[0];
|
|
92
97
|
|
|
93
98
|
if (
|
|
99
|
+
!options.worker &&
|
|
94
100
|
!alrreadyCluster &&
|
|
95
101
|
((!options.kubeadm && !UnderpostDeploy.API.get('kube-apiserver-kind-control-plane')[0]) ||
|
|
96
102
|
(options.kubeadm === true && !UnderpostDeploy.API.get('calico-kube-controllers')[0]))
|
|
97
103
|
) {
|
|
98
|
-
|
|
99
|
-
shellExec(`sudo sed -i 's/^SELINUX=enforcing$/SELINUX=permissive/' /etc/selinux/config`);
|
|
100
|
-
shellExec(`sudo systemctl enable --now docker`);
|
|
101
|
-
shellExec(`sudo systemctl enable --now kubelet`);
|
|
102
|
-
shellExec(`containerd config default > /etc/containerd/config.toml`);
|
|
103
|
-
shellExec(`sed -i -e "s/SystemdCgroup = false/SystemdCgroup = true/g" /etc/containerd/config.toml`);
|
|
104
|
-
// shellExec(`cp /etc/kubernetes/admin.conf ~/.kube/config`);
|
|
105
|
-
// shellExec(`sudo systemctl restart kubelet`);
|
|
106
|
-
shellExec(`sudo service docker restart`);
|
|
107
|
-
shellExec(`sudo systemctl enable --now containerd.service`);
|
|
108
|
-
shellExec(`sudo swapoff -a; sudo sed -i '/swap/d' /etc/fstab`);
|
|
109
|
-
shellExec(`sudo systemctl daemon-reload`);
|
|
110
|
-
shellExec(`sudo systemctl restart containerd`);
|
|
104
|
+
UnderpostCluster.API.config();
|
|
111
105
|
if (options.kubeadm === true) {
|
|
112
|
-
shellExec(`sysctl net.bridge.bridge-nf-call-iptables=1`);
|
|
113
106
|
shellExec(
|
|
114
107
|
`sudo kubeadm init --pod-network-cidr=192.168.0.0/16 --control-plane-endpoint="${os.hostname()}:6443"`,
|
|
115
108
|
);
|
|
116
|
-
|
|
117
|
-
shellExec(`sudo -E cp -i /etc/kubernetes/admin.conf ~/.kube/config`);
|
|
118
|
-
shellExec(`sudo -E chown $(id -u):$(id -g) ~/.kube/config`);
|
|
109
|
+
UnderpostCluster.API.chown();
|
|
119
110
|
// https://docs.tigera.io/calico/latest/getting-started/kubernetes/quickstart
|
|
120
111
|
shellExec(
|
|
121
112
|
`sudo kubectl create -f https://raw.githubusercontent.com/projectcalico/calico/v3.29.3/manifests/tigera-operator.yaml`,
|
|
@@ -133,6 +124,7 @@ class UnderpostCluster {
|
|
|
133
124
|
if (options.full === true || options.dedicatedGpu === true) {
|
|
134
125
|
// https://kubernetes.io/docs/tasks/manage-gpus/scheduling-gpus/
|
|
135
126
|
shellExec(`cd ${underpostRoot}/manifests && kind create cluster --config kind-config-cuda.yaml`);
|
|
127
|
+
UnderpostCluster.API.chown();
|
|
136
128
|
} else {
|
|
137
129
|
shellExec(
|
|
138
130
|
`cd ${underpostRoot}/manifests && kind create cluster --config kind-config${
|
|
@@ -140,7 +132,6 @@ class UnderpostCluster {
|
|
|
140
132
|
}.yaml`,
|
|
141
133
|
);
|
|
142
134
|
}
|
|
143
|
-
shellExec(`sudo chown $(id -u):$(id -g) $HOME/.kube/config**`);
|
|
144
135
|
}
|
|
145
136
|
} else logger.warn('Cluster already initialized');
|
|
146
137
|
|
|
@@ -288,6 +279,26 @@ class UnderpostCluster {
|
|
|
288
279
|
shellExec(`sudo kubectl apply -f ${underpostRoot}/manifests/${letsEncName}.yaml`);
|
|
289
280
|
}
|
|
290
281
|
},
|
|
282
|
+
|
|
283
|
+
config() {
|
|
284
|
+
shellExec(`sudo setenforce 0`);
|
|
285
|
+
shellExec(`sudo sed -i 's/^SELINUX=enforcing$/SELINUX=permissive/' /etc/selinux/config`);
|
|
286
|
+
shellExec(`sudo systemctl enable --now docker`);
|
|
287
|
+
shellExec(`sudo systemctl enable --now kubelet`);
|
|
288
|
+
shellExec(`containerd config default > /etc/containerd/config.toml`);
|
|
289
|
+
shellExec(`sed -i -e "s/SystemdCgroup = false/SystemdCgroup = true/g" /etc/containerd/config.toml`);
|
|
290
|
+
shellExec(`sudo service docker restart`);
|
|
291
|
+
shellExec(`sudo systemctl enable --now containerd.service`);
|
|
292
|
+
shellExec(`sudo swapoff -a; sudo sed -i '/swap/d' /etc/fstab`);
|
|
293
|
+
shellExec(`sudo systemctl daemon-reload`);
|
|
294
|
+
shellExec(`sudo systemctl restart containerd`);
|
|
295
|
+
shellExec(`sysctl net.bridge.bridge-nf-call-iptables=1`);
|
|
296
|
+
},
|
|
297
|
+
chown() {
|
|
298
|
+
shellExec(`mkdir -p ~/.kube`);
|
|
299
|
+
shellExec(`sudo -E cp -i /etc/kubernetes/admin.conf ~/.kube/config`);
|
|
300
|
+
shellExec(`sudo -E chown $(id -u):$(id -g) ~/.kube/config`);
|
|
301
|
+
},
|
|
291
302
|
// This function performs a comprehensive reset of Kubernetes and container environments
|
|
292
303
|
// on the host machine. Its primary goal is to clean up cluster components, temporary files,
|
|
293
304
|
// and container data, ensuring a clean state for re-initialization or fresh deployments,
|
package/src/cli/deploy.js
CHANGED
|
@@ -82,13 +82,13 @@ spec:
|
|
|
82
82
|
containers:
|
|
83
83
|
- name: ${deployId}-${env}-${suffix}
|
|
84
84
|
image: localhost/debian-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}"
|
|
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
|
package/src/cli/index.js
CHANGED
|
@@ -112,6 +112,9 @@ program
|
|
|
112
112
|
.option('--info-capacity-pod', 'display current machine capacity pod info')
|
|
113
113
|
.option('--pull-image', 'Set optional pull associated image')
|
|
114
114
|
.option('--init-host', 'Install k8s node necessary cli env: kind, kubeadm, docker, podman, helm')
|
|
115
|
+
.option('--config', 'Set k8s base node config')
|
|
116
|
+
.option('--worker', 'Set worker node context')
|
|
117
|
+
.option('--chown', 'Set k8s kube chown')
|
|
115
118
|
.action(Underpost.cluster.init)
|
|
116
119
|
.description('Manage cluster, for default initialization base kind cluster');
|
|
117
120
|
|
|
@@ -275,6 +278,7 @@ program
|
|
|
275
278
|
.option('--dev', 'Set dev context env')
|
|
276
279
|
.option('--create-virtual-network', 'Create lxd virtual network bridge')
|
|
277
280
|
.option('--create-admin-profile', 'Create admin profile for lxd management')
|
|
281
|
+
.option('--control', 'set control node vm context')
|
|
278
282
|
.option('--create-vm <vm-id>', 'Create default virtual machines')
|
|
279
283
|
.option('--init-vm <vm-id>', 'Get init vm underpost script')
|
|
280
284
|
.option('--info-vm <vm-id>', 'Get all info vm')
|
package/src/cli/lxd.js
CHANGED
|
@@ -10,7 +10,9 @@ class UnderpostLxd {
|
|
|
10
10
|
dev: false,
|
|
11
11
|
install: false,
|
|
12
12
|
createVirtualNetwork: false,
|
|
13
|
-
|
|
13
|
+
control: false,
|
|
14
|
+
worker: false,
|
|
15
|
+
initVm: '',
|
|
14
16
|
createVm: '',
|
|
15
17
|
infoVm: '',
|
|
16
18
|
rootSize: '',
|
|
@@ -51,7 +53,13 @@ ipv6.address=none`);
|
|
|
51
53
|
);
|
|
52
54
|
}
|
|
53
55
|
if (options.initVm && typeof options.initVm === 'string') {
|
|
54
|
-
|
|
56
|
+
let flag = '';
|
|
57
|
+
if (options.control === true) {
|
|
58
|
+
flag = ' -s -- --kubeadm';
|
|
59
|
+
} else if (options.worker == true) {
|
|
60
|
+
flag = ' -s -- --worker';
|
|
61
|
+
}
|
|
62
|
+
pbcopy(`cat ${underpostRoot}/manifests/lxd/underpost-setup.sh | lxc exec ${options.initVm} -- bash${flag}`);
|
|
55
63
|
}
|
|
56
64
|
if (options.infoVm && typeof options.infoVm === 'string') {
|
|
57
65
|
shellExec(`lxc config show ${options.infoVm}`);
|