X-Git-Url: https://gerrit.fd.io/r/gitweb?p=csit.git;a=blobdiff_plain;f=resources%2Flibraries%2Fbash%2Fshell%2Fk8s_utils.sh;h=b96ec8df6c6bb78120cd261dba67b9dc22d8de05;hp=55d3d815c9fcf3998e55a90871e34cf061cde370;hb=6da5a6920171682bd5bf6a77517bedfef91cbd0e;hpb=0437095f4bf958154f25a3f163f432b22fcdc743 diff --git a/resources/libraries/bash/shell/k8s_utils.sh b/resources/libraries/bash/shell/k8s_utils.sh index 55d3d815c9..b96ec8df6c 100644 --- a/resources/libraries/bash/shell/k8s_utils.sh +++ b/resources/libraries/bash/shell/k8s_utils.sh @@ -1,5 +1,5 @@ #!/bin/bash -# Copyright (c) 2018 Cisco and/or its affiliates. +# Copyright (c) 2021 Cisco and/or its affiliates. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at: @@ -18,7 +18,7 @@ function k8s_utils.destroy { kubectl delete node $HOSTNAME # Revert any changes made to this host by 'kubeadm init' or 'kubeadm join' - sudo kubeadm reset && sudo rm -rf $HOME/.kube || \ + sudo kubeadm reset --force && sudo rm -rf $HOME/.kube || \ { echo "Failed to reset kubeadm"; exit 1; } } @@ -66,7 +66,8 @@ function k8s_utils.contiv_vpp_deploy { k8s_contiv_patch="kubecon.contiv-vpp-yaml-patch.diff" # Pull the most recent Docker images - bash <(curl -s https://raw.githubusercontent.com/contiv/vpp/master/k8s/pull-images.sh) + url="https://raw.githubusercontent.com/contiv/vpp/master/k8s/pull-images.sh" + bash <(curl -s "${url}") # Apply resources wget ${k8s_contiv} @@ -80,17 +81,21 @@ function k8s_utils.contiv_vpp_deploy { function k8s_utils.cri_shim_install { # Install the CRI Shim on host - sudo su root -c 'bash <(curl -s https://raw.githubusercontent.com/contiv/vpp/master/k8s/cri-install.sh)' + url"https://raw.githubusercontent.com/contiv/vpp/master/k8s/cri-install.sh" + sudo su root -c "bash <(curl -s '${url}')" } function k8s_utils.cri_shim_uninstall { # Uninstall the CRI Shim on host - sudo su root -c 'bash <(curl -s https://raw.githubusercontent.com/contiv/vpp/master/k8s/cri-install.sh) --uninstall' + url="https://raw.githubusercontent.com/contiv/vpp/master/k8s/cri-install.sh" + sudo su root -c "bash <(curl -s '${url}') --uninstall" } function k8s_utils.kube_proxy_install { # Installing custom version of Kube-Proxy to enable Kubernetes services - bash <(curl -s https://raw.githubusercontent.com/contiv/vpp/master/k8s/proxy-install.sh) + url="https://raw.githubusercontent.com/contiv/vpp/master/k8s/" + url+="proxy-install.sh" + bash <(curl -s "${url}") } function k8s_utils.apply { @@ -113,7 +118,9 @@ function k8s_utils.resource_delete { function k8s_utils.affinity_non_vpp { # Set affinity for all non VPP docker containers to CPU 0 - for i in `sudo docker ps --format "{{.ID}} {{.Names}}" | grep -v vpp | cut -d' ' -f1`; do + command='sudo docker ps --format "{{.ID}} {{.Names}}"' + command+=" | grep -v vpp | cut -d' ' -f1" + for i in $(${command}); do sudo docker update --cpuset-cpus 0 ${i} done }