-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmaster.sh
62 lines (53 loc) · 1.86 KB
/
master.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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#!/bin/bash
#Set up master node
echo 'Initialize master node, please wait may take some time'
kubeadm init --image-repository registry.aliyuncs.com/google_containers --apiserver-advertise-address=192.168.0.30
#Make .kube dir for vagrant user
echo 'Adding .kube dir for user'
mkdir -p /home/vagrant/.kube
sudo cp -i /etc/kubernetes/admin.conf /home/vagrant/.kube/config
sudo chown -R vagrant:vagrant /home/vagrant/.kube/config
#Make .kube dir for root user
echo 'Adding .kube dir for root'
mkdir -p /root/.kube
sudo cp -i /etc/kubernetes/admin.conf /root/.kube/config
#Deploy pod network weavenet
echo 'Deploying Weavenet CNI'
kubectl apply -f "https://cloud.weave.works/k8s/net?k8s-version=$(kubectl version | base64 | tr -d '\n')" >/dev/null 2>&1
#Bootstrap token
echo 'Creating worker bootstrap token'
kubeadm token create --print-join-command > /bootstrap_token.sh
echo 'Master node set up'
#Add kubectl alias to vagrant user .bashrc file
echo 'Adding kubectl alias to bashrc'
cat <<EOF > /home/vagrant/.bashrc
#.bashrc
#Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi
#Uncomment the following line if you don't like systemctl's auto-paging feature:
#export SYSTEMD_PAGER=
#User specific aliases and functions
alias k='kubectl'
alias kg='kubectl get'
alias kgpo='kubectl get po'
alias kgn='kubectl get nodes'
alias kd='kubectl describe'
alias krm='kubectl delete'
alias krmf='kubectl delete -f'
alias kc='kubectl create -f'
alias ka='kubectl apply -f'
alias kl='kubectl logs'
EOF
source ~/.bashrc
# Enable ssh password authentication
echo "Enable ssh password authentication"
sed -i 's/^PasswordAuthentication no/PasswordAuthentication yes/' /etc/ssh/sshd_config
systemctl reload sshd
# Set Root password
echo "Set root password"
echo "kubeadmin" | passwd --stdin root >/dev/null 2>&1
#Rebooting node
echo 'Setup complete rebooting node...'
sleep 10 && reboot