Fix Copy Artifacts stage in stage3 in case that tree fails 73/14373/1 v12.0
authorgarciadeblas <gerardo.garciadeblas@telefonica.com>
Mon, 13 May 2024 06:46:55 +0000 (08:46 +0200)
committergarciadeblas <gerardo.garciadeblas@telefonica.com>
Mon, 13 May 2024 06:47:30 +0000 (08:47 +0200)
Change-Id: I96b4dd28a8df5374ec0990790a5d69d7fc06fe3a
Signed-off-by: garciadeblas <gerardo.garciadeblas@telefonica.com>
installers/install_docker_ce.sh
installers/install_kubeadm_cluster.sh
jenkins/ci-pipelines/ci_stage_3.groovy

index 9d6387f..750cdb3 100755 (executable)
@@ -70,6 +70,15 @@ EOF"
         sudo service docker restart
         echo "... restarted Docker service again"
     fi
+
+    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 service containerd restart
+    fi
+
     [ -z "${DEBUG_INSTALL}" ] || ! echo "File: /etc/docker/daemon.json" || cat /etc/docker/daemon.json
     sg docker -c "docker version" || FATAL "Docker installation failed"
     echo "... Docker CE installation done"
index 70f6d9d..babf17c 100755 (executable)
 
 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.23.3-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}
-    cat << EOF | sudo tee -a /etc/default/kubelet
-    KUBELET_EXTRA_ARGS="--cgroup-driver=cgroupfs"
-EOF
+    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
 }
 
@@ -71,8 +75,9 @@ 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}')
+    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
 }
@@ -81,7 +86,6 @@ function taint_master_node() {
 #Helm releases can be found here: https://github.com/helm/helm/releases
 function install_helm() {
     [ -z "${DEBUG_INSTALL}" ] || DEBUG beginning of function
-    HELM_VERSION="v3.7.2"
     if ! [[ "$(helm version --short 2>/dev/null)" =~ ^v3.* ]]; then
         # Helm is not installed. Install helm
         echo "Helm3 is not installed, installing ..."
index 9d5a6e4..0102e2f 100644 (file)
@@ -216,10 +216,9 @@ node("${params.NODE}") {
         stage('Copy Artifacts') {
             // cleanup any previous repo
             println("Logging system info before deleting repo.")
-            sh("pwd")
-            sh("tree -fD repo")
-            println("Trying to delete previous repo...")
-            sh("rm -rfv repo")
+            sh "tree -fD repo || exit 0"
+            sh 'rm -rvf repo'
+            sh "tree -fD repo && lsof repo || exit 0"
             dir('repo') {
                 packageList = []
                 dir("${RELEASE}") {