forked from platform9/cluster-api-provider-bringyourownhost
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfigure-byoh-host.sh
More file actions
executable file
·59 lines (49 loc) · 1.76 KB
/
Copy pathconfigure-byoh-host.sh
File metadata and controls
executable file
·59 lines (49 loc) · 1.76 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
#!/usr/bin/env bash
#
# configure-byoh-host.sh — enable the kernel/network prerequisites kubeadm needs
# on a BYO host, applied over SSH against a target VM.
#
# When the workload cluster runs on a single machine, the privileged byoh/node
# containers mount /lib/modules:ro and share the host kernel, so the host must
# have the overlay + br_netfilter modules and the bridge-netfilter / ip_forward
# sysctls loaded. The same script preps a standalone BYO host VM.
#
# The commands that run on the target live in configure-byoh-host-remote.sh (a
# sibling file) so they can be linted independently; this script just pipes that
# file to the host over SSH.
#
# Usage:
# hack/configure-byoh-host.sh <VM_IP>
#
# SSH user defaults to "ubuntu"; override with BYOH_SSH_USER.
# Assumes passwordless sudo on the target.
set -Eeuo pipefail
shopt -s nullglob
SSH_USER=${BYOH_SSH_USER:-ubuntu}
log() { printf '%s %s\n' "$(date -u +%FT%TZ)" "$*"; }
usage() {
cat >&2 <<'EOF'
Usage: configure-byoh-host.sh <VM_IP>
Loads overlay + br_netfilter and sets the kubeadm-required sysctls on the
target host over SSH, persisting both across reboot. Idempotent.
SSH user defaults to "ubuntu" (override with BYOH_SSH_USER).
EOF
}
main() {
if [[ $# -ne 1 || "$1" == "-h" || "$1" == "--help" ]]; then
usage
exit 1
fi
local vm_ip="$1"
local script_dir remote_file
script_dir=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
remote_file="${script_dir}/configure-byoh-host-remote.sh"
[[ -f "$remote_file" ]] || {
log "remote script not found: ${remote_file}"
exit 1
}
log "configuring byoh host prerequisites on ${SSH_USER}@${vm_ip}"
ssh "${SSH_USER}@${vm_ip}" 'bash -s' <"$remote_file"
log "done on ${vm_ip}: overlay/br_netfilter loaded, sysctls applied and persisted"
}
main "$@"