X-Git-Url: https://osm.etsi.org/gitweb/?a=blobdiff_plain;f=installers%2Finstall_kubeadm_cluster.sh;h=6855d9f4caa4e3781e02944e45e879479b831cc5;hb=80b2e177597d4d66afa568837aa58e0064f1a9d5;hp=d57dec7fdfd4cb439e5d0e16a55c243045c05f22;hpb=b17abf76811b74f98bd5852d6ce4010a4acb680a;p=osm%2Fdevops.git diff --git a/installers/install_kubeadm_cluster.sh b/installers/install_kubeadm_cluster.sh index d57dec7f..6855d9f4 100755 --- a/installers/install_kubeadm_cluster.sh +++ b/installers/install_kubeadm_cluster.sh @@ -15,7 +15,7 @@ set +eux -K8S_VERSION=1.23.3-00 +K8S_VERSION=1.26.5-00 # installs kubernetes packages function install_kube() { @@ -23,16 +23,13 @@ function install_kube() { # 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 -y "deb https://apt.kubernetes.io/ kubernetes-xenial main" - sudo apt-get update + sudo apt-get -y update && sudo apt-get install -y apt-transport-https ca-certificates curl + sudo install -m 0755 -d /etc/apt/keyrings + curl -fsSL https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo gpg --dearmor -o /etc/apt/keyrings/kubernetes-archive-keyring.gpg + echo "deb [signed-by=/etc/apt/keyrings/kubernetes-archive-keyring.gpg] https://apt.kubernetes.io/ kubernetes-xenial main" | 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} - cat << EOF | sudo tee -a /etc/default/kubelet -KUBELET_EXTRA_ARGS="--cgroup-driver=cgroupfs" -EOF sudo apt-mark hold kubelet kubeadm kubectl [ -z "${DEBUG_INSTALL}" ] || DEBUG end of function } @@ -75,6 +72,7 @@ function kube_config_dir() { # test kubernetes installation function check_and_track_init_k8s() { [ -z "${DEBUG_INSTALL}" ] || DEBUG beginning of function + echo "Reading existing namespaces" kubectl get ns || FATAL_TRACK k8scluster "Failed getting namespaces" track k8scluster init_k8s_ok [ -z "${DEBUG_INSTALL}" ] || DEBUG end of function @@ -96,8 +94,8 @@ function deploy_cni_provider() { # 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}') - kubectl taint node $K8S_MASTER node-role.kubernetes.io/master:NoSchedule- + K8S_MASTER=$(kubectl get nodes | awk '$3~/control-plane/'| awk '{print $1; exit}') + kubectl taint node $K8S_MASTER node-role.kubernetes.io/control-plane:NoSchedule- sleep 5 [ -z "${DEBUG_INSTALL}" ] || DEBUG end of function } @@ -134,11 +132,8 @@ function install_helm() { function install_k8s_storageclass() { [ -z "${DEBUG_INSTALL}" ] || DEBUG beginning of function - echo "Installing open-iscsi" - sudo apt-get update - sudo apt-get install open-iscsi - sudo systemctl enable --now iscsid - OPENEBS_VERSION="3.1.0" + # Openebs versions can be found here: https://github.com/openebs/openebs/releases + OPENEBS_VERSION="3.7.0" echo "Installing OpenEBS" helm repo add openebs https://openebs.github.io/charts helm repo update @@ -170,17 +165,27 @@ function install_k8s_storageclass() { function install_helm_metallb() { [ -z "${DEBUG_INSTALL}" ] || DEBUG beginning of function echo "Installing MetalLB" - METALLB_VERSION="0.11.0" - METALLB_IP_RANGE="$DEFAULT_IP/32" - echo "configInline: - address-pools: - - name: default - protocol: layer2 - addresses: - - $METALLB_IP_RANGE" | sudo tee -a ${OSM_CLUSTER_WORK_DIR}/metallb-config.yaml + METALLB_VERSION="0.13.10" helm repo add metallb https://metallb.github.io/metallb helm repo update - helm install --create-namespace --namespace metallb-system metallb metallb/metallb --version ${METALLB_VERSION} -f ${OSM_CLUSTER_WORK_DIR}/metallb-config.yaml + helm install --create-namespace --namespace metallb-system metallb metallb/metallb --version ${METALLB_VERSION} + [ -z "${DEBUG_INSTALL}" ] || DEBUG end of function +} + +function configure_ipaddresspool_metallb() { + [ -z "${DEBUG_INSTALL}" ] || DEBUG beginning of function + echo "Creating IP address pool manifest: ${OSM_CLUSTER_WORK_DIR}/metallb-ipaddrpool.yaml" + METALLB_IP_RANGE="$DEFAULT_IP/32" + echo "apiVersion: metallb.io/v1beta1 +kind: IPAddressPool +metadata: + name: first-pool + namespace: metallb-system +spec: + addresses: + - ${METALLB_IP_RANGE}" | sudo tee -a ${OSM_CLUSTER_WORK_DIR}/metallb-ipaddrpool.yaml + echo "Applying IP address pool manifest: kubectl apply -f ${OSM_CLUSTER_WORK_DIR}/metallb-ipaddrpool.yaml" + kubectl apply -f ${OSM_CLUSTER_WORK_DIR}/metallb-ipaddrpool.yaml || FATAL_TRACK k8scluster "Cannot create IP address Pool in MetalLB" [ -z "${DEBUG_INSTALL}" ] || DEBUG end of function } @@ -229,8 +234,8 @@ function check_for_readiness() { # State of MetalLB METALLB_STATE=$(kubectl get pod -n ${METALLB_NAMESPACE} --no-headers 2>&1) - METALLB_READY=$(echo "${METALLB_STATE}" | awk '$2=="1/1" || $2=="2/2" {printf ("%s\t%s\t\n", $1, $2)}') - METALLB_NOT_READY=$(echo "${METALLB_STATE}" | awk '$2!="1/1" && $2!="2/2" {printf ("%s\t%s\t\n", $1, $2)}') + METALLB_READY=$(echo "${METALLB_STATE}" | awk '$2=="1/1" || $2=="4/4" {printf ("%s\t%s\t\n", $1, $2)}') + METALLB_NOT_READY=$(echo "${METALLB_STATE}" | awk '$2!="1/1" && $2!="4/4" {printf ("%s\t%s\t\n", $1, $2)}') COUNT_METALLB_READY=$(echo "${METALLB_READY}" | grep -v -e '^$' | wc -l) COUNT_METALLB_NOT_READY=$(echo "${METALLB_NOT_READY}" | grep -v -e '^$' | wc -l) @@ -300,7 +305,8 @@ function check_for_readiness() { #removes osm deployments and services function remove_k8s_namespace() { [ -z "${DEBUG_INSTALL}" ] || DEBUG beginning of function - kubectl delete ns $1 2>&1 >/dev/null + echo "Deleting existing namespace $1: kubectl delete ns $1" + kubectl delete ns $1 2>/dev/null [ -z "${DEBUG_INSTALL}" ] || DEBUG end of function } @@ -359,11 +365,12 @@ if [ -n "$INSTALL_K8S_MONITOR" ]; then track k8scluster uninstall_k8s_monitoring_ok fi -remove_k8s_namespace osm deploy_cni_provider taint_master_node check_and_track_k8s_ready_before_helm +remove_k8s_namespace osm + install_helm track k8scluster install_helm_ok @@ -375,4 +382,4 @@ install_helm_certmanager track k8scluster k8s_certmanager_ok check_for_readiness track k8scluster k8s_ready_ok - +configure_ipaddresspool_metallb