从零开始搭建Kubernetes(k8s)集群(以master节点为例,slave节点类似)

文章目录前言正文1)系统初始化1. 安装阿里源及安装依赖包2. 设置系统主机名及host文件3. 安装依赖包4. 设置防火墙为 Iptables 并设置空规则5. 关闭SELINUX6. 跳转内核参数7. 调整系统时区9. 升级系统内核2)Kubeadm部署安装1. kube-proxy开启ipvs的前置条件2. 安装docker软件3. 安装 Kubeadm(没有科学上网的情况下,需要将源改为阿里源)4. 初始化主节点5. 判断是否安装成功6. 部署网络(flannel)7. 删除污点前言前期准备
摘要由CSDN通过智能技术生成

前言

前期准备

  1. centos7的操作系统
  2. 网络配置完成,静态ip并可以访问外网

正文

1)系统初始化

1. 安装阿里源(可以跳过)

mkdir /etc/yum.repos.d/bk
mv /etc/yum.repos.d/*.repo /etc/yum.repos.d/bk
curl -o /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo
curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
yum clean all
yum makecache
yum update -y

2. 设置系统主机名及host文件

hostnamectl set-hostname k8s-master
# 在/etc/hosts中追加
10.x.x.x k8s-master

3. 安装依赖包

yum install -y conntrack ntpdate ntp ipvsadm ipset jq iptables curl sysstat libseccomp wget vim net-tools git

4. 设置防火墙为 Iptables 并设置空规则

systemctl stop firewalld && systemctl disable firewalld
yum -y install iptables-services && systemctl start iptables && systemctl enable iptables&& iptables -F && service iptables save

5. 关闭SELINUX

swapoff -a && sed -i '/ swap / s/^\(.*\)$/#\1/g' /etc/fstab
setenforce 0 && sed -i 's/^SELINUX=.*/SELINUX=disabled/' /etc/selinux/config

6. 跳转内核参数

cat > kubernetes.conf << EOF
net.bridge.bridge-nf-call-iptables=1
net.bridge.bridge-nf-call-ip6tables=1
net.ipv4.ip_forward=1
net.ipv4.tcp_tw_recycle=0
vm.swappiness=0 # 禁止使用 swap 空间,只有当系统 OOM 时才允许使用它
vm.overcommit_memory=1 # 不检查物理内存是否够用
vm.panic_on_oom=0 # 开启 OOM
fs.inotify.max_user_instances=8192
fs.inotify.max_user_watches=1048576
fs.file-max=52706963
fs.nr_open=52706963
net.ipv6.conf.all.disable_ipv6=1
net.netfilter.nf_conntrack_max=2310720
EOF
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

wanghx7

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值