Kubeadm部署k8s单点master1、环境准备:主机名IP说明宿主机系统master10.0.0.17Kubernetes集群的master节点CentOS 7.9node110.0.0.27Kubernetes集群的node节点CentOS 7.9 # 所有master和node节点执行: # 关闭防火墙、iptables和selinux systemctl stop firewalld && systemctl disable firewalld setenforce 0 sed -i 's/enforcing/disabled/' /etc/selinux/config # 禁用swap vim /etc/fstab swapoff -a # 主机名互相解析 hostnamectl set-hostname master vim /etc/hosts 10.0.0.27 node 10.0.0.17 master # 时间同步 yum install -y chrony systemctl enable --now chronyd # 添加网桥过滤和地址转发功能 yum install -y bridge-utils modprobe br_netfilter cat > /etc/sysctl.d/kubernetes.conf <<EOF net.bridge.bridge-nf-call-arptables = 1 net.bridge.bridge-nf-call-ip6tables = 1 net.ipv4.ip_forward = 1 user.max_user_namespaces=28633 EOF sysctl -p /etc/sysctl.d/kubernetes.conf2、安装docker # 所有节点执行: yum install -y yum-utils device-mapper-persistent-data lvm2 yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo yum install docker-ce # 配置镜像加速器、使用 systemd 来管理容器的 cgroup mkdir -p /etc/docker cat <<EOF > /etc/docker/daemon.json { "exec-opts": ["native.cgroupdriver=systemd"], "log-driver": "json-file", "log-opts": { "max-size": "100m" }, "storage-driver": "overlay2", "storage-opts": [ "overlay2.override_kernel_check=true" ], "experimental": false, "debug": false, "max-concurrent-downloads": 10, "registry-mirrors": ["https://pgavrk5n.mirror.aliyuncs.com"] } EOF systemctl enable docker && systemctl start docker && systemctl status docker3、切换k8s国内源 # 所有节点执行: cat > /etc/yum.repos.d/kubernetes.repo << EOF [kubernetes] name=Kubernetes baseurl=https://mirrors.aliyun.com/kubernetes/yum/repos/kubernetes-el7-x86_64 enabled=1 gpgcheck=0 repo_gpgcheck=0 gpgkey=https://mirrors.aliyun.com/kubernetes/yum/doc/yum-key.gpg https://mirrors.aliyun.com/kubernetes/yum/doc/rpm-package-key.gpg EOF yum install -y kubelet-1.23.0 kubeadm-1.23.0 kubectl-1.23.04、安装指定版本kubeadm、kubelet、kubectl # 所有节点执行: # 建议不要安装最新版本,因为最新版本很多组件不兼容 , 造成安装报错 。 yum install -y kubelet-1.23.0 kubeadm-1.23.0 kubectl-1.23.0 # 设置kubelet开机启动 systemctl enable kubelet5、初始化K8S # master节点: kubeadm init --apiserver-advertise-address=10.0.0.17 --image-repository registry.aliyuncs.com/google_containers --kubernetes-version v1.23.0 --service-cidr=10.96.0.0/12 --pod-network-cidr=10.244.0.0/16 --ignore-preflight-errors=all # 说明: –apiserver-advertise-address #集群通告地址(master机器IP) –image-repository #由于默认拉取镜像地址k8s.gcr.io国内无法访问 , 这里指定阿里云镜像仓库地址 –kubernetes-version #K8s版本,与上面安装的一致 –service-cidr #集群内部虚拟网络,Pod统一访问入口 –pod-network-cidr #Pod网络,与下面部署的CNI网络组件yaml中保持一致
推荐阅读
- Kubeadm部署Kubernetes
- 含源码 【YOLOv5】手把手教你使用LabVIEW ONNX Runtime部署 TensorRT加速,实现YOLOv5实时物体识别
- 二 Istio:在Kubernetes(k8s)集群上安装部署istio1.14
- .NET6打包部署到Windows Service
- docker swarm快速部署redis分布式集群
- 使用 etcdadm 快速、弹性部署 etcd 集群
- Cenots7 离线安装部署PostgreSQL
- 十一 【Kubernetes】K8s笔记:Ingress 集群进出流量总管
- 快速安装 服务器之Apollo单机部署
- 云计算_OpenStack