k8s的安装

创建三台虚拟机

|--------|----------------|----|
| 名称 | IP | 说明 |
| master | 192.168.108.22 | |
| node1 | 192.168.108.10 | |
| node2 | 192.168.108.12 | |

参考资料:尚硅谷的Kubernetes(k8s)入门到实战教程

安装前操作

关闭防火墙

复制代码
systemctl stop firewalld
systemctl disable firewalld

关闭selinux

复制代码
#永久
sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config
#临时
setenforce 0

关闭swap

复制代码
临时关闭
swapoff -a
永久关闭
sed -ri 's/.*swap.*/#&/' /etc/fstab

添加hosts

复制代码
先给机器重命名
hostnamectl set-hostname master
hostnamectl set-hostname node1
hostnamectl set-hostname node2

cat >> /etc/hosts <<EOF 
192.168.108.22 master
192.168.108.10 node1
192.168.108.12 node2
EOF

把桥接的IPv4流量传递到iptables的链 (每台执行)

因为在Kubernetes中,将桥接的IPv4流量传递到iptables链通常是为了实现网络策略和服务发现。Kubernetes使用iptables来管理网络规则,以实现Pod之间的通信和外部流量的负载均衡。

复制代码
cat > /etc/sysctl.d/k8s.conf << EOF
net.bridge.bridge-nf-call-ip6tables = 1
net.bridge.bridge-nf-call-iptables = 1
EOF

# 生效
sysctl --system 

时间同步

复制代码
yum install  ntpdate -y
ntpdate time.windows.com
此命令将把你的系统时间设置为与time.windows.com服务器相同的时间。

安装docker

查看是否安装docker,若要安装新版本,要卸载旧版本的docker

复制代码
yum list installed | grep docker

yum remove -y docker*

yum 包更新到最新。

yum -y update

参考之前的文章Docker的学习记录-CSDN博客

//安装需要的软件包

复制代码
yum install -y yum-utils device-mapper-persistent-data lvm2

// 添加yum源

复制代码
yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo

// 设置yum源,并更新 yum 的包索引

复制代码
 yum makecache fast

可以查看所有仓库中所有docker版本,并选择特定版本安装

复制代码
yum list docker-ce --showduplicates | sort -r

安装指定版本
yum install -y docker-ce-18.06.3.ce-3.el7

启动并加入开机启动

复制代码
systemctl start docker && systemctl enable docker

参考文章

Docker实战一 Docker部署微服务_docker部署微服务项目-CSDN博客

相关推荐
tonngw7 小时前
【Mac 从 0 到 1 保姆级配置教程 16】- Docker 快速安装配置、常用命令以及实际项目演示
macos·docker·容器·开源·github·docker desktop·orbstack
Chan1610 小时前
【 SpringCloud | 微服务 MQ基础 】
java·spring·spring cloud·微服务·云原生·rabbitmq
2201_7611990412 小时前
k8s4部署
云原生·容器·kubernetes
慌ZHANG12 小时前
云原生技术驱动 IT 架构现代化转型:企业实践与落地策略全解
云原生
小柏ぁ12 小时前
calico/node is not ready: BIRD is not ready: BGP not established with xxx
运维·docker·kubernetes
三劫散仙13 小时前
kubernetes jenkins pipeline优化拉取大仓库性能指定分支+深度
容器·kubernetes·jenkins
西京刀客13 小时前
k8s热更新-subPath 不支持热更新
云原生·容器·kubernetes·configmap·subpath
weixin_4349362814 小时前
k8S 命令
linux·容器·kubernetes
nuczzz16 小时前
GPU虚拟化
docker·kubernetes·k8s·gpu·nvidia
Johny_Zhao17 小时前
2025年6月Docker镜像加速失效终极解决方案
linux·网络·网络安全·docker·信息安全·kubernetes·云计算·containerd·yum源·系统运维