mirror of
https://github.com/clearlinux/cloud-native-setup.git
synced 2026-08-19 05:27:26 +00:00
Compare commits
7 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 0e280f40fa | |||
| d31d78c193 | |||
| 04487a2cfe | |||
| e67630b0bd | |||
| e08c92f6d5 | |||
| d00a5ea9d8 | |||
| a9b3b5c506 |
@@ -50,14 +50,12 @@ master and also uses kubelet config via [`kubeadm.yaml`](kubeadm.yaml)
|
|||||||
to propagate cluster wide kubelet configuration to all workers. Customize it if
|
to propagate cluster wide kubelet configuration to all workers. Customize it if
|
||||||
you need to setup other cluster wide properties.
|
you need to setup other cluster wide properties.
|
||||||
|
|
||||||
There are two flavors of install -
|
There are different flavors to install, run `./create_stack.sh help` to get
|
||||||
|
more information.
|
||||||
* `minimal`: initialize cluster, add kata runtimeclass, install canal CNI and metrics server
|
|
||||||
* `all`: minimal, install rook storage, prometheus, ELK, nginx-ingress, etc.,
|
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
# default is 'all'
|
# default shows help
|
||||||
./create_stack.sh [minimal|all]
|
./create_stack.sh <subcommand>
|
||||||
```
|
```
|
||||||
|
|
||||||
## Join Workers to the cluster
|
## Join Workers to the cluster
|
||||||
|
|||||||
@@ -8,12 +8,23 @@ CUR_DIR=$(pwd)
|
|||||||
SCRIPT_DIR="$(dirname "${BASH_SOURCE[0]}")"
|
SCRIPT_DIR="$(dirname "${BASH_SOURCE[0]}")"
|
||||||
|
|
||||||
function print_usage_exit() {
|
function print_usage_exit() {
|
||||||
echo $"Usage: $0 [minimal|all]"
|
exit_code=${1:-0}
|
||||||
exit 1
|
cat <<EOT
|
||||||
|
Usage: $0 [subcommand]
|
||||||
|
|
||||||
|
Subcommands:
|
||||||
|
|
||||||
|
$(
|
||||||
|
for cmd in "${!command_handlers[@]}"; do
|
||||||
|
printf "\t%s:|\t%s\n" "${cmd}" "${command_help[${cmd}]:-Not-documented}"
|
||||||
|
done | sort | column -t -s "|"
|
||||||
|
)
|
||||||
|
EOT
|
||||||
|
exit "${exit_code}"
|
||||||
}
|
}
|
||||||
|
|
||||||
function finish() {
|
function finish() {
|
||||||
cd $CUR_DIR
|
cd "${CUR_DIR}"
|
||||||
}
|
}
|
||||||
trap finish EXIT
|
trap finish EXIT
|
||||||
|
|
||||||
@@ -22,10 +33,10 @@ function cluster_init() {
|
|||||||
#to enable the RuntimeClass featuregate
|
#to enable the RuntimeClass featuregate
|
||||||
sudo -E kubeadm init --config=./kubeadm.yaml
|
sudo -E kubeadm init --config=./kubeadm.yaml
|
||||||
|
|
||||||
rm -rf $HOME/.kube
|
rm -rf "${HOME}/.kube"
|
||||||
mkdir -p $HOME/.kube
|
mkdir -p "${HOME}/.kube"
|
||||||
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
|
sudo cp -i /etc/kubernetes/admin.conf "${HOME}/.kube/config"
|
||||||
sudo chown $(id -u):$(id -g) $HOME/.kube/config
|
sudo chown "$(id -u):$(id -g)" "${HOME}/.kube/config"
|
||||||
|
|
||||||
# If this an interactive terminal then wait for user to join workers
|
# If this an interactive terminal then wait for user to join workers
|
||||||
if [ -t 0 ]; then
|
if [ -t 0 ]; then
|
||||||
@@ -33,7 +44,7 @@ function cluster_init() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
#Ensure single node k8s works
|
#Ensure single node k8s works
|
||||||
if [ $(kubectl get nodes | wc -l) -eq 2 ]; then
|
if [ "$(kubectl get nodes | wc -l)" -eq 2 ]; then
|
||||||
kubectl taint nodes --all node-role.kubernetes.io/master-
|
kubectl taint nodes --all node-role.kubernetes.io/master-
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
@@ -109,20 +120,25 @@ function all() {
|
|||||||
miscellaneous
|
miscellaneous
|
||||||
}
|
}
|
||||||
|
|
||||||
cd $SCRIPT_DIR
|
declare -A command_handlers
|
||||||
if [[ "$#" -eq 0 ]]; then
|
command_handlers[init]=cluster_init
|
||||||
all
|
command_handlers[cni]=cni
|
||||||
exit
|
command_handlers[minimal]=minimal
|
||||||
fi
|
command_handlers[all]=all
|
||||||
|
command_handlers[help]=print_usage_exit
|
||||||
|
|
||||||
case "$1" in
|
declare -A command_help
|
||||||
minimal)
|
command_help[init]="Only inits a cluster using kubeadm"
|
||||||
minimal
|
command_help[cni]="Setup network for running cluster"
|
||||||
;;
|
command_help[minimal]="init + cni + kata + metrics"
|
||||||
all)
|
command_help[all]="minimal + storage + monitoring + miscellaneous"
|
||||||
all
|
command_help[help]="show this message"
|
||||||
;;
|
|
||||||
*)
|
cd "${SCRIPT_DIR}"
|
||||||
print_usage_exit
|
|
||||||
;;
|
cmd_handler=${command_handlers[${1:-none}]:-unimplemented}
|
||||||
esac
|
if [ "${cmd_handler}" != "unimplemented" ]; then
|
||||||
|
"${cmd_handler}"
|
||||||
|
else
|
||||||
|
print_usage_exit 1
|
||||||
|
fi
|
||||||
|
|||||||
@@ -1,7 +1,5 @@
|
|||||||
apiVersion: kubeadm.k8s.io/v1beta1
|
apiVersion: kubeadm.k8s.io/v1beta1
|
||||||
kind: InitConfiguration
|
kind: InitConfiguration
|
||||||
nodeRegistration:
|
|
||||||
criSocket: /var/run/crio/crio.sock
|
|
||||||
---
|
---
|
||||||
apiVersion: kubelet.config.k8s.io/v1beta1
|
apiVersion: kubelet.config.k8s.io/v1beta1
|
||||||
kind: KubeletConfiguration
|
kind: KubeletConfiguration
|
||||||
|
|||||||
@@ -3,7 +3,10 @@
|
|||||||
set -o nounset
|
set -o nounset
|
||||||
|
|
||||||
#Cleanup
|
#Cleanup
|
||||||
sudo -E kubeadm reset -f --cri-socket="/var/run/crio/crio.sock"
|
reset_cluster() {
|
||||||
|
sudo -E kubeadm reset -f
|
||||||
|
}
|
||||||
|
reset_cluster
|
||||||
|
|
||||||
for ctr in $(sudo crictl ps --quiet); do
|
for ctr in $(sudo crictl ps --quiet); do
|
||||||
sudo crictl stop "$ctr"
|
sudo crictl stop "$ctr"
|
||||||
@@ -15,9 +18,10 @@ for pod in $(sudo crictl pods --quiet); do
|
|||||||
done
|
done
|
||||||
|
|
||||||
#Forcefull cleanup all artifacts
|
#Forcefull cleanup all artifacts
|
||||||
#This is needed is things really go wrong
|
#This is needed if things really go wrong
|
||||||
sudo systemctl stop kubelet
|
sudo systemctl stop kubelet
|
||||||
sudo systemctl stop crio
|
systemctl is-active crio && sudo systemctl stop crio
|
||||||
|
systemctl is-active containerd && sudo systemctl stop containerd
|
||||||
sudo pkill -9 qemu
|
sudo pkill -9 qemu
|
||||||
sudo pkill -9 kata
|
sudo pkill -9 kata
|
||||||
sudo pkill -9 kube
|
sudo pkill -9 kube
|
||||||
@@ -39,8 +43,11 @@ sudo -E bash -c "rm -r /var/run/kata-containers/*"
|
|||||||
sudo rm -rf /var/lib/rook
|
sudo rm -rf /var/lib/rook
|
||||||
|
|
||||||
sudo systemctl daemon-reload
|
sudo systemctl daemon-reload
|
||||||
sudo systemctl enable kubelet crio
|
sudo systemctl is-active crio && sudo systemctl stop crio
|
||||||
sudo systemctl restart crio
|
sudo systemctl is-active containerd && sudo systemctl stop containerd
|
||||||
|
sudo systemctl is-enabled crio && sudo systemctl restart crio
|
||||||
|
sudo systemctl is-enabled containerd && sudo systemctl restart containerd
|
||||||
|
|
||||||
sudo systemctl restart kubelet
|
sudo systemctl restart kubelet
|
||||||
|
|
||||||
sudo -E kubeadm reset -f --cri-socket="/var/run/crio/crio.sock"
|
reset_cluster
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ sudo mkdir -p /etc/sysctl.d/
|
|||||||
cat <<EOT | sudo bash -c "cat > /etc/sysctl.d/60-k8s.conf"
|
cat <<EOT | sudo bash -c "cat > /etc/sysctl.d/60-k8s.conf"
|
||||||
net.ipv4.ip_forward=1
|
net.ipv4.ip_forward=1
|
||||||
net.ipv4.conf.default.rp_filter=1
|
net.ipv4.conf.default.rp_filter=1
|
||||||
|
net.ipv4.conf.all.rp_filter=1
|
||||||
EOT
|
EOT
|
||||||
sudo systemctl restart systemd-sysctl
|
sudo systemctl restart systemd-sysctl
|
||||||
|
|
||||||
@@ -51,8 +52,6 @@ sudo systemctl daemon-reload
|
|||||||
echo "The following kubelet command may complain... it is not an error"
|
echo "The following kubelet command may complain... it is not an error"
|
||||||
sudo systemctl enable --now kubelet crio || true
|
sudo systemctl enable --now kubelet crio || true
|
||||||
|
|
||||||
sudo mkdir -p /usr/libexec/cni /opt/cni
|
|
||||||
[ ! -e /opt/cni/bin/cni ] && sudo ln -s /usr/libexec/cni /opt/cni/bin
|
|
||||||
#Ensure that the system is ready without requiring a reboot
|
#Ensure that the system is ready without requiring a reboot
|
||||||
sudo swapoff -a
|
sudo swapoff -a
|
||||||
sudo systemctl restart systemd-modules-load.service
|
sudo systemctl restart systemd-modules-load.service
|
||||||
|
|||||||
Reference in New Issue
Block a user