2 # Copyright (c) 2017 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:
7 # http://www.apache.org/licenses/LICENSE-2.0
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.
17 SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
19 K8S_CALICO="${SCRIPT_DIR}/../../templates/kubernetes/calico_v2.4.1.yaml"
20 K8S_CSIT="${SCRIPT_DIR}/../../templates/kubernetes/csit.yaml"
22 trap "sudo kubeadm reset && sudo rm -rf $HOME/.kube" ERR
24 # Revert any changes made to this host by 'kubeadm init' or 'kubeadm join'
25 sudo kubeadm reset && sudo rm -rf $HOME/.kube || \
26 { echo "Failed to reset kubeadm"; exit 1; }
28 # Ret up the Kubernetes master
29 sudo -E kubeadm init --token-ttl 0 --pod-network-cidr=192.168.0.0/16 || \
30 { echo "Failed to init kubeadm"; exit 1; }
32 # Make cgroup non-exclusive for CPU and MEM
33 sudo cgset -r cpuset.cpu_exclusive=0 /kubepods
34 sudo cgset -r cpuset.mem_exclusive=0 /kubepods
38 sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
39 sudo chown $(id -u):$(id -g) $HOME/.kube/config
42 kubectl apply -f ${K8S_CALICO} || \
43 { echo "Failed to apply Calico resources"; exit 1; }
44 kubectl apply -f ${K8S_CSIT} || \
45 { echo "Failed to apply CSIT resource"; exit 1; }
48 kubectl taint nodes --all node-role.kubernetes.io/master- || \
49 { echo "Failed to taint nodes"; exit 1; }
51 # Dump Kubernetes objects ...
52 kubectl get all --all-namespaces
54 echo Kubernetes is ready