-
Notifications
You must be signed in to change notification settings - Fork 2
/
building-k8s-cluster.sh
executable file
·66 lines (45 loc) · 2.89 KB
/
building-k8s-cluster.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
63
64
65
66
echo -e "=================================================================================================================================="
echo -e "Execute Ansible Playbook kube-dependencies.yml"
echo -e "=================================================================================================================================="
ansible-playbook -i hosts kube-dependencies.yml
sleep 3
echo -e "=================================================================================================================================="
echo -e "Execute Ansible Playbook master.yml"
echo -e "=================================================================================================================================="
ansible-playbook -i hosts master.yml
sleep 3
echo -e "=================================================================================================================================="
echo -e "Install kubectl to local"
echo -e "=================================================================================================================================="
cat <<EOF > /etc/yum.repos.d/kubernetes.repo
[kubernetes]
name=Kubernetes
baseurl=https://packages.cloud.google.com/yum/repos/kubernetes-el7-x86_64
enabled=1
gpgcheck=1
repo_gpgcheck=1
gpgkey=https://packages.cloud.google.com/yum/doc/yum-key.gpg https://packages.cloud.google.com/yum/doc/rpm-package-key.gpg
EOF
yum install -y kubectl
#kubectl version --short
sleep 3
echo -e "=================================================================================================================================="
echo -e "Copy K8S Master kube config to local"
echo -e "=================================================================================================================================="
mkdir ~/.kube
scp k8s-master-az:/etc/kubernetes/admin.conf ~/.kube/config
sleep 3
echo -e "=================================================================================================================================="
echo -e "Check the cluster status"
echo -e "=================================================================================================================================="
kubectl get nodes
sleep 3
echo -e "=================================================================================================================================="
echo -e "Execute Ansible Playbook worker.yml"
echo -e "=================================================================================================================================="
ansible-playbook -i hosts workers.yml
sleep 10
echo -e "=================================================================================================================================="
echo -e "Check the cluster status"
echo -e "=================================================================================================================================="
kubectl get nodes