1.2、安装k8s-node1 和 k8s-node2节点虚拟机

news2025/1/12 13:18:56

        k8s-master节点的虚拟机环境弄好之后,这小节继续介绍k8s-node1 和 k8s-node2节点虚拟机环境安装。

节点主机名ip
主节点k8s-master172.31.0.10
节点1k8s-node1172.31.0.11
节点2k8s-node2172.31.0.12
  •  在D:\vagrant目录下新建centos_stream_9_node1文件夹,然后在文件夹中新建Vagrantfile文件。

centos_stream_9_node1节点的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.11
  config.vm.network "private_network", ip: "172.31.0.11"

  # 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", bridge: "Intel(R) Wi-Fi 6 AX200 160MHz"

  # 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、卸载旧版本docker
  sudo 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-utils
  sudo yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
  # 1.3、安装 Docker Engine
  sudo yum install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
  sudo systemctl enable docker
  sudo systemctl start docker
  # 1.4、禁用防火墙
  sudo systemctl stop firewalld
  sudo systemctl disable firewalld
  # 1.5、修改 SSH 配置
  sudo sed -i 's/^#*PasswordAuthentication .*/PasswordAuthentication yes/' /etc/ssh/sshd_config
  sudo 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/docker
  cat > /etc/docker/daemon.json <<EOF
  {
    "registry-mirrors": ["https://registry.docker-cn.com","https://docker.mirrors.ustc.edu.cn"],
    "exec-opts": ["native.cgroupdriver=systemd"]
  }
EOF
  # 1.9、配置HTTP/HTTPS 网络代理 使用Docker的过程中,因为网络原因,通常需要使用 HTTP/HTTPS 代理来加速镜像拉取、构建和使用。
  # 为 dockerd 设置网络代理 "docker pull" 命令是由 dockerd 守护进程执行。而 dockerd 守护进程是由 systemd 管理。因此,如果需要在执行 "docker pull" 命令时使用 HTTP/HTTPS 代理,需要通过 systemd 配置。
  # 1.9.1、为 dockerd 创建配置文件夹。(mkdir -p /etc/systemd/system/docker.service.d)
  # 1.9.2、为 dockerd 创建 HTTP/HTTPS 网络代理的配置文件,文件路径是 /etc/systemd/system/docker.service.d/http-proxy.conf 。并在该文件中添加相关环境变量。
  sudo sh -c 'mkdir -p /etc/systemd/system/docker.service.d && \
    cat <<EOF > /etc/systemd/system/docker.service.d/http-proxy.conf
[Service]
Environment="HTTP_PROXY=http://172.31.0.1:7890/"
Environment="HTTPS_PROXY=http://172.31.0.1:7890/"
Environment="NO_PROXY=localhost,127.0.0.1,.example.com"
EOF'
  sudo systemctl daemon-reload
  sudo 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、重启docker
  sudo systemctl restart docker

  SHELL
end
  • 在D:\vagrant\centos_stream_9_node1目录这里点击一下,然后输入"cmd",在弹出的cmd命令框中输入:"vagrant up"命令,进行虚拟机创建。

  • 在D:\vagrant目录下新建centos_stream_9_node2文件夹,然后在文件夹中新建Vagrantfile文件。

centos_stream_9_node2节点的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.12
  config.vm.network "private_network", ip: "172.31.0.12"

  # 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", bridge: "Intel(R) Wi-Fi 6 AX200 160MHz"

  # 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、卸载旧版本docker
  sudo 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-utils
  sudo yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
  # 1.3、安装 Docker Engine
  sudo yum install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
  sudo systemctl enable docker
  sudo systemctl start docker
  # 1.4、禁用防火墙
  sudo systemctl stop firewalld
  sudo systemctl disable firewalld
  # 1.5、修改 SSH 配置
  sudo sed -i 's/^#*PasswordAuthentication .*/PasswordAuthentication yes/' /etc/ssh/sshd_config
  sudo 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/docker
  cat > /etc/docker/daemon.json <<EOF
  {
    "registry-mirrors": ["https://registry.docker-cn.com","https://docker.mirrors.ustc.edu.cn"],
    "exec-opts": ["native.cgroupdriver=systemd"]
  }
EOF
  # 1.9、配置HTTP/HTTPS 网络代理 使用Docker的过程中,因为网络原因,通常需要使用 HTTP/HTTPS 代理来加速镜像拉取、构建和使用。
  # 为 dockerd 设置网络代理 "docker pull" 命令是由 dockerd 守护进程执行。而 dockerd 守护进程是由 systemd 管理。因此,如果需要在执行 "docker pull" 命令时使用 HTTP/HTTPS 代理,需要通过 systemd 配置。
  # 1.9.1、为 dockerd 创建配置文件夹。(mkdir -p /etc/systemd/system/docker.service.d)
  # 1.9.2、为 dockerd 创建 HTTP/HTTPS 网络代理的配置文件,文件路径是 /etc/systemd/system/docker.service.d/http-proxy.conf 。并在该文件中添加相关环境变量。
  sudo sh -c 'mkdir -p /etc/systemd/system/docker.service.d && \
    cat <<EOF > /etc/systemd/system/docker.service.d/http-proxy.conf
