2.修改主机名
hostnamectl set-hostname master
在master主机的 /etc/hosts
上添加master的ip和主机名
192.2.0.0 master
/etc/yum.repos.d目录下
vim kubenetes.repo
[root@k8s-master yum.repos.d]# cat kubenetes.repo
[kubernetes]
name=Kubernetes Repo
baseurl=https://mirrors.aliyun.com/kubernetes/yum/repos/kubernetes-el7-x86_64/
gpgcheck=1 #开启gpg校验
gpgkey=https://mirrors.aliyun.com/kubernetes/yum/doc/yum-key.gpg
enabled=1
下载校验文件
wget https://mirrors.aliyun.com/kubernetes/yum/doc/rpm-package-key.gpg
wget https://mirrors.aliyun.com/kubernetes/yum/doc/yum-key.gpg
导入校验文件
rpm --import rpm-package-key.gpg
rpm --import yum-key.gpg
yum install docker-ce kubelet kubeadm kubectl
初始化k8s集群
[root@master01 ~]# kubeadm init --kubernetes-version=1.18.0 \
--apiserver-advertise-address=192.168.122.21 \
--image-repository registry.aliyuncs.com/google_containers \
--service-cidr=10.10.0.0/16 --pod-network-cidr=10.122.0.0/16