centos stream 9安装 Kubernetes v1.30 集群

1、版本说明:

系统版本:centos stream 9
Kubernetes版本:最新版(v1.30)
docker版本:27.1.1
节点主机名ip
主节点k8s-master172.31.0.10
节点1k8s-node1172.31.0.11
节点2k8s-node2172.31.0.12

2、首先,使用Vagrant和Virtualbox创建centos stream 9虚拟机。

2.1、安装Vagrant

vagrant官网下载地址:Install | Vagrant | HashiCorp Developer

这里我们下载Windows版的vagrant_2.4.1_windows_amd64.msi安装包,双击后进行安装:

勾选"I accept the terms in the License Agreement",点击"Install"进行安装。

点击"Finish",然后点击"Yes"重启电脑。

重启之后,我们的vagrant就可以使用了。

2.2、安装Virtualbox

Virtualbox下载地址:

下载VirtualBox-7.0.20-163906-Win.exeicon-default.png?t=N7T8https://download.virtualbox.org/virtualbox/7.0.20/VirtualBox-7.0.20-163906-Win.exe安装包。

然后进行安装:

virtualbox默认是安装在c盘,我不想安装在c盘,修改到了d盘,在安装过程中出现了下面的报错:

然后在打开cmd命令行,执行下面官网说的命令:

icacls D:\virtualbox /reset /t /c
icacls D:\virtualbox /inheritance:d /t /c
icacls D:\virtualbox /grant *S-1-5-32-545:(OI)(CI)(RX)
icacls D:\virtualbox /deny *S-1-5-32-545:(DE,WD,AD,WEA,WA)
icacls D:\virtualbox /grant *S-1-5-11:(OI)(CI)(RX)
icacls D:\virtualbox /deny *S-1-5-11:(DE,WD,AD,WEA,WA)

命令执行成功后继续接下来的步骤。

这样,virtualbox就安装完成了。安装完之后记得重启一下电脑。

2.3、使用Vagrant快速安装Centos stream 9虚拟机,并自动在在虚拟机中安装好docker。

2.3.1、首先,在D盘创建一个vagrant的文件夹(可以自定义其他的目录),然后在文件夹中创建centos_stream_9的文件夹。然后创建名为:Vagrantfile的文件。注意这个文件就叫这个名字不能更改。

Vagrantfile的文件内容如下:

