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博客

相关推荐
阿里云云原生12 小时前
阿里云 Agent Native Cloud:让智能体成为企业原生的能力
云原生·agent
小码哥哥12 小时前
云原生时代的企业AI知识库:从云生态融合到多云知识治理
人工智能·云原生
关关长语12 小时前
Wsl解决MySQL容器跨域权限问题
mysql·docker·容器
Geek-Chow15 小时前
Connecting kubectl to a Private EKS Cluster Over an Internal Domain
kubernetes·k8s·aws
人间凡尔赛19 小时前
Post-Kubernetes 时代:2026 云原生架构从 Cloud Native 到 AI Native 的范式跃迁
云原生·架构·kubernetes
运维大师20 小时前
【K8S 运维实战】03-网络模型实战CNI
运维·网络·kubernetes
运维大师20 小时前
【K8S 运维实战】04-存储体系梳理CSI
运维·容器·kubernetes
AOwhisky20 小时前
Python 学习笔记(第十一期)——运维自动化(上·后篇):进程级监控与子进程管理——psutil进阶
运维·开发语言·python·学习·云原生·运维开发
heimeiyingwang1 天前
【架构实战】GitOps实践:Kubernetes上的声明式交付
elasticsearch·架构·kubernetes
Ai拆代码的曹操1 天前
K8s Pod Pending 逐层排查:从 FailedScheduling 到 PVC StorageClass 不存在的实战记录
java·linux·kubernetes