-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun_after_30-setup-kubernetes.sh.tmpl
54 lines (44 loc) · 1.46 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
{{- 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 git@github.com: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_pkgs=(
"cnpg"
"klock"
"rook-ceph"
"sick-pods"
"view-secret"
)
kubectl krew install ${krew_pkgs[@]}
fi
{{- end -}}