-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathbootstrap.sh
executable file
·133 lines (112 loc) · 3.97 KB
/
bootstrap.sh
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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
#!/usr/bin/env bash
## desc: bootstrap a cluster-api environment for openstack
## license: Apache-2.0
# Source proxy settings:
. /etc/profile.d/proxy.sh
# Find helper scripts
export PATH=$PATH:~/bin
# Need yaml parsing capabilities
# flatpak remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo
if type snap >/dev/null 2>&1; then
sudo snap install yq
else
ARCH=`uname -m`
if test "$ARCH" = "x86_64"; then ARCH=amd64; fi
# FIXME: CHECK SIGNATURE
curl -LO https://github.com/mikefarah/yq/releases/download/v4.40.7/yq_linux_$ARCH
chmod +x yq_linux_$ARCH
sudo mv yq_linux_$ARCH /usr/local/bin/yq
fi
# Source global settings
test -r ~/.capi-settings && source ~/.capi-settings
# Prepare OpenStack
prepare_openstack.sh
# Start image registration early, so it can proceed in the background
upload_capi_image.sh
## install tools and utils at local account
# install kubectl
sudo apt-get install --no-install-recommends --no-install-suggests -y binutils jq
if type snap >/dev/null 2>&1; then
sudo snap install kubectl --classic
sudo snap install kustomize
else
sudo apt-get install --no-install-recommends --no-install-suggests -y apt-transport-https ca-certificates curl gnupg2
# FIXME: CHECK SIGNATURE
KUBECTLVER=v1.28
curl -fsSL https://pkgs.k8s.io/core:/stable:/$KUBECTLVER/deb/Release.key | sudo gpg --dearmor -o /etc/apt/keyrings/kubernetes-apt-keyring.gpg
#sudo mkdir -m 755 /etc/apt/keyrings
echo "deb [signed-by=/etc/apt/keyrings/kubernetes-apt-keyring.gpg] https://pkgs.k8s.io/core:/stable:/$KUBECTLVER/deb/ /" | sudo tee /etc/apt/sources.list.d/kubernetes.list
sudo apt-get update
sudo apt-get install -y kubectl
# FIXME: CHECK SIGNATURE
KUSTVER=v5.3.0
curl -L https://github.com/kubernetes-sigs/kustomize/releases/download/kustomize/$KUSTVER/kustomize_${KUSTVER}_linux_amd64.tar.gz | tar xvz
#chmod +x kustomize
sudo mv kustomize /usr/local/bin/
fi
install_kube_ps1.sh
# setup aliases and environment
echo "# setup environment"
cat <<EOF >> ~/.bash_aliases
export PATH=\$PATH:~/bin
# kubernetes-cli
alias k=kubectl
source <( kubectl completion bash | sed 's# kubectl\$# k kubectl\$#' )
source <( kubectl completion bash )
# clusterctl
source <( clusterctl completion bash )
# kube_ps1
source ~/.kube-ps1/kube-ps1.sh
# Error code in prompt
PS1="\${PS1%\\\\\$ } \\\$(kube_ps1) [\\\$?]\\\$ "
# We may do git commits and nano feels unusual ...
export VISUAL=/usr/bin/vim
# clusterctl beta features
export CLUSTER_TOPOLOGY=true
export EXP_CLUSTER_RESOURCE_SET=true
# CSO settings
export GIT_PROVIDER_B64=$(echo -n "github" | base64 -w0)
export GIT_ORG_NAME_B64=$(echo -n "SovereignCloudStack" | base64 -w0)
export GIT_REPOSITORY_NAME_B64=$(echo -n "cluster-stacks" | base64 -w0)
# export GIT_ACCESS_TOKEN_B64=\$(echo -n "\$GIT_ACCESS_TOKEN" | base64 -w0)
# eof
EOF
# openstack completion
openstack complete > ~/.bash_openstack 2>/dev/null
echo -e "#openstack complete\nsource ~/.bash_openstack" >> ~/.bash_aliases
# set inputrc set tab once
cat <<EOF > .inputrc
# set tab once
set show-all-if-ambiguous on
# alternate mappings for "page up" and "page down" to search the history
"\e[5~": history-search-backward
"\e[6~": history-search-forward
EOF
install_kind.sh
install_helm.sh
deploy_cluster_api.sh
install_k9s.sh
get_capi_helm.sh
install_kubectx.sh
# install Flux CLI always - regardless of deploy_flux variable(it can be used only for version change)
DEPLOY_FLUX=`yq eval '.DEPLOY_FLUX' ~/cluster-defaults/clusterctl.yaml`
if test "$DEPLOY_FLUX" = "true" -o "$DEPLOY_FLUX" = "false"; then
FLUX_VERSION="2.2.3"
else
FLUX_VERSION="${DEPLOY_FLUX:1}"
fi
install_flux.sh $FLUX_VERSION
#git clone https://github.com/Pharb/kubernetes-iperf3.git
CONTROLLERS=`yq eval '.CONTROL_PLANE_MACHINE_COUNT' ~/cluster-defaults/clusterctl.yaml`
export TESTCLUSTER=${1:-$TESTCLUSTER}
if test "$CONTROLLERS" != "0"; then
create_cluster.sh $TESTCLUSTER
fi
# Extensions
cd extension
for script in $(find ./ -name '*.sh' | sort)
do
echo executing $script
bash $script
done
# eof