当前位置: 首页 > news >正文

MacOS使用Multipass快速搭建轻量级k3s集群

使用Homebrew安装Multipass(macOS系统)

brew install multipass --cask

创建一个名为k3s的Multipass虚拟机,分配2G内存、10G硬盘和1个CPU核心

multipass launch --name k3s --mem 2G --disk 10G --cpus 1

进入虚拟机的shell环境

multipass shell k3s

使用国内镜像源安装k3s(Rancher中国镜像站)

curl -sfL https://rancher-mirror.rancher.cn/k3s/k3s-install.sh | INSTALL_K3S_MIRROR=cn sh -

停止k3s服务以便修改配置

sudo systemctl stop k3s

确保进入当前用户home目录

cd

创建.kube配置目录

mkdir .kube

复制k3s配置文件到用户目录

sudo cp /etc/rancher/k3s/k3s.yaml .kube/config

将配置文件所有权改为当前用户

sudo chown (id−u):(id -u):(idu):(id -g) .kube/config

查看k3s服务状态(主要是为了找到服务配置文件路径)

systemctl status k3s

编辑k3s服务配置文件

sudo nano /etc/systemd/system/k3s.service

在ExecStart行末尾追加以下参数(注意转义符和空格):

–write-kubeconfig=/home/ubuntu/.kube/config \
–write-kubeconfig-mode=644 \

重新加载systemd配置

sudo systemctl daemon-reload

启动k3s服务

sudo systemctl start k3s

验证节点状态

kubectl get node

配置镜像仓库源

cat > /etc/rancher/k3s/registries.yaml <<EOF
mirrors:
docker.io:
endpoint:
- “https://registry.cn-hangzhou.aliyuncs.com/”
quay.io:
endpoint:
- “https://quay.tencentcloudcr.com/”
registry.k8s.io:
endpoint:
- “https://registry.aliyuncs.com/v2/google_containers”
gcr.io:
endpoint:
- “https://gcr.m.daocloud.io/”
k8s.gcr.io:
endpoint:
- “https://registry.aliyuncs.com/google_containers”
ghcr.io:
endpoint:
- “https://ghcr.m.daocloud.io/”
EOF

重新启动k3s服务

sudo systemctl restart k3s

停止虚拟机实例

multipass stop k3s

启动虚拟机实例

multipass start k3s

删除虚拟机实例

multipass delete -p k3s

查看虚拟机实例列表

multipass list

参考

https://zhuanlan.zhihu.com/p/499810063
https://juejin.cn/post/7189945206085517367

http://www.lryc.cn/news/586776.html

相关文章:

  • mac上BRPC的CMakeLists.txt优化:解决Protobuf路径问题
  • TensorFlow深度学习实战(24)——变分自编码器详解与实现
  • Vue 3 动态ref问题
  • 封装---统一封装处理页面标题
  • C++模版编程:类模版与继承
  • Qt 3D模块加载复杂模型
  • vue应用如何实现在 A 标签页登出,希望 B 标签页也自动感知并退出登录
  • 语音识别的速度革命:从 Whisper 到 Whisper-CTranslate2,我经历了什么?
  • 数据库3.0
  • HarmonyOS-ArkUI Web控件基础铺垫1-HTTP协议-数据包内容
  • EPLAN多项目并行,电气设计许可如何不浪费?
  • (S4)Efficiently Modeling Long Sequences with Structured State Spaces论文精读(逐段解析)
  • ReAct论文解读(1)—什么是ReAct?
  • 基于YOLOv11的无人机目标检测实战(Windows环境)
  • Spring Cloud Gateway 实战指南
  • 力扣经典算法篇-21- 两数之和 II - 输入有序数组(固定一端 + 二分查找法,双指针法)
  • MongoDB性能优化实战指南:原理、实践与案例
  • git实际工作流程
  • 【零基础入门unity游戏开发——unity3D篇】3D光源之——unity反射和反射探针技术
  • SPSSPRO:数据分析市场SaaS挑战者的战略分析
  • 深入解析Hadoop架构设计:原理、组件与应用
  • (2)从零开发 Chrome 插件:实现 API 登录与本地存储功能
  • 代码随想录|图论|14有向图的完全可达性
  • 基于Prompt结构的语校解析:3H日本语学校信息建模实录(4/500)
  • Java求职面试:从Spring到微服务的全面挑战
  • AI进化论12:大语言模型的爆发——GPT系列“出圈”,AI飞入寻常百姓家
  • 碳水循环(增肌、减脂)
  • VISUALBERT:一个简单且高效的视觉与语言基线模型
  • 【读书笔记】《Effective Modern C++》第3章 Moving to Modern C++
  • 14.ResourceMangaer启动解析