[Service]
Environment="HTTP_PROXY=http://172.31.0.1:7890/"
Environment="HTTPS_PROXY=http://172.31.0.1:7890/"
Environment="NO_PROXY=localhost,127.0.0.1,.example.com"
EOF'
  sudo systemctl daemon-reload
  sudo 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、重启docker
  sudo systemctl restart docker

  SHELL
end

  • 在D:\vagrant\centos_stream_9_node2目录这里点击一下,然后输入"cmd",在弹出的cmd命令框中输入:"vagrant up"命令,进行虚拟机创建。

  • 等待两个虚拟机创建完成

现在我们就创建好k8s-node1节点(172.31.0.11)和k8s-node2节点(172.31.0.12)的虚拟机了,它们两个虚拟机root账号的密码都是:1TdhblkFcdhx2a

  • 使用ssh工具MobaXterm连接k8s-node1节点(172.31.0.11)和k8s-node2节点(172.31.0.12)

现在,我们就配置好k8s-node1和k8s-node2节点的虚拟机,并在两台虚拟机中安装好Docker。

接下来,我们要在k8s-master上面 安装 kubeadm,然后用 kubeadm 安装k8s集群。

请看下一篇文章:

1.3、k8s-master上面安装 kubeadm-CSDN博客

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

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

相关文章

如何在Python中使用网页抓取API获得Google搜索结果

SERP是搜索引擎结果页的缩写&#xff0c;它是你在百度、谷歌、Bing等搜索引擎中提交查询后所得到的页面。搜索引擎需要给所有页面做排序&#xff0c;把最能解决我们需求的页面展示给我们&#xff0c;企业会非常关注结果页的排序&#xff0c;也就是本企业内容的自然排名情况。手…

革新IT架构管理,宝兰德全新中间件统一管理平台助力企业数字化转型

近期&#xff0c;宝兰德在金融行业科技盛会“2024中国国际金融展”上正式发布了拳头产品「中间件统一管理平台MCP2.0」&#xff0c;旨在推动业务与中间件解耦&#xff0c;解决中间件管理中的版本不统一、自动化程度低、监控不完善、运维效率低、管理分散等问题&#xff0c;实现…

8月1日学习笔记 java环境安装以及tomcat配置

一&#xff0c;java环境安装 1. 效果 2. 步骤 1. 下载 jdk22 # 官网地址 https://www.oracle.com/cn/java/technologies/download s/ wget https://download.oracle.com/java/22/latest/jdk- 22_linux-x64_bin.tar.gz 2. 解压 tar -zxvf jdk-22.2.tar.gz 3. 移动到 us…

快速搞定分布式Kafka

本文从kafka中的实际应用场景分析&#xff0c;讲述kafka的一些基本概念。再讲述zookeeper集群环境的构建&#xff1b;kafka的搭建以及脚本文件编写&#xff1b;最后是一个快速入门的demo.内容会比较多&#xff0c;希望大家能有所收获&#xff01; 1.Kafka(MQ)实战应用场景剖析…

linux系统ShellCheck检查shell脚步语法正确的工具

目录 ShellCheck 安装ShellCheck 、dnf、yum 源代码编译 步骤如下&#xff1a; 示例命令&#xff1a; 方法三&#xff1a;使用其他第三方仓库、COPR 仓库 假设 ShellCheck 输出如下&#xff1a; 分析输出 修改脚本 再次运行 ShellCheck 1. Shell 脚本最佳实践 主题…

vcpkg install libtorch[cuda] -allow-unsupported-compiler

在vcpkg中不懂如何使用 nvcc 的 -allow-unsupported-compiler, 所以直接注释了CUDA中对版本的检查代码. C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.8\include\crt\host_config.h 奇了怪了,我是用的是vs2022,但是还是被检查为不支持的编译器!!! 可以试一下改这…

搭建gitlab代码托管仓库(解决centos7无法使用默认数据源问题)

公司的gitlab由于停电&#xff0c;又崩了&#xff0c;每次停电都会崩掉。所以就想到自己学一下搭建gitlab代码中心&#xff0c;后面在搞一个jenkins自动发版学习一下&#xff0c;慢慢搞吧。 在弄的时候&#xff0c;发现Centos7居然在2024年6月31日停止维护了。这就离谱了&…

职教国培丨高职教师数据分析与挖掘课程实施能力提升培训班莅临泰迪智能科技参观调研

7月28日&#xff0c;由广东机电职业技术学院牵头&#xff0c;广东泰迪智能科技股份有限公司为合作单位的“2024年高职教师数据分析与挖掘课程实施能力提升培训班”老师莅临广东泰迪智能科技股份有限公司产教融合实训基地参观调研&#xff0c;来自广东省各地36位高校教师参与本次…

