Remove: Obsolete bash code
[csit.git] / resources / libraries / bash / k8s_setup.sh
1 #!/bin/bash
2 # Copyright (c) 2018 Cisco and/or its affiliates.
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at:
6 #
7 #     http://www.apache.org/licenses/LICENSE-2.0
8 #
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
14
15 set -xo pipefail
16
17 SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
18
19 # Include
20 source ${SCRIPT_DIR}/config/defaults
21 source ${SCRIPT_DIR}/shell/k8s_utils.sh
22
23 trap "k8s_utils.destroy" ERR
24
25 case "$1" in
26     prepare)
27         # Revert any changes made to this host by 'kubeadm init'
28         k8s_utils.destroy
29         # Sets up the Kubernetes master
30         k8s_utils.prepare
31         ;;
32     deploy_calico)
33         # Revert any changes made to this host by 'kubeadm init'
34         k8s_utils.destroy
35         # Load kernel modules uio/uio_pci_generic
36         sudo modprobe uio
37         sudo modprobe uio_pci_generic
38         sudo modprobe vfio_pci
39         # Sets up the Kubernetes master
40         k8s_utils.prepare "--pod-network-cidr=192.168.0.0/16"
41         # Apply resources
42         k8s_utils.calico_deploy ${cfg[K8S_CALICO]}
43         # Dump Kubernetes objects ...
44         k8s_utils.dump_all
45         ;;
46     affinity_non_vpp)
47         # Set affinity for all non VPP docker containers to CPU 0
48         k8s_utils.affinity_non_vpp
49         ;;
50     destroy)
51         # Revert any changes made to this host by 'kubeadm init'
52         k8s_utils.destroy
53         ;;
54     *)
55         echo "usage: $0 function"
56         echo "function:"
57         echo "    prepare"
58         echo "    deploy_calico"
59         echo "    affinity_non_vpp"
60         echo "    destroy"
61         exit 1
62 esac
63 shift
64
65 echo Kubernetes setup finished