-
Notifications
You must be signed in to change notification settings - Fork 22
/
configure-master-node.sh
39 lines (32 loc) · 1.05 KB
/
configure-master-node.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/bin/bash -e
master_node=172.16.8.10
pod_network_cidr=192.168.0.0/16
initialize_master_node ()
{
sudo systemctl enable kubelet
sudo kubeadm config images pull --cri-socket /run/cri-dockerd.sock
sudo kubeadm init --cri-socket /run/cri-dockerd.sock --apiserver-advertise-address=$master_node --pod-network-cidr=$pod_network_cidr --ignore-preflight-errors=NumCPU
}
create_join_command ()
{
kubeadm token create --print-join-command | sed 's/--token/--cri-socket unix:\/\/\/run\/cri-dockerd.sock --token/' | tee /vagrant/join_command.sh
chmod +x /vagrant/join_command.sh
}
configure_kubectl ()
{
mkdir -p $HOME/.kube
sudo cp -f /etc/kubernetes/admin.conf $HOME/.kube/config
sudo chown $(id -u):$(id -g) $HOME/.kube/config
##For vagrant user
mkdir -p /home/vagrant/.kube
sudo cp -f /etc/kubernetes/admin.conf /home/vagrant/.kube/config
sudo chown 900:900 /home/vagrant/.kube/config
}
install_network_cni ()
{
kubectl apply -f /vagrant/kube-flannel.yml
}
initialize_master_node
configure_kubectl
install_network_cni
create_join_command