服务器要求(三台都要操作)
- 一台master两台node
- 能连外网
- 关闭防火墙
- 关闭selinux
- 设置主机名,域名解析
- 关闭swap(记得关完之后重启)
swapoff -a //临时关闭
vim /etc/fstab //把swap分区挂载部分注释掉
- 将桥接的ipv4流量传递到iptables上,修改linux内核参数,添加网桥过滤和地址转发功能
[root@master ~]# cat /etc/ sysctl.d/kubernetes.conf
net.bridge. bridge-nf-call-ip6tables = 1
net.bridge. bridge-nf-call-iptables = 1
net.ipv4.ip_forward = 1
[root@master ~]# sysctl -p
[root@master ~]# modprobe br_netfilter
[root@master ~]#lsmod |grep br_netfil
- 时间同步
- 安装docker-ce(拉取阿里云docker镜像源)
wget https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
- 配置docker默认
[root@master docker]# cat daemon.json
{
"registry-mirrors": ["https://n5jclonh.mirror.aliyuncs.com"],
"insecure-registries": ["10.104.43.33:8858"],
"exec-opts": ["native.cgroupdriver=systemd"] //docker在默认情况下使用cgroupdiver为cgroupfs,而kubernetes推荐使用systemd来代替cgroupfs,所以需要修改配置文件
}
- 安装kubeadm、kubelet、kubectl
- 配置yum源
[root@master yum.repos.d] # cat k8s.repo [kubernetes] name=kubernetes baseurl=http://mirrors. aliyun.com/kubernetes/ yum/repos/ kubernetes-el7-x86_64 enabled=1 gpgcheck=0 repo_gpgcheck=0 gpgkey=http://mirrors. aliyun.com/kubernetes/ yum/doc/yum-key.gpg http://mirrors. aliyun.com/ kubernetes/yum/ doc/ rpm-package-key. gpg //yum仓库的配置文件一定要顶格写
- 安装kubelet kubeadm kubectl
yum install -y kubelet-1.23.6 kubeadm-1.23.6 kubectl-1.23.6
- 配置yum源
- 初始化master
[root@master ~]# kubeadm init --apiserver-advertise-address=10.104.43.33 --image-repository registry.aliyuncs.com/google_containers --kubernetes-version v1.23.6 --service-cidr=10.96.0.0/12 --pod-network-cidr=10.244.0.0/16
标签:kubernetes,com,master,yum,集群,docker,k8s,root,搭建
From: https://www.cnblogs.com/humlogs/p/18175125