-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinit-node.sh
executable file
·42 lines (32 loc) · 1.05 KB
/
init-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
40
41
42
#!/usr/bin/env bash
echo '### set host name resolution'
cat /vagrant/hosts >> /etc/hosts
cat /etc/hosts
echo '/sbin/iptables -P FORWARD ACCEPT' >> /etc/rc.local
cat /vagrant/ipvs.modules > /etc/sysconfig/modules/ipvs.modules
chmod 755 /etc/sysconfig/modules/ipvs.modules && \
bash /etc/sysconfig/modules/ipvs.modules && \
lsmod | grep -e ip_vs -e nf_conntrack_ipv4
# for master node
if [[ $1 -eq 1 ]]
then
echo '### config master node'
echo '### pull core images'
kubeadm config images pull --config /vagrant/kubeadm-init.yaml
docker images
echo '### kubeadm init'
kubeadm init --config /vagrant/kubeadm-init.yaml
echo '### copy kube config'
mkdir -p $HOME/.kube
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
sudo chown $(id -u):$(id -g) $HOME/.kube/config
echo '### apply flannel'
kubectl apply -f /vagrant/kube-flannel.yml
echo 'master untainted'
kubectl taint nodes --all node-role.kubernetes.io/master-
fi
if [[ $1 -gt 1 ]]
then
echo 'Please join to master'
echo 'script: kubeadm token create --print-join-command'
fi