From 80b2e177597d4d66afa568837aa58e0064f1a9d5 Mon Sep 17 00:00:00 2001 From: garciadeblas Date: Thu, 1 Jun 2023 18:38:13 +0200 Subject: [PATCH] Update installer for Ubuntu22 and K8s 1.26.5 Change-Id: I3b39c6b63c06847f42376ec6e8493d2085429986 Signed-off-by: garciadeblas --- installers/full_install_osm.sh | 8 +-- installers/install_docker_ce.sh | 59 +++++++++-------------- installers/install_kubeadm_cluster.sh | 67 ++++++++++++++------------ jenkins/ci-pipelines/ci_stage_2.groovy | 2 +- jenkins/ci-pipelines/ci_stage_3.groovy | 2 +- 5 files changed, 66 insertions(+), 72 deletions(-) diff --git a/installers/full_install_osm.sh b/installers/full_install_osm.sh index 9497fd49..8f092fb8 100755 --- a/installers/full_install_osm.sh +++ b/installers/full_install_osm.sh @@ -180,16 +180,16 @@ function install_osmclient(){ key_location=$CLIENT_REPOSITORY_BASE/$CLIENT_RELEASE/$CLIENT_REPOSITORY_KEY curl $key_location | sudo APT_KEY_DONT_WARN_ON_DANGEROUS_USAGE=1 apt-key add - sudo add-apt-repository -y "deb [arch=amd64] $CLIENT_REPOSITORY_BASE/$CLIENT_RELEASE $CLIENT_REPOSITORY osmclient IM" - sudo apt-get update - sudo apt-get install -y python3-pip + sudo apt-get -y update + sudo DEBIAN_FRONTEND=noninteractive apt-get install -y python3-pip sudo -H LC_ALL=C python3 -m pip install -U pip sudo -H LC_ALL=C python3 -m pip install -U python-magic pyangbind verboselogs - sudo apt-get install -y python3-osm-im python3-osmclient + sudo DEBIAN_FRONTEND=noninteractive apt-get install -y python3-osm-im python3-osmclient if [ -f /usr/lib/python3/dist-packages/osm_im/requirements.txt ]; then python3 -m pip install -r /usr/lib/python3/dist-packages/osm_im/requirements.txt fi if [ -f /usr/lib/python3/dist-packages/osmclient/requirements.txt ]; then - sudo apt-get install -y libcurl4-openssl-dev libssl-dev libmagic1 + sudo DEBIAN_FRONTEND=noninteractive apt-get install -y libcurl4-openssl-dev libssl-dev libmagic1 python3 -m pip install -r /usr/lib/python3/dist-packages/osmclient/requirements.txt fi [ -z "$INSTALL_LIGHTWEIGHT" ] && export OSM_HOSTNAME=`lxc list | awk '($2=="SO-ub"){print $6}'` diff --git a/installers/install_docker_ce.sh b/installers/install_docker_ce.sh index 5c0cc6d3..e5c2f44d 100755 --- a/installers/install_docker_ce.sh +++ b/installers/install_docker_ce.sh @@ -18,37 +18,24 @@ set +eux function install_docker_ce() { # installs and configures Docker CE [ -z "${DEBUG_INSTALL}" ] || DEBUG beginning of function + echo "Removing previous installation of docker ..." + for pkg in docker.io docker-doc docker-compose podman-docker containerd runc; do sudo apt-get remove $pkg; done echo "Installing Docker CE ..." - sudo apt-get -qq update - sudo apt-get install -y apt-transport-https ca-certificates software-properties-common - curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo APT_KEY_DONT_WARN_ON_DANGEROUS_USAGE=1 apt-key add - - sudo add-apt-repository -y "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" - sudo apt-get -qq update + sudo apt-get -y update + sudo apt-get install -y apt-transport-https ca-certificates software-properties-common gnupg + sudo install -m 0755 -d /etc/apt/keyrings + curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg + sudo chmod a+r /etc/apt/keyrings/docker.gpg + echo "deb [arch="$(dpkg --print-architecture)" signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \ + "$(. /etc/os-release && echo "$VERSION_CODENAME")" stable" | \ + sudo tee /etc/apt/sources.list.d/docker.list > /dev/null + sudo apt-get -y update sudo apt-get install -y docker-ce -# echo "Reconfiguring Docker to use systemd as cgroup driver" -# if [ ! -f /etc/docker/daemon.json ]; then -# sudo bash -c "cat < /etc/docker/daemon.json -#{ -# \"exec-opts\": [\"native.cgroupdriver=systemd\"], -# \"log-driver\": \"json-file\", -# \"log-opts\": { -# \"max-size\": \"100m\" -# }, -# \"storage-driver\": \"overlay2\" -#} -#EOF" -# else -# sudo sed -i "s|native.cgroupdriver=cgroupfs|native.cgroupdriver=systemd|" /etc/docker/daemon.json -# fi + echo "Adding user to group 'docker'" sudo groupadd -f docker sudo usermod -aG docker $USER - sleep 2 - #sudo systemctl enable docker - #sudo systemctl daemon-reload - #sudo systemctl restart docker - sudo service docker restart - echo "... restarted Docker service" + if [ -n "${DOCKER_PROXY_URL}" ]; then echo "Configuring docker proxy ..." if [ -f /etc/docker/daemon.json ]; then @@ -83,24 +70,24 @@ Environment=\"NO_PROXY=${NO_PROXY}\" EOF" fi if [ -n "${DOCKER_PROXY_URL}" ] || [ -n "${OSM_BEHIND_PROXY}" ] ; then - #sudo systemctl enable docker sudo systemctl daemon-reload - #sudo systemctl restart docker - sudo service docker restart - echo "... restarted Docker service again" + sudo systemctl restart docker + echo "... restarted Docker service" fi + echo "Configuring containerd to expose CRI, use systemd cgroup and use DOCKER_PROXY_URL as registry mirror" + sudo mv /etc/containerd/config.toml /etc/containerd/config.toml.orig 2>/dev/null + sudo bash -c "containerd config default > /etc/containerd/config.toml" + sudo sed -i 's/SystemdCgroup = false/SystemdCgroup = true/' /etc/containerd/config.toml if [ -n "${DOCKER_PROXY_URL}" ]; then - echo "Configuring containerd" - sudo mv /etc/containerd/config.toml /etc/containerd/config.toml.orig 2>/dev/null - sudo bash -c "containerd config default > /etc/containerd/config.toml" sudo sed -i "s#\[plugins.\"io.containerd.grpc.v1.cri\".registry.mirrors\]#\[plugins.\"io.containerd.grpc.v1.cri\".registry.mirrors\]\n \[plugins.\"io.containerd.grpc.v1.cri\".registry.mirrors.\"docker.io\"\]\n endpoint = \[\"${DOCKER_PROXY_URL}\"\]\n \[plugins.\"io.containerd.grpc.v1.cri\".registry.mirrors.\"registry.hub.docker.com\"]\n endpoint = \[\"${DOCKER_PROXY_URL}\"]#" /etc/containerd/config.toml - sudo diff /etc/containerd/config.toml.orig /etc/containerd/config.toml - sudo service containerd restart fi + sudo systemctl restart containerd [ -z "${DEBUG_INSTALL}" ] || ! echo "File: /etc/docker/daemon.json" || cat /etc/docker/daemon.json - sg docker -c "docker version" || FATAL "Docker installation failed" + echo "Testing Docker CE installation ..." + sg docker -c "docker version" || FATAL_TRACK docker_ce "Docker installation failed. Cannot run docker version" + sg docker -c "docker run --rm hello-world" || FATAL_TRACK docker_ce "Docker installation failed. Cannot run hello-world" echo "... Docker CE installation done" [ -z "${DEBUG_INSTALL}" ] || DEBUG end of function return 0 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 diff --git a/jenkins/ci-pipelines/ci_stage_2.groovy b/jenkins/ci-pipelines/ci_stage_2.groovy index c3880b02..13714b90 100644 --- a/jenkins/ci-pipelines/ci_stage_2.groovy +++ b/jenkins/ci-pipelines/ci_stage_2.groovy @@ -266,7 +266,7 @@ def ci_pipeline(mdg,url_prefix,project,branch,refspec,revision,do_stage_3,artifa def downstream_params_stage_3 = [ string(name: 'GERRIT_BRANCH', value: "${branch}"), string(name: 'INSTALLER', value: "Default" ), - string(name: 'OPENSTACK_BASE_IMAGE', value: "ubuntu20.04" ), + string(name: 'OPENSTACK_BASE_IMAGE', value: "ubuntu22.04" ), string(name: 'UPSTREAM_JOB_NAME', value: "${JOB_NAME}" ), string(name: 'UPSTREAM_JOB_NUMBER', value: "${BUILD_NUMBER}" ), booleanParam(name: 'DO_STAGE_4', value: do_stage_4 ) diff --git a/jenkins/ci-pipelines/ci_stage_3.groovy b/jenkins/ci-pipelines/ci_stage_3.groovy index 26f928b0..31eab9dc 100644 --- a/jenkins/ci-pipelines/ci_stage_3.groovy +++ b/jenkins/ci-pipelines/ci_stage_3.groovy @@ -31,7 +31,7 @@ properties([ string(defaultValue: 'artifactory-osm', description: '', name: 'ARTIFACTORY_SERVER'), string(defaultValue: 'osm-stage_4', description: '', name: 'DOWNSTREAM_STAGE_NAME'), string(defaultValue: 'testing-daily', description: '', name: 'DOCKER_TAG'), - string(defaultValue: 'ubuntu20.04', description: '', name: 'OPENSTACK_BASE_IMAGE'), + string(defaultValue: 'ubuntu22.04', description: '', name: 'OPENSTACK_BASE_IMAGE'), booleanParam(defaultValue: false, description: '', name: 'SAVE_CONTAINER_ON_FAIL'), booleanParam(defaultValue: false, description: '', name: 'SAVE_CONTAINER_ON_PASS'), booleanParam(defaultValue: true, description: '', name: 'SAVE_ARTIFACTS_ON_SMOKE_SUCCESS'), -- 2.17.1