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 start kubelet #&& sudo systemctl enable kubelet
30 sudo docker info | grep -i cgroup
31 sudo sed -i 's/cgroup-driver=systemd/cgroup-driver=cgroupfs/g' \
32 /etc/systemd/system/kubelet.service.d/10-kubeadm.conf
34 sudo systemctl daemon-reload
35 sudo systemctl restart kubelet
37 # Initialize kubernetes on master
40 --apiserver-advertise-address="${MASTER_IP}" \
41 --pod-network-cidr="${POD_NETWORK_CIDR}"
43 mkdir -p "${HOME}/.kube"
44 sudo cp -i /etc/kubernetes/admin.conf "${HOME}/.kube/config"
45 sudo chown "$(id -u)":"$(id -g)" "${HOME}/.kube/config"