# -*- mode: ruby -*-
# vi: set ft=ruby :# All Vagrant configuration is done below. The "2" in Vagrant.configure
# configures the configuration version (we support older styles for
# backwards compatibility). Please don't change it unless you know what
# you're doing.
Vagrant.configure("2") do |config|# The most common configuration options are documented and commented below.# For a complete reference, please see the online documentation at# https://docs.vagrantup.com.# Every Vagrant development environment requires a box. You can search for# boxes at https://vagrantcloud.com/search.config.vm.box = "eurolinux-vagrant/centos-stream-9"config.vm.box_version = "9.0.45"# Disable automatic box update checking. If you disable this, then# boxes will only be checked for updates when the user runs# `vagrant box outdated`. This is not recommended.# config.vm.box_check_update = false# Create a forwarded port mapping which allows access to a specific port# within the machine from a port on the host machine. In the example below,# accessing "localhost:8080" will access port 80 on the guest machine.# NOTE: This will enable public access to the opened port# config.vm.network "forwarded_port", guest: 80, host: 8080# Create a forwarded port mapping which allows access to a specific port# within the machine from a port on the host machine and only allow access# via 127.0.0.1 to disable public access# config.vm.network "forwarded_port", guest: 80, host: 8080, host_ip: "127.0.0.1"# Create a private network, which allows host-only access to the machine# using a specific IP.# 指定虚拟机网络ip为:172.31.0.10config.vm.network "private_network", ip: "172.31.0.10"# Create a public network, which generally matched to bridged network.# Bridged networks make the machine appear as another physical device on# your network.# config.vm.network "public_network"# Share an additional folder to the guest VM. The first argument is# the path on the host to the actual folder. The second argument is# the path on the guest to mount the folder. And the optional third# argument is a set of non-required options.# config.vm.synced_folder "../data", "/vagrant_data"# Disable the default share of the current code directory. Doing this# provides improved isolation between the vagrant box and your host# by making sure your Vagrantfile isn't accessible to the vagrant box.# If you use this you may want to enable additional shared subfolders as# shown above.# config.vm.synced_folder ".", "/vagrant", disabled: true# Provider-specific configuration so you can fine-tune various# backing providers for Vagrant. These expose provider-specific options.# Example for VirtualBox:## config.vm.provider "virtualbox" do |vb|#   # Display the VirtualBox GUI when booting the machine#   vb.gui = true##   # Customize the amount of memory on the VM:#   vb.memory = "1024"# end## View the documentation for the provider you are using for more# information on available options.# Enable provisioning with a shell script. Additional provisioners such as# Ansible, Chef, Docker, Puppet and Salt are also available. Please see the# documentation for more information about their specific syntax and use.config.vm.provision "shell", inline: <<-SHELL# 1、Docker安装# 1.1、卸载旧版本dockersudo yum remove docker docker-client docker-client-latest docker-common docker-latest docker-latest-logrotate docker-logrotate docker-engine# 1.2、设置存储库sudo yum install -y yum-utilssudo yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo# 1.3、安装 Docker Enginesudo yum install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-pluginsudo systemctl enable dockersudo systemctl start docker# 1.4、禁用防火墙sudo systemctl stop firewalldsudo systemctl disable firewalld# 1.5、修改 SSH 配置sudo sed -i 's/^#*PasswordAuthentication .*/PasswordAuthentication yes/' /etc/ssh/sshd_configsudo sed -i 's/^#*PermitRootLogin .*/PermitRootLogin yes/' /etc/ssh/sshd_config# 1.6、重启 SSH 服务sudo systemctl restart sshd.service# 1.7、修改 root 用户密码echo "root:1TdhblkFcdhx2a" | sudo chpasswd# 1.8、配置 Docker 镜像加速mkdir -p /etc/dockercat > /etc/docker/daemon.json <<EOF{"registry-mirrors": ["https://6kx4zyno.mirror.aliyuncs.com","https://registry.docker-cn.com"],"exec-opts": ["native.cgroupdriver=systemd"]}
EOFsudo systemctl daemon-reloadsudo systemctl restart docker# 2、配置非root用户(Docker)执行docker命令时不使用sudo。# 2.1、创建名为 "Docker" 的用户sudo useradd Docker# 2.2、设置 "Docker" 用户的密码echo "Docker:1TdhblkFcdhx2a" | sudo chpasswd# 2.3、创建名为 "docker" 的组sudo groupadd docker# 2.4、将用户 "Docker" 添加到组 "docker"sudo gpasswd -a Docker docker# 2.5、重启dockersudo systemctl restart dockerSHELL
end

在弹出的cmd命令框中输入下面的命令:

vagrant up

等待执行完之后,我们就可以得到一台安装好Docker并且运行的centos stream 9的虚拟机。第一次执行的时候因为会下载centos stream 9的镜像文件,所以会很慢,我大概等了20分钟。成功以后再次安装centos stream 9就很快了。

我们打开virtualbox,就可以看到这个虚拟机正在运行。

使用MobaXterm或者其他ssh工具连接这个虚拟机。

MobaXterm下载地址:MobaXterm free Xserver and tabbed SSH client for Windows

虚拟机连接信息如下:

IP:172.31.0.10

用户:root

密码:1TdhblkFcdhx2a

密码可能有些长,这样记忆:一条大河波浪宽,风吹稻花香两岸。

3、Kubernetes集群

Kubernetes官方文档地址:

3.1、通过kubeadm快速安装Kubernetes集群

Kubernetes从v1.4版本开始引入了命令行工具kubeadm,以简化集群的安装过程,到v1.13版本时,kubeadm已经达到GA阶段。

3.1.1、在安装kubeadm前,需要关闭Linux的系统交换分区(swap),这可以通过下面的命令实现:

#关闭swap
swapoff -a  
sed -ri 's/.*swap.*/#&/' /etc/fstab

3.1.2、然后,将 SELinux 设置为 permissive 模式(相当于将其禁用)。

# 将 SELinux 设置为 permissive 模式(相当于将其禁用)
sudo setenforce 0
sudo sed -i 's/^SELINUX=enforcing$/SELINUX=permissive/' /etc/selinux/config

3.1.3、修改/etc/hosts文件,添加域名映射

# 所有机器添加master的域名映射,保证各个node节点可以ping通master。以下需要修改为自己的IP和域名。

echo "172.31.0.10  k8s-master" >> /etc/hosts

# 添加这个映射,解决后期calico网络插件安装的报错。

echo "185.199.111.133 raw.githubusercontent.com" >> /etc/hosts

3.1.4、允许 iptables 检查桥接流量

按照步骤执行下面的命令:

