-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver-init.sh
More file actions
77 lines (69 loc) · 1.64 KB
/
server-init.sh
File metadata and controls
77 lines (69 loc) · 1.64 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
#!/bin/bash
exec >/tmp/output 2>&1
set -x
(
echo '#!/bin/sh'
echo ''
echo 'count=500'
echo 'file=/etc/rancher/rke2/rke2.yaml'
echo ''
echo 'while true'
echo 'do'
echo ''
echo ' if [ -f ${file} ]'
echo ' then'
echo ' break'
echo ' fi'
echo ''
echo ' count=$(($count - 1))'
echo ''
echo ' if [ $count -lt 1 ]'
echo ' then'
echo ' echo Failed to get kubeconfig 1>&2'
echo ' exit 1'
echo ' fi'
echo ''
echo ' sleep 1'
echo ''
echo 'done'
echo ''
echo 'count=100'
echo ''
echo 'while true'
echo 'do'
echo ''
echo ' /var/lib/rancher/rke2/bin/kubectl --kubeconfig ${file} get all >/dev/null 2>&1'
echo ' if [ $? -eq 0 ]'
echo ' then'
echo ' cat ${file}'
echo ' exit 0'
echo ' fi'
echo ''
echo ' count=$(($count - 1))'
echo ''
echo ' if [ $count -lt 1 ]'
echo ' then'
echo ' echo Failed to get working k8s 1>&2'
echo ' exit 1'
echo ' fi'
echo ''
echo ' sleep 1'
echo ''
echo 'done'
) > /usr/local/bin/wait-for-kubeconfig
chmod 755 /usr/local/bin/wait-for-kubeconfig
apt update
apt upgrade
apt install -y python3 python3-pip unzip python3-venv
pip install --break-system-packages awscli
curl -sfL https://get.rke2.io | sh -
(
echo 'write-kubeconfig-mode: "0644"'
echo 'token: %TOKEN%'
echo 'debug: true'
echo 'tls-san:'
echo " - %INTERNAL-ADDR%"
echo " - %EXTERNAL-ADDR%"
) > /etc/rancher/rke2/config.yaml
systemctl enable rke2-server
systemctl start rke2-server