环境
两台虚拟机
一个脚本的安装包
步骤一
两台虚拟机都安装doker
systemctl stop firewalld.service && systemctl disable firewalld.service
setenforce 0
sed -i.bak ‘s/SELINUX=enforcing/SELINUX=permissive/’ /etc/selinux/config
创建一个 vi /etc/yum.repos.d/docker.repo 文件,内容如下:
[dockerrepo]
name=Docker Repository
baseurl=https://yum.dockerproject.org/repo/main/centos/7/
enabled=1
gpgcheck=1
gpgkey=https://yum.dockerproject.org/gpg
安装新版本 Docker
yum install -y docker-engine
开启服务
systemctl start docker
设置两台虚拟机的hostname
master上执行:
[root@localhost ~]# hostnamectl –static set-hostname k8s-master
node1上执行
[root@localhost ~]# hostnamectl –static set-hostname k8s-node-1
修改两台虚拟机的/etc/hosts文件
vi /etc/hosts
192.168.0.220 k8s-master
192.168.0.221 k8s-node-1
下面进行分开设置
k8s-master 设置(虚拟机内存为2g)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 1mkdir /root/k8s1
2 cp 1kubernetes1.9.2.tar.tar.gz /root/k8s1
3 swapoff -a
4 sed -i 's#SELINUX=enforcing#SELINUX=disabled#g' /etc/selinux/config
5 setenforce 0
6
7 yum install epel-release
8
9systemctl start docker
10
11 cd k8s1
12
13tar -xvf 1kubernetes1.9.2.tar.tar.gz
14cd shell
15
16 sh init.sh
17 sh master.sh
18 kubectl get pod -n kube-system
19 kubectl get node
20
21
k8s-node-1 设置(虚拟机内存为2g)
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 1 17 mkdir /root/k8s2
2 18 cd /mnt/dscloud/
3 19 cp 1kubernetes1.9.2.tar.tar.gz /root/k8s2
4 20 vi /etc/hosts
5 21 docker info
6 22 systemctl start docker
7 23 cd ..
8 24 ls
9 25 cd /root
10 26 ls
11 27 cd k8s2
12 28 ls
13 29 tar -xvf 1kubernetes1.9.2.tar.tar.gz
14 30 sed -i.bak 's/SELINUX=enforcing/SELINUX=permissive/' /etc/selinux/config
15 31 setenforce 0
16 32 systemctl stop firewalld.service && systemctl disable firewalld.service
17 33 swapoff -a
18 34 ls
19 35 cd shell
20 36 ls
21 37 sh init.sh
22 38 kubeadm join --token af6813.20df34842ec71dc9 192.168.186.211:6443 --discovery-token-ca-cert-hash sha256:47d8ff8cddcdf913eef782dc974281cd19f15bb5b5c5c2bcb0d4190b07305543
23
24
25