set +eux
-#installs kubernetes packages
+K8S_VERSION=1.24
+K8S_PACKAGE_VERSION="$K8S_VERSION".17-1.1
+HELM_VERSION="v3.10.3"
+
+# installs kubernetes packages
function install_kube() {
[ -z "${DEBUG_INSTALL}" ] || DEBUG beginning of function
- K8S_VERSION=1.20.11-00
+ # Kubernetes releases can be found here: https://kubernetes.io/releases/
# To check other available versions, run the following command
# curl -s https://packages.cloud.google.com/apt/dists/kubernetes-xenial/main/binary-amd64/Packages | grep Version | awk '{print $2}'
- sudo apt-get update && sudo apt-get install -y apt-transport-https
- sudo apt-get update && sudo apt-get install -y apt-transport-https
- curl -fsSL https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add -
- sudo add-apt-repository "deb https://apt.kubernetes.io/ kubernetes-xenial main"
- sudo apt-get update
+ sudo mkdir /etc/apt/keyrings
+ sudo apt-get -y update && sudo apt-get install -y apt-transport-https ca-certificates curl
+ curl -fsSL https://pkgs.k8s.io/core:/stable:/v"$K8S_VERSION"/deb/Release.key | sudo gpg --dearmor -o /etc/apt/keyrings/kubernetes-apt-keyring.gpg
+ echo 'deb [signed-by=/etc/apt/keyrings/kubernetes-apt-keyring.gpg] https://pkgs.k8s.io/core:/stable:/v'$K8S_VERSION'/deb/ /' | sudo tee /etc/apt/sources.list.d/kubernetes.list
+ sudo apt-get -y update
echo "Installing Kubernetes Packages ..."
- sudo apt-get install -y kubelet=${K8S_VERSION} kubeadm=${K8S_VERSION} kubectl=${K8S_VERSION}
+ sudo apt-get install -y kubelet=${K8S_PACKAGE_VERSION} kubeadm=${K8S_PACKAGE_VERSION} kubectl=${K8S_PACKAGE_VERSION}
sudo apt-mark hold kubelet kubeadm kubectl
+
+ sudo rm /etc/containerd/config.toml
+ sudo systemctl restart containerd
+
[ -z "${DEBUG_INSTALL}" ] || DEBUG end of function
}
[ -z "${DEBUG_INSTALL}" ] || DEBUG beginning of function
CNI_DIR="$(mktemp -d -q --tmpdir "flannel.XXXXXX")"
trap 'rm -rf "${CNI_DIR}"' EXIT
- wget -q https://raw.githubusercontent.com/coreos/flannel/master/Documentation/kube-flannel.yml -P $CNI_DIR
+ wget --retry-on-host-error --retry-on-http-error 404,429,503 --tries=5 https://raw.githubusercontent.com/coreos/flannel/master/Documentation/kube-flannel.yml -P $CNI_DIR
+ [ ! -f $CNI_DIR/kube-flannel.yml ] && FATAL "Cannot Install Flannel because $CNI_DIR/kube-flannel.yml was not found. Maybe the file https://raw.githubusercontent.com/coreos/flannel/master/Documentation/kube-flannel.yml is temporarily not accessible"
kubectl apply -f $CNI_DIR
[ $? -ne 0 ] && FATAL "Cannot Install Flannel"
[ -z "${DEBUG_INSTALL}" ] || DEBUG end of function
#taints K8s master node
function taint_master_node() {
[ -z "${DEBUG_INSTALL}" ] || DEBUG beginning of function
- K8S_MASTER=$(kubectl get nodes | awk '$3~/master/'| awk '{print $1}')
+ K8S_MASTER=$(kubectl get nodes | awk '$3~/control-plane/'| awk '{print $1}')
kubectl taint node $K8S_MASTER node-role.kubernetes.io/master:NoSchedule-
+ kubectl taint node $K8S_MASTER node-role.kubernetes.io/control-plane:NoSchedule-
sleep 5
[ -z "${DEBUG_INSTALL}" ] || DEBUG end of function
}
#Install Helm v3
+#Helm releases can be found here: https://github.com/helm/helm/releases
function install_helm() {
[ -z "${DEBUG_INSTALL}" ] || DEBUG beginning of function
- helm > /dev/null 2>&1
- if [ $? != 0 ] ; then
+ if ! [[ "$(helm version --short 2>/dev/null)" =~ ^v3.* ]]; then
# Helm is not installed. Install helm
- echo "Helm is not installed, installing ..."
- curl https://get.helm.sh/helm-v3.6.3-linux-amd64.tar.gz --output helm-v3.6.3.tar.gz
- tar -zxvf helm-v3.6.3.tar.gz
+ echo "Helm3 is not installed, installing ..."
+ curl https://get.helm.sh/helm-${HELM_VERSION}-linux-amd64.tar.gz --output helm-${HELM_VERSION}.tar.gz
+ tar -zxvf helm-${HELM_VERSION}.tar.gz
sudo mv linux-amd64/helm /usr/local/bin/helm
rm -r linux-amd64
- rm helm-v3.6.3.tar.gz
- helm repo add stable https://charts.helm.sh/stable
- helm repo update
+ rm helm-${HELM_VERSION}.tar.gz
+ else
+ echo "Helm3 is already installed. Skipping installation..."
fi
+ helm repo add stable https://charts.helm.sh/stable
+ helm repo update
[ -z "${DEBUG_INSTALL}" ] || DEBUG end of function
}
function install_k8s_storageclass() {
[ -z "${DEBUG_INSTALL}" ] || DEBUG beginning of function
- OPENEBS_VERSION="1.12.0"
+ echo "Installing open-iscsi"
+ sudo apt-get update
+ sudo apt-get install open-iscsi
+ sudo systemctl enable --now iscsid
+ OPENEBS_VERSION="3.1.0"
echo "Installing OpenEBS"
helm repo add openebs https://openebs.github.io/charts
helm repo update
#removes osm deployments and services
function remove_k8s_namespace() {
[ -z "${DEBUG_INSTALL}" ] || DEBUG beginning of function
- kubectl delete ns $1
+ kubectl delete ns $1 2>&1 >/dev/null
[ -z "${DEBUG_INSTALL}" ] || DEBUG end of function
}
install_kube
-track install_k8s
+track k8scluster install_k8s_ok
init_kubeadm $OSM_DOCKER_WORK_DIR/cluster-config.yaml
kube_config_dir
-track init_k8s
+track k8scluster init_k8s_ok
if [ -n "$INSTALL_K8S_MONITOR" ]; then
# uninstall OSM MONITORING
uninstall_k8s_monitoring
- track uninstall_k8s_monitoring
+ track k8scluster uninstall_k8s_monitoring_ok
fi
#remove old namespace
remove_k8s_namespace osm
deploy_cni_provider
taint_master_node
install_helm
-track install_helm
+track k8scluster install_helm_ok
install_k8s_storageclass
-track k8s_storageclass
+track k8scluster k8s_storageclass_ok
install_helm_metallb
-track k8s_metallb
+track k8scluster k8s_metallb_ok
check_for_readiness
-track k8s_ready
+track k8scluster k8s_ready_ok