-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup-host.sh
More file actions
92 lines (72 loc) · 2.49 KB
/
Copy pathsetup-host.sh
File metadata and controls
92 lines (72 loc) · 2.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#!/usr/bin/env bash
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
source "$SCRIPT_DIR/lib/common.sh"
require_root
KIND_VERSION="v0.23.0"
KUBECTL_VERSION="v1.30.3"
install_packages() {
log "Installing podman and podman-docker..."
dnf install -y podman podman-docker
}
install_kind() {
if command -v kind > /dev/null 2>&1; then
log "kind already installed ($(kind version | head -n1)), skipping."
return
fi
log "Installing kind ${KIND_VERSION}..."
curl -fLo /usr/local/bin/kind \
"https://kind.sigs.k8s.io/dl/${KIND_VERSION}/kind-linux-amd64"
chmod +x /usr/local/bin/kind
}
install_kubectl() {
if command -v kubectl >/dev/null 2>&1; then
log "kubectl already installed, skipping."
return
fi
log "Installing kubectl ${KUBECTL_VERSION}..."
local tmpdir
tmpdir="$(mktemp -d)"
curl -fLo "$tmpdir/kubectl" \
"https://dl.k8s.io/release/${KUBECTL_VERSION}/bin/linux/amd64/kubectl"
curl -fLo "$tmpdir/kubectl.sha256" \
"https://dl.k8s.io/release/${KUBECTL_VERSION}/bin/linux/amd64/kubectl.sha256"
(cd "$tmpdir" && echo "$(cat kubectl.sha256) kubectl" | sha256sum -c -)
install -m 0755 "$tmpdir/kubectl" /usr/local/bin/kubectl
rm -rf "$tmpdir"
}
verify_cgroup_v2() {
local fstype
fstype="$(stat -fc %T /sys/fs/cgroup)"
if [[ "$fstype" != "cgroup2fs" ]]; then
die "ERROR: cgroupv2 is not active (found $fstype). Rootless Podman and per-user resource limits require it."
fi
log "cgroupv2 confirmed active"
}
verify_user_delegation() {
local delegate
delegate="$(systemctl show user@.service -p Delegate --value 2>/dev/null || echo "Unknown")"
if [[ "$delegate" == "yes" ]]; then
log "systemd delegates controllers to user session (Delegate=yes)"
else
log "WARNING: could not confirm controller delegation to user session (Delegate=$delegate). Resource limits in add-user.sh may not be enforced correctly."
fi
}
create_clubmembers_group() {
if getent group clubmembers >/dev/null; then
log "Group 'clubmembers' already exists, skipping."
else
log "Creating group 'clubmembers'..."
groupadd clubmembers
fi
}
install_packages
install_kind
install_kubectl
verify_cgroup_v2
verify_user_delegation
create_clubmembers_group
log "Host setup complete."
log "podman: $(podman --version)"
log "kubectl: $(kubectl version --client 2>/dev/null | head -n1)"
log "kind: $(kind version | head -n1)"