aboutsummaryrefslogtreecommitdiffstats
path: root/resources/libraries/bash
diff options
context:
space:
mode:
Diffstat (limited to 'resources/libraries/bash')
-rw-r--r--resources/libraries/bash/config/defaults8
-rw-r--r--resources/libraries/bash/function/README.txt20
-rw-r--r--resources/libraries/bash/function/artifacts.sh79
-rw-r--r--resources/libraries/bash/function/branch.sh6
-rwxr-xr-xresources/libraries/bash/k8s_setup.sh65
-rw-r--r--resources/libraries/bash/shell/k8s_utils.sh132
6 files changed, 2 insertions, 308 deletions
diff --git a/resources/libraries/bash/config/defaults b/resources/libraries/bash/config/defaults
deleted file mode 100644
index 6a25a5f04d..0000000000
--- a/resources/libraries/bash/config/defaults
+++ /dev/null
@@ -1,8 +0,0 @@
-#!/bin/bash
-
-typeset -A cfg
-cfg=( # set default values in config array
- [K8S_CALICO]="${SCRIPT_DIR}/../../templates/kubernetes/calico_v2.6.3.yaml"
- [K8S_CONTIV_VPP]="https://raw.githubusercontent.com/contiv/vpp/master/k8s/contiv-vpp.yaml"
- [K8S_CSIT]="${SCRIPT_DIR}/../../templates/kubernetes/csit.yaml"
-)
diff --git a/resources/libraries/bash/function/README.txt b/resources/libraries/bash/function/README.txt
deleted file mode 100644
index e4eb91565b..0000000000
--- a/resources/libraries/bash/function/README.txt
+++ /dev/null
@@ -1,20 +0,0 @@
-# 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:
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-Files in this directory system are to be executed indirectly,
-sourced from other scripts.
-
-In fact, the files should only define functions,
-except perhaps some minimal logic needed to import dependencies.
-The originating function calls should be executed from elsewhere,
-typically from entry scripts.
diff --git a/resources/libraries/bash/function/artifacts.sh b/resources/libraries/bash/function/artifacts.sh
index 15a4dd2fe1..e4d5dd6fc6 100644
--- a/resources/libraries/bash/function/artifacts.sh
+++ b/resources/libraries/bash/function/artifacts.sh
@@ -1,7 +1,6 @@
#!/usr/bin/env bash
-# Copyright (c) 2021 Cisco and/or its affiliates.
-# Copyright (c) 2021 PANTHEON.tech and/or its affiliates.
+# Copyright (c) 2023 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:
@@ -26,8 +25,6 @@ function download_artifacts () {
# - REPO_URL - FD.io Packagecloud repository.
# Functions conditionally called (see their documentation for side effects):
# - download_ubuntu_artifacts
- # - download_centos_artifacts
- # - download_opensuse_artifacts
set -exuo pipefail
@@ -46,10 +43,6 @@ function download_artifacts () {
if [ "${os_id}" == "ubuntu" ]; then
download_ubuntu_artifacts || die
- elif [ "${os_id}" == "centos" ]; then
- download_centos_artifacts || die
- elif [ "${os_id}" == "opensuse" ]; then
- download_opensuse_artifacts || die
else
die "${os_id} is not yet supported."
fi
@@ -129,73 +122,3 @@ function download_ubuntu_artifacts () {
}
fi
}
-
-function download_centos_artifacts () {
-
- # Download or install CentOS VPP artifacts from packagecloud.io.
- #
- # Variables read:
- # - REPO_URL - FD.io Packagecloud repository.
- # - VPP_VERSION - VPP version.
- # - INSTALL - Whether install packages (if set to "true") or download only.
- # Default: "false".
-
- set -exuo pipefail
-
- curl -s "${REPO_URL}"/script.rpm.sh | sudo -E bash || {
- die "Packagecloud FD.io repo fetch failed."
- }
- # If version is set we will add suffix.
- artifacts=()
- pkgs=(vpp vpp-selinux-policy vpp-devel vpp-lib vpp-plugins vpp-api-python)
- if [ -z "${VPP_VERSION-}" ]; then
- artifs+=(${pkgs[@]})
- else
- artifs+=(${pkgs[@]/%/-${VPP_VERSION-}})
- fi
-
- if [[ "${INSTALL:-false}" == "true" ]]; then
- sudo yum -y install "${artifs[@]}" || {
- die "Install VPP artifact failed."
- }
- else
- sudo yum -y install --downloadonly --downloaddir=. "${artifs[@]}" || {
- die "Download VPP artifacts failed."
- }
- fi
-}
-
-function download_opensuse_artifacts () {
-
- # Download or install OpenSuSE VPP artifacts from packagecloud.io.
- #
- # Variables read:
- # - REPO_URL - FD.io Packagecloud repository.
- # - VPP_VERSION - VPP version.
- # - INSTALL - Whether install packages (if set to "true") or download only.
- # Default: "false".
-
- set -exuo pipefail
-
- curl -s "${REPO_URL}"/script.rpm.sh | sudo -E bash || {
- die "Packagecloud FD.io repo fetch failed."
- }
- # If version is set we will add suffix.
- artifs=()
- pkgs=(vpp vpp-devel vpp-lib vpp-plugins libvpp0)
- if [ -z "${VPP_VERSION-}" ]; then
- artifs+=(${pkgs[@]})
- else
- artifs+=(${pkgs[@]/%/-${VPP_VERSION-}})
- fi
-
- if [[ "${INSTALL:-false}" == "true" ]]; then
- sudo yum -y install "${artifs[@]}" || {
- die "Install VPP artifact failed."
- }
- else
- sudo yum -y install --downloadonly --downloaddir=. "${artifs[@]}" || {
- die "Download VPP artifacts failed."
- }
- fi
-}
diff --git a/resources/libraries/bash/function/branch.sh b/resources/libraries/bash/function/branch.sh
index ba9cc39c67..37900eab01 100644
--- a/resources/libraries/bash/function/branch.sh
+++ b/resources/libraries/bash/function/branch.sh
@@ -1,4 +1,4 @@
-# Copyright (c) 2021 Cisco and/or its affiliates.
+# Copyright (c) 2023 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:
@@ -57,10 +57,6 @@ function checkout_csit_for_vpp () {
set -exuo pipefail
case "${1}" in
- "stable/2009")
- # LTS branch
- branch_id="origin/${1/stable\//oper-rls}_lts"
- ;;
"stable/"*)
branch_id="origin/${1/stable\//oper-rls}"
;;
diff --git a/resources/libraries/bash/k8s_setup.sh b/resources/libraries/bash/k8s_setup.sh
deleted file mode 100755
index d1d3a38454..0000000000
--- a/resources/libraries/bash/k8s_setup.sh
+++ /dev/null
@@ -1,65 +0,0 @@
-#!/bin/bash
-# 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:
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-set -xo pipefail
-
-SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
-
-# Include
-source ${SCRIPT_DIR}/config/defaults
-source ${SCRIPT_DIR}/shell/k8s_utils.sh
-
-trap "k8s_utils.destroy" ERR
-
-case "$1" in
- prepare)
- # Revert any changes made to this host by 'kubeadm init'
- k8s_utils.destroy
- # Sets up the Kubernetes master
- k8s_utils.prepare
- ;;
- deploy_calico)
- # Revert any changes made to this host by 'kubeadm init'
- k8s_utils.destroy
- # Load kernel modules uio/uio_pci_generic
- sudo modprobe uio
- sudo modprobe uio_pci_generic
- sudo modprobe vfio_pci
- # Sets up the Kubernetes master
- k8s_utils.prepare "--pod-network-cidr=192.168.0.0/16"
- # Apply resources
- k8s_utils.calico_deploy ${cfg[K8S_CALICO]}
- # Dump Kubernetes objects ...
- k8s_utils.dump_all
- ;;
- affinity_non_vpp)
- # Set affinity for all non VPP docker containers to CPU 0
- k8s_utils.affinity_non_vpp
- ;;
- destroy)
- # Revert any changes made to this host by 'kubeadm init'
- k8s_utils.destroy
- ;;
- *)
- echo "usage: $0 function"
- echo "function:"
- echo " prepare"
- echo " deploy_calico"
- echo " affinity_non_vpp"
- echo " destroy"
- exit 1
-esac
-shift
-
-echo Kubernetes setup finished
diff --git a/resources/libraries/bash/shell/k8s_utils.sh b/resources/libraries/bash/shell/k8s_utils.sh
deleted file mode 100644
index b96ec8df6c..0000000000
--- a/resources/libraries/bash/shell/k8s_utils.sh
+++ /dev/null
@@ -1,132 +0,0 @@
-#!/bin/bash
-# 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:
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-function k8s_utils.destroy {
- # Destroy existing Kubernetes deployment
- kubectl drain $HOSTNAME --delete-local-data --force --ignore-daemonsets
- kubectl delete node $HOSTNAME
-
- # Revert any changes made to this host by 'kubeadm init' or 'kubeadm join'
- sudo kubeadm reset --force && sudo rm -rf $HOME/.kube || \
- { echo "Failed to reset kubeadm"; exit 1; }
-}
-
-function k8s_utils.prepare {
- # Sets up the Kubernetes master
-
- # Disable swap
- sudo swapoff --all
-
- # Set up the Kubernetes master
- sudo -E kubeadm init --token-ttl 0 ${1} || \
- { echo "Failed to init kubeadm"; exit 1; }
-
- # Make cgroup non-exclusive for CPU and MEM
- sudo cgset -r cpuset.cpu_exclusive=0 /kubepods
- sudo cgset -r cpuset.mem_exclusive=0 /kubepods
-
- rm -rf $HOME/.kube
- mkdir -p $HOME/.kube
- sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
- sudo chown $(id -u):$(id -g) $HOME/.kube/config
-}
-
-function k8s_utils.taint {
- # Updates the taints
- kubectl taint nodes --all node-role.kubernetes.io/master- || \
- { echo "Failed to taint nodes"; exit 1; }
-}
-
-function k8s_utils.calico_deploy {
- # Calico yaml URL or file
- k8s_calico=$1
-
- # Apply resources
- kubectl apply -f ${k8s_calico} || \
- { echo "Failed to apply ${k8s_calico}"; exit 1; }
-
- # Update the taints
- k8s_utils.taint
-}
-
-function k8s_utils.contiv_vpp_deploy {
- # Contiv yaml URL or file
- k8s_contiv=$1
- k8s_contiv_patch="kubecon.contiv-vpp-yaml-patch.diff"
-
- # Pull the most recent Docker images
- url="https://raw.githubusercontent.com/contiv/vpp/master/k8s/pull-images.sh"
- bash <(curl -s "${url}")
-
- # Apply resources
- wget ${k8s_contiv}
- patch contiv-vpp.yaml -i ${k8s_contiv_patch} -o - | kubectl apply -f - || \
- { echo "Failed to apply Contiv resources"; exit 1; }
- rm contiv-vpp.yaml
-
- # Update the taints
- k8s_utils.taint
-}
-
-function k8s_utils.cri_shim_install {
- # Install the CRI Shim on host
- 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
- 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
- url="https://raw.githubusercontent.com/contiv/vpp/master/k8s/"
- url+="proxy-install.sh"
- bash <(curl -s "${url}")
-}
-
-function k8s_utils.apply {
- # Resource yaml URL or file
- k8s_resource=$1
-
- # Apply resources
- kubectl apply -f ${k8s_resource} || \
- { echo "Failed to apply ${k8s_resource}"; exit 1; }
-}
-
-function k8s_utils.resource_delete {
- # Resource yaml URL or file
- k8s_resource=$1
-
- # Delete resources
- kubectl delete -f ${k8s_resource} || \
- { echo "Failed to delete ${k8s_resource}"; exit 1; }
-}
-
-function k8s_utils.affinity_non_vpp {
- # Set affinity for all non VPP docker containers to CPU 0
- 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
-}
-
-function k8s_utils.dump_all {
- # Dumps the kubernetes objects
- kubectl get all --all-namespaces
- kubectl describe nodes
-}