2 ##############################################################################
3 # Copyright (c) 2019 Huawei Tech and others. #
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 ##############################################################################
13 POD_NETWORK_CIDR=192.168.0.0/16
15 KUBERNETES_CNI=0.7.5-0
19 hostname -I > hostname.tmp
20 MASTER_IP="$(cut -d ' ' -f 1 hostname.tmp)"
23 # kubernetes installation
25 sudo yum install -y kubelet-${KUBE_VERSION} kubectl-${KUBE_VERSION} \
26 kubernetes-cni-${KUBERNETES_CNI}
28 sudo systemctl daemon-reload
29 sudo systemctl restart kubelet
31 # Initialize kubernetes on master
34 --apiserver-advertise-address="${MASTER_IP}" \
35 --pod-network-cidr="${POD_NETWORK_CIDR}"
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"