uninstall edgex
[eliot.git] / blueprints / iotgateway / scripts / k8smaster_centos.sh
1 #!/bin/bash -ex
2 ##############################################################################
3 # Copyright (c) 2019 Huawei Tech and others.                                 #
4 #                                                                            #
5 # All rights reserved. This program and the accompanying materials           #
6 # are made available under the terms of the Apache License, Version 2.0      #
7 # which accompanies this distribution, and is available at                   #
8 # http://www.apache.org/licenses/LICENSE-2.0                                 #
9 ##############################################################################
10
11 # constants
12
13 POD_NETWORK_CIDR=192.168.0.0/16
14 KUBE_VERSION=1.17.2-0
15 KUBERNETES_CNI=0.7.5-0
16
17 # start
18
19 hostname -I > hostname.tmp
20 MASTER_IP="$(cut -d ' ' -f 1 hostname.tmp)"
21 rm hostname.tmp
22
23 # kubernetes installation
24
25 sudo yum install -y kubelet-${KUBE_VERSION} kubectl-${KUBE_VERSION} \
26 kubernetes-cni-${KUBERNETES_CNI}
27
28 sudo systemctl daemon-reload
29 sudo systemctl restart kubelet
30
31 # Initialize kubernetes on master
32
33 sudo kubeadm init \
34         --apiserver-advertise-address="${MASTER_IP}" \
35         --pod-network-cidr="${POD_NETWORK_CIDR}"
36
37 mkdir -p "${HOME}/.kube"
38 sudo cp -i /etc/kubernetes/admin.conf "${HOME}/.kube/config"
39 sudo chown "$(id -u)":"$(id -g)" "${HOME}/.kube/config"