-
Notifications
You must be signed in to change notification settings - Fork 0
/
run_after_30-setup-kubernetes.sh.tmpl
69 lines (58 loc) · 1.76 KB
/
run_after_30-setup-kubernetes.sh.tmpl
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
{{- if (eq .chezmoi.os "darwin") -}}
#!/bin/bash
# Step 1: Check if ~/code/home-ops doesn't exist. If it does, skip cloning.
if [ ! -d "$HOME/code/home-ops" ]; then
# Step 2: Clone the repository to $HOME/code/home-ops
git clone -q [email protected]:adampetrovic/home-ops.git "$HOME/code/home-ops"
fi
# Step 3: Run talhelper to generate config
if [ ! -f "$HOME/.talos/config" ]; then
cd $HOME/code/home-ops/kubernetes/bootstrap/talos
SOPS_AGE_KEY_FILE=$HOME/.config/sops/age/keys.txt talhelper genconfig --no-gitignore -o /tmp >/dev/null
# Step 4: Move talosconfig to ~/.talos/config and delete /tmp/*.yaml
mkdir -p ~/.talos
mv /tmp/talosconfig $HOME/.talos/config
rm /tmp/*.yaml
# Step 5: Test the command `talosctl time` runs and exits correctly
if ! talosctl time >/dev/null 2>&1; then
echo "talosctl command failed. setup manually"
exit 1
fi
else
echo "talosctl already setup. skipping..."
fi
# Step 6: Run talosctl to generate kubeconfig
if [ ! -f "$HOME/.kube/config" ]; then
talosctl kubeconfig -n 10.0.80.10 ~/.kube/config
if ! kubectl get nodes >/dev/null 2>&1; then
echo "kubectl command failed. setup manually"
exit 1
fi
else
echo "kubectl already setup. skipping..."
fi
if kubectl krew >/dev/null 2>&1; then
krew_indexes=(
"netshoot https://github.com/nilic/kubectl-netshoot.git"
)
for idx in "${krew_indexes[@]}"
do
kubectl krew index add ${idx}
done
krew_pkgs=(
"autons"
"clog"
"cnpg"
"images"
"klock"
"ktop"
"netshoot/netshoot"
"oomd"
"restart"
"rook-ceph"
"sick-pods"
"view-secret"
)
kubectl krew install ${krew_pkgs[@]}
fi
{{- end -}}