cat <<EOF | sudo tee /etc/modules-load.d/k8s.conf
overlay
br_netfilter
EOF

sudo modprobe overlay

sudo modprobe br_netfilter

cat <<EOF | sudo tee /etc/sysctl.d/k8s.conf
net.bridge.bridge-nf-call-ip6tables = 1
net.bridge.bridge-nf-call-iptables = 1
net.ipv4.ip_forward = 1
vm.swappiness = 0
EOF

sudo sysctl --system

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://xiahunao.cn/news/3269787.html

如若内容造成侵权/违法违规/事实不符,请联系瞎胡闹网进行投诉反馈,一经查实,立即删除!

相关文章

【2024年国际高等学校数学建模竞赛IMMCHE】问题 B:太空移民计划和战略 问题分析及数学模型及求解代码

【2024年国际高等学校数学建模竞赛IMMCHE】问题 B&#xff1a;太空移民计划和战略 问题分析及数学模型及求解代码 Problem B: Space Migration Program and Strategy 1 题目 我们的未来有两种可能&#xff1a;第一&#xff0c;我们将留在地球上&#xff0c;直到完全灭绝&…

Hive3:Hive初体验

1、创建表 CREATE TABLE test(id INT, name STRING, gender STRING);2、新增数据 INSERT INTO test VALUES(1, 王力红, 男); INSERT INTO test VALUES(2, 钉钉盯, 女); INSERT INTO test VALUES(3, 咔咔咔, 女);3、查询数据 简单查询 select * from test;带聚合函数的查询 …

Halcon 引擎方式调试

1.C# 端添加代码 启动调试模式 public HDevEngine MyEngine new HDevEngine(); // halcon引擎;// 启动调试服务 MyEngine.StartDebugServer();2.Halcon程序添加到进程 打开Halcon程序 【执行】>【附加到进程】 点击【确定】 3.C# 程序执行到相关位置 C# 程序执行调用…

vector深度剖析及模拟实现

目录 前言vector核心框架模拟实现1. 前期准备2. 构造和销毁补充: 隐式类型转换和多参数构造的区别 3. 迭代器相关4. 容器相关补充: memcpy拷贝问题 5. 元素访问6. vector的修改测试代码 总结 前言 本文重点模拟实现vector的核心接口, 帮助我们更好的理解底层逻辑, 以及对vecto…

科学又省力 宠物浮毛怎么去掉便捷高效?除毛秘籍养宠空气净化器

上次和朋友逛完街去她家&#xff0c;她家的猫哈基米一开门就飞奔过来&#xff0c;朋友直接抱起它狂亲。结果&#xff0c;猫毛和汗水粘得到处都是&#xff0c;手臂上、脸上都是&#xff0c;看得我这鼻炎星人直起鸡皮疙瘩。很多养宠物的朋友都说&#xff0c;天天给猫狗梳毛&#…

Android Studio导入源码

在有源码并且编译环境可用的情况下&#xff1a; 1.生成导入AS所需的配置文件 在源码的根目录执行以下命令&#xff1a; source build/ensetup.sh lunch 要编译的项目 make idegen //这一步会生成out/host/linux-x86/framework/idegen.jar development/tools/idegen/idegen.sh…

利用OSMnx求路网最短路径并可视化(二)

书接上回&#xff0c;为了增加多路径的可视化效果和坐标匹配最近点来实现最短路可视化&#xff0c;我们使用图形化工具matplotlib结合OSMnx的绘图功能来展示整个路网图&#xff0c;并特别高亮显示计算出的最短路径。 多起终点最短路路径并计算距离和时间 完整代码#运行环境 P…

《昇思25天学习打卡营第24天|基于MindSpore通过GPT实现情感分类》

基于MindSpore通过GPT实现情感分类 %%capture captured_output # 实验环境已经预装了mindspore2.2.14&#xff0c;如需更换mindspore版本&#xff0c;可更改下面mindspore的版本号 !pip uninstall mindspore -y !pip install -i https://pypi.mirrors.ustc.edu.cn/simple mind…

自动化测试 pytest 中 scope 限制 fixture使用范围!

导读 fixture 是 pytest 中一个非常重要的模块&#xff0c;可以让代码更加简洁。 fixture 的 autouse 为 True 可以自动化加载 fixture。 如果不想每条用例执行前都运行初始化方法(可能多个fixture)怎么办&#xff1f;可不可以只运行一次初始化方法&#xff1f; 答&#xf…

C语言进阶 11.结构体

