3 # For host setup as Kubernetes master
5 POD_NETWORK_CIDR=${2:-192.168.0.0/16}
6 SERVICE_CIDR=${3:-172.16.1.0/24}
8 if [ -z "${MGMT_IP}" ]; then
9 echo "Please specify a management IP!"
13 #Add extra flags to Kubelet
14 sed '/Environment=\"KUBELET_CONFIG_ARGS/a\Environment=\"KUBELET_EXTRA_ARGS=--fail-swap-on=false --feature-gates HugePages=false\"' -i /etc/systemd/system/kubelet.service.d/10-kubeadm.conf
16 if ! kubectl get nodes; then
17 sudo kubeadm config images pull
19 --pod-network-cidr="${POD_NETWORK_CIDR}" \
20 --apiserver-advertise-address="${MGMT_IP}" \
21 --service-cidr="${SERVICE_CIDR}"
23 if [ "$(id -u)" = 0 ]; then
24 echo "export KUBECONFIG=/etc/kubernetes/admin.conf" | \
25 tee -a "${HOME}/.profile"
26 # shellcheck disable=SC1090
27 source "${HOME}/.profile"
29 mkdir -p "${HOME}/.kube"
30 sudo cp -i /etc/kubernetes/admin.conf "${HOME}/.kube/config"
31 sudo chown "$(id -u)":"$(id -g)" "${HOME}/.kube/config"