promote Jinquan ni as MSB commiter and ptl
[msb/service-mesh.git] / install / 1_install_k8s_master.sh
1 #!/bin/sh
2 #
3 # Copyright 2018 ZTE, Inc.
4 #
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
8 #
9 #     http://www.apache.org/licenses/LICENSE-2.0
10 #
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
16
17 echo "************install docker************"
18 sudo apt-get update
19 sudo apt-get install -y docker.io
20
21 echo "*************set up kubernetes apt-get source************"
22 sudo apt-get update && sudo apt-get install -y apt-transport-https
23 curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add -
24 cat <<EOF | sudo tee /etc/apt/sources.list.d/kubernetes.list
25 deb http://apt.kubernetes.io/ kubernetes-xenial main
26 EOF
27 sudo apt-get update
28
29 read -p "Install kubelet (y/n)?" choice
30 case "$choice" in
31   y|Y ) sudo apt-get install -y kubelet=1.11.1-00;;
32 esac
33 printf "\n"
34
35 read -p "Install kubeadm (y/n)?" choice
36 case "$choice" in
37   y|Y ) sudo apt-get install -y kubeadm=1.11.1-00;;
38 esac
39 printf "\n"
40
41 read -p "Install kubectl (y/n)?" choice
42 case "$choice" in
43   y|Y ) sudo apt-get install -y kubectli=1.11.1-00;;
44 esac
45 printf "\n"
46
47 echo "*************dry run to test kubeadm.conf************"
48 sudo kubeadm init --config kubeadm.conf --dry-run
49
50 read -p "Create kubernetees master(y/n)?" choice
51 case "$choice" in
52   y|Y )
53     sudo kubeadm init --config kubeadm.conf
54     mkdir -p $HOME/.kube
55     sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
56     sudo chown $(id -u):$(id -g) $HOME/.kube/config
57     sudo chmod o+wr  $HOME/.kube/config
58     ;;
59 esac
60 printf "\n"
61
62 read -p "Install calico network plugin (y/n)?" choice
63 case "$choice" in
64   y|Y ) kubectl apply -f https://docs.projectcalico.org/v2.6/getting-started/kubernetes/installation/hosted/kubeadm/1.6/calico.yaml;;
65 esac
66 printf "\n"
67
68 read -p "Install helm (y/n)?" choice
69 case "$choice" in
70   y|Y )
71     wget https://storage.googleapis.com/kubernetes-helm/helm-v2.8.2-linux-amd64.tar.gz
72     tar -zxvf helm-v2.8.2-linux-amd64.tar.gz
73     chmod o+x linux-amd64/helm
74     sudo mv linux-amd64/helm /usr/local/bin/helm
75     rm -rf linux-amd64
76     rm -rf helm-v2.8.2-linux-amd64.tar.gz
77
78     kubectl create -f helm_service_account.yaml
79     helm init --service-account tiller
80     ;;
81 esac
82 printf "\n"