C语言进阶 11.结构体 文章目录 C语言进阶 11.结构体11.1. 枚举11.2. 结构类型11.3. 结构与函数11.4. 结构中的结构11.5. 类型定义11.6. 联合11.7. PAT11-0. 平面向量加法(10)11-1. 通讯录的录入与显示(10) 11.1. 枚举 常量符号化: 用符号而不是具体的数字表示程序中的数字 cons…

【C++深度探索】AVL树与红黑树的原理与特性

&#x1f525; 个人主页&#xff1a;大耳朵土土垚 &#x1f525; 所属专栏&#xff1a;C从入门至进阶 这里将会不定期更新有关C/C的内容&#xff0c;欢迎大家点赞&#xff0c;收藏&#xff0c;评论&#x1f973;&#x1f973;&#x1f389;&#x1f389;&#x1f389; 前言 前…

渣土车与搅拌车安全问题解析及智能监控解决方案

一、背景分析 近年来&#xff0c;渣土车在货物运输中由于超载超速、违规驾驶、车辆盲区过大等问题导致的事故频发&#xff0c;严重影响了人们的生命财产安全。而搅拌车作为一种特殊的运输车辆&#xff0c;在混凝土输送过程中也存在类似的隐患。针对这些问题&#xff0c;对搅拌…

多维矩阵乘积运算和对应的广播机制

神经网络中的多维矩阵乘积运算&#xff1a; 遵循的原则是&#xff1a; 两张量前两维度应该是相同的&#xff0c;如果不同则其中一张量维度为1。 如果有论文中有遇到矩阵乘积的两项维度不一致&#xff0c;那就考虑它计算时是使用了广播机制&#xff08;如YOLACT&#xff09;。…

谁说只有车载HMI界面?现在工业类的HMI界面UI也崛起了

谁说只有车载HMI界面&#xff1f;现在工业类的HMI界面UI也崛起了 引言 艾斯视觉作为行业ui设计和前端开发领域的从业者&#xff0c;其观点始终认为&#xff1a;工业自动化和智能化水平不断提高&#xff0c;人机界面&#xff08;Human-Machine Interface&#xff0c;简称HMI&a…

Lombok的认识

Lombok的作用 Lombok是一个Java库&#xff0c;它可以通过简单的注解形式来帮助开发人员简化Java代码的编写&#xff0c;特别是减少模板代码的书写。具体来说&#xff0c;Lombok的主要作用包括&#xff1a; 减少模板代码&#xff1a;Lombok可以通过注解自动生成getter、setter、…

QT opencv常用代码备忘

最近在了解qt opencv的一些用法&#xff0c;把常用的代码记下来方便需要时复制使用 在默认.pro文件加入opencv包含路径和库文件 QT core guigreaterThan(QT_MAJOR_VERSION, 4): QT widgetsCONFIG c17# You can make your code fail to compile if it uses deprecate…

网络钓鱼抓肉鸡实验

实验背景 网络钓鱼&#xff0c;攻击一台服务器或普通主机时&#xff0c;很可能会将这台服务器或主机变成“傀儡机”&#xff0c;帮助它攻击其它的主机&#xff0c;以达到窃取更多信息、组建僵尸网络、DDOS攻击等目的&#xff0c;危害性极大 其中僵尸网络&#xff08;Botnet&a…

运维锅总详解NFS

NFS是什么&#xff1f;如何对NFS进行部署及优化&#xff1f;NFS工作流程是什么&#xff1f;NFS的性能及优缺点是什么&#xff1f;NFS发展历史又是怎样的&#xff1f;希望本文能帮您解答这些疑惑&#xff01; 一、NFS简介 NFS (Network File System) 是由 Sun Microsystems 在…

rem实现屏幕适配(jQuery)

一、rem换算 1.根据视口宽度动态计算字体大小&#xff0c;如果宽度大于750px&#xff0c;则将字体大小设置为100px&#xff0c;否则按比例缩小。 tips:使用时记得引入jQuery.js // 在文档加载完成后执行函数&#xff0c;确保DOM已经准备就绪$(function () {// 定义一个自执行…

二叉树详解-第四篇 二叉树链式结构的实现

目录 1.二叉树的遍历 1.1前序遍历&#xff1a; 1.2 中序遍历&#xff1a; 1.3 后序遍历&#xff1a; 2.二叉树链式结构的实现 2.1 Tree.h 2.2 Tree.cpp 2.2.1 前序遍历 void PreOrder(TNode* Root) 2.2.2 中序遍历 void InOrder(TNode* Root) 2.2.3 后序遍历 void Bac…