1.修改网卡
sed -i "s/ONBOOT=no/ONBOOT=yes/g" /etc/sysconfig/network-scripts/ifcfg-ens33 && systemctl restart network
2.修改主机名
hostnamectl set-hostname node2
3.禁用SELINUX
sed -i "s/SELINUX=enforcing/SELINUX=disabled/g" /etc/sysconfig/selinux && setenforce 0
4.时间同步
systemctl restart chronyd
5.设置hosts
cat > /etc/hosts << EOF
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
10.0.0.2 master.ckafk2.com master
10.0.0.3 node1.ckafk2.com node1
10.0.0.4 node2.ckafk2.com node2
10.0.0.5 node3.ckafk2.com node3
EOF
6.下载docker-ce repo至/etc/yum.repos.d/
cd /etc/yum.repos.d/ && curl -o ali-docker-ce.repo https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
7.安装docker-ce,启动docker
yum install docker-ce -y
systemctl daemon-reload
systemctl start docker && systemctl enable docker
8.配置kubernetes repo
vim /etc/yum.repo.d/kubernetes.repo
[kubernetes]
name=Kubernetes Repository
baseurl=https://mirrors.aliyun.com/kubernetes/yum/repos/kubernetes-el7-x86_64/
enable=1
gpgcheck=1
gpgkey=https://mirrors.aliyun.com/kubernetes/yum/doc/rpm-package-key.gpg
https://mirrors.aliyun.com/kubernetes/yum/doc/yum-key.gpg
9.安装kubeadm, kubelet
yum install kubelet kubeadm -y
10.禁用kubelet的swap
echo KUBELET_EXTRA_ARGS="--fail-swap-on=false" > /etc/sysconfig/kubelet
11.启动kubelet并开机启动
systemctl start kubelet && systemctl enable kubelet
echo 1 > /proc/sys/net/bridge/bridge-nf-call-iptables
12.需要准备3个docker镜像,kube-proxy,pause,flannel
docker pull registry.cn-hangzhou.aliyuncs.com/google_containers/kube-proxy:v1.15.2
docker pull registry.cn-hangzhou.aliyuncs.com/google_containers/pause:3.1
docker tag registry.cn-hangzhou.aliyuncs.com/google_containers/kube-proxy:v1.15.2 k8s.gcr.io/kube-proxy:v1.15.2
docker tag registry.cn-hangzhou.aliyuncs.com/google_containers/pause:3.1 k8s.gcr.io/pause:3.1
docker rmi registry.cn-hangzhou.aliyuncs.com/google_containers/kube-proxy:v1.15.2
docker rmi registry.cn-hangzhou.aliyuncs.com/google_containers/pause:3.1
13.提前将flannel的tar包从互联网下载过来,然后加载
docker load -i flannel-v0.11.0.tar.gz
====查看
[root@node3 ~]# docker image list
REPOSITORY TAG IMAGE ID CREATED SIZE
k8s.gcr.io/kube-proxy v1.15.2 167bbf6c9338 9 days ago 82.4MB
quay.io/coreos/flannel v0.11.0-amd64 ff281650a721 6 months ago 52.6MB
k8s.gcr.io/pause 3.1 da86e6ba6ca1 20 months ago 742kB
==================================================================
最后一步,加入集群
kubeadm join 10.0.0.2:6443 --token a30edt.uwgmifdb29x3vt4n --discovery-token-ca-cert-hash sha256:fc084e7d9b0f0ccce47a7c42bb3bde2c92194f5ee218e711dab142398bc9b1b9 --ignore-preflight-errors=Swap