如何在 Kali Linux 上安装和使用 Docker 和 Docker Compose

Docker 和 Docker Compose 是现代开发者必备的工具&#xff0c;特别是当你需要在不同的环境中部署应用时。本文将详细介绍如何在 Kali Linux 上安装 Docker 和 Docker Compose&#xff0c;并使用它们启动服务。即使你是个技术小白&#xff0c;也能轻松跟随这篇指南完成操作。 …

Ecovadis认证:企业申请Ecovadis认证条件

Ecovadis认证是一种用于评估和评价企业可持续发展绩效的认证体系。该认证由Ecovadis公司提供&#xff0c;目的是帮助公司了解和改善其环境、社会和治理&#xff08;ESG&#xff09;实践。 Ecovadis认证主要基于四个方面进行评估&#xff1a;环境、劳工和人权、道德采购以及可持…

Python——记录pip问题(解决下载慢、升级失败问题)

在python开发中&#xff0c;经常需要使用到各种各样的库。 pip又是我们常用的安装工具。但是国外的源下载速度实在太慢&#xff0c;经常导致超时。 有很多朋友刚刚学Python的时候&#xff0c;会来问为什么pip下载东西这么慢啊&#xff1f; 而且pycharm里面下载库也是非常的慢…

Linux服务器安装MySQL8.0

序号类型地址1MySQLLinux&#xff08;centos 7.5&#xff09;服务器安装MySQL5.72MySQLLinux服务器安装MySQL8.03MySQLMySQL操作之概念、SQL约束&#xff08;一&#xff09;4MySQLMySQL操作之数据定义语言&#xff08;DDL)&#xff08;二&#xff09;5MySQLMySQL操作之数据操作…

React三原理和路由

代码下载 React 组件通讯原理 setState() 说明 setState() 是异步更新数据的&#xff0c;使用该语法时&#xff0c;后面的 setState() 不要依赖于前面的 setState()&#xff0c;可以多次调用 setState() &#xff0c;只会触发一次重新渲染&#xff1a; this.setState({ coun…

CPQ报价管理系统 | 成本报价CPQ解决方案

一、成本报价流程现状 1、传统流程 2、业务痛点 ①、数据手工重复输入环节多、易错&#xff0c;为保障准确性需多次复核&#xff0c;影响报价效率 ②、原材波动较大&#xff0c;但是当前询价流程只有一次性&#xff0c;原材成本发生变化&#xff0c;无法及时更新变化提醒报价…

类和对象(作业篇)

简简单单整理一下咱们的小作业&#xff0c;这次的作业比较简单&#xff0c;只有选择题&#xff1a; public class Test{private float f1.0f;int m12;static int n1;public static void main(String args[]){Test tnew Test();} }A&#xff1a;抛开private不说&#xff0c;先看…

解析顺序表【数据结构】

1.线性表 线性表&#xff08;linear list&#xff09;是n个具有相同特性的数据元素的有线序列。线性表是一种在实际中广泛使用的数据结构&#xff0c;常见的线性表有&#xff1a;顺序表、链表、栈、队列、字符串… 线性表在逻辑上是线性结构&#xff0c;也就是说是连续的一条线…

HTML 字符集详解及示例

文章目录 摘要引言从ASCII到UTF-8的演变ASCII 字符集ANSI字符集ISO-8859-1字符集UTF-8字符集 示例代码运行Demo小结表格总结未来展望参考资料 摘要 本文介绍了HTML中的字符集演变历史&#xff0c;从最初的ASCII到现代的UTF-8&#xff0c;并提供了设置字符集的示例代码。文中涵…

图形编辑器基于Paper.js教程10:导入导出svg,导入导出json数据

深入了解Paper.js&#xff1a;实现SVG和JSON的导入导出功能 Paper.js是一款强大的矢量绘图JavaScript库&#xff0c;非常适合用于复杂的图形处理和交互式网页应用。本文将详细介绍如何在Paper.js项目中实现SVG和JSON格式的导入导出功能&#xff0c;这对于开发动态图形编辑器等…

git reset --soft(回退commit,保留add)

参考博客&#xff1a;git reset --soft命令的使用-CSDN博客感觉博客中举的例子不是很好。读者自行判断。举的例子的场景适合使用revert&#xff0c;撤销就行了。另外建议看下边这篇博客&#xff0c;这篇详细介绍了reset和revert&#xff0c;带图。但是要注意这个reset是hard的&…

mysql 内存一直增长(memory/sql/thd::main_mem_root)

mysql版本 8.0.14 发现过程 查询总内存 SELECT t.EVENT_NAME, t.CURRENT_NUMBER_OF_BYTES_USED FROM performance_schema.memory_summary_global_by_event_name t ORDER BY t.CURRENT_NUMBER_OF_BYTES_USED DESC;前&#xff1a; memory/sql/thd::main_mem_root 1…