ubuntu 18 安装rancher/rancher 2.0 并制定本地registry

本文详细介绍如何通过Docker、VirtualBox及Rancher搭建Kubernetes集群的过程。从安装Docker及VirtualBox开始,到配置主机、建立Kubernetes集群,直至运行Registry单机版,并配置Registry非HTTPS客户端。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

1、安装docker

sudo apt-get install docker.io

docker的版本:Docker version 17.12.1-ce

2、安装virtualbox-qt,因为virtualbox-5.2无法安装

sudo apt-get install virtualbox-qt

3、运行rancher

sudo docker run -d --restart=unless-stopped -p 80:80 -p 443:443 rancher/rancher:stable

rancher的版本是:v2.0.8

4、安装配置主机

在virtualbox-qt创建新的虚拟机,我选择的是ubuntuserver,网络使用桥接模式。hostname设置为k8sNode1.

(1)检查文件/etc/hosts,确保有hostname和本机IP的配置:
       对于master应该有这么一行:[IP地址] master
       对于node1应该有这么一样:[IP地址] k8sNode1

(2)

  1. 打开文件/etc/sysctl.conf,检查是否有net.ipv4.ip_forward = x这样的配置;
  2. 如果有就保证x等于1,如果没有就加一行:net.ipv4.ip_forward = 1
  3. 修改并保存后,执行命令sysctl -p使配置生效;
  4. 执行命令sysctl -a|grep “ip_forward”,查看最新的配置,应该有如下内容:
net.ipv4.ip_forward = 1
net.ipv4.ip_forward_use_pmtu = 0

(3)最好重启一次计算机

(4)禁用swap:sudo swapoff -a

5、建立k8s集群

(1)登录localhost界面,提示不安全,继续访问

(2)“新建集群”——>选择客户自定义模式——>点击“下一步”

(3)先选择MASTER主机的按照命令,要选择etcd和Control这两个角色,不选worker,拷贝到要成为MASTER的主机上。

(4)然后只选择worker,把命令拷贝到要成为节点的主机上

6、运行registry单机版

sudo docker run -p 5000:5000 registry:2

7、配置registry非https客户端

在每一个需要registry的终端

vim  /etc/docker/daemon.json    增加一个daemon.json文件

{ "insecure-registries":["192.168.1.100:5000"] }
保存退出

重启docker服务

<think>我们参考了用户提供的引用内容,结合用户之前的问题(关于企业用户Docker Desktop平替版),可以确定用户现在需要的是Rancher Desktop的具体安装和使用指南。 根据引用[2]和[4]可知,Rancher Desktop支持Windows、macOS和Linux,且安装过程简单。引用[3]提到了其仪表板功能,引用[1]提到了设置镜像仓库等配置。 因此,我们将分步骤介绍在不同操作系统上的安装和配置方法。 注意:根据引用[1],Rancher Desktop在设置代理或镜像仓库时可能需要额外配置,但用户当前问题聚焦于安装和基本配置,所以我们先介绍安装和基本使用,然后简要提及配置镜像仓库。 步骤: 1. 下载安装2. 安装步骤(分操作系统) 3. 基本配置(包括Kubernetes设置和容器引擎选择) 4. 设置镜像仓库(根据引用[1]) 5. 使用仪表板(根据引用[3]) 同时,我们将生成相关问题,以引导用户深入了解Rancher Desktop的高级功能。</think>### Rancher Desktop 跨平台安装与配置指南 #### 一、操作系统安装步骤 **1. Windows 系统安装** ```mermaid graph TD A[下载安装包] --> B[双击.exe文件] B --> C[接受许可协议] C --> D[选择安装路径] D --> E[完成安装] E --> F[访问 http://localhost:8080 ↗] ``` - 从[官网](https://rancherdesktop.io/)下载`.exe`安装包[^2] - 安装后自动创建桌面快捷方式 - 首次启动自动初始化Kubernetes集群(约3-5分钟) - **验证安装**:命令行执行 `kubectl get nodes` 查看节点状态 **2. macOS 系统安装** ```bash # Homebrew 安装(推荐) brew install --cask rancher # 或手动安装: 1. 下载.dmg文件 2. 拖拽到Applications文件夹 3. 首次启动需在系统设置中授权 ``` - 需要 macOS 10.15+ 系统 - 自动配置 `/usr/local/bin` 下的命令行工具 - 文件共享路径:`~/rancher-desktop` **3. Linux 系统安装** ```bash # Debian/Ubuntu curl https://download.opensuse.org/repositories/isv:/Rancher:/stable/deb/Release.key | gpg --dearmor | sudo tee /usr/share/keyrings/rancher.gpg > /dev/null echo "deb [signed-by=/usr/share/keyrings/rancher.gpg] https://download.opensuse.org/repositories/isv:/Rancher:/stable/deb/ ./" | sudo tee /etc/apt/sources.list.d/rancher.list sudo apt update sudo apt install rancher-desktop # RPM系(Fedora/CentOS) sudo tee /etc/yum.repos.d/rancher.repo << 'EOF' [rancher] name=Rancher Desktop baseurl=https://download.opensuse.org/repositories/isv:/Rancher:/stable/rpm/ enabled=1 gpgcheck=1 gpgkey=https://download.opensuse.org/repositories/isv:/Rancher:/stable/rpm/repodata/repomd.xml.key EOF sudo dnf install rancher-desktop ``` #### 二、核心配置详解 **1. Kubernetes 设置** - **版本切换**:UI界面 > Kubernetes Settings > 选择版本(支持v1.21-v1.26) - **运行时选择**: - containerd(默认,兼容OCI标准) - dockerd(兼容Docker引擎) **2. 镜像仓库配置** ```yaml # 配置文件路径:~/.config/rancher-desktop/lima/_config/override.yaml proxies: docker: host: "proxy.example.com:3128" noProxy: "localhost,127.0.0.1,.internal" registries: mirror: "docker.io": - "https://mirror.registry.example" [^1] ``` **3. 资源分配调整** - 界面路径:Preferences > Resources - 关键参数: - CPU核心数(建议≥4核) - 内存分配(建议≥4GB) - 磁盘空间(默认20GB可扩展) #### 三、核心功能使用 **1. 仪表板操作** ```mermaid graph LR G[工作负载] --> H[查看Pod状态] I[网络] --> J[Service/Ingress管理] K[存储] --> L[持久卷监控] ``` - 实时监控资源使用率(CPU/内存/存储)[^3] - 一键访问Service的NodePort端口 **2. 命令行集成** ```bash # 使用内置kubectl rancher kubectl get pods -A # 使用nerdctl(兼容Docker命令) nerdctl run -d nginx:alpine ``` **3. 开发环境配置** - VS Code扩展:安装[Rancher Desktop扩展](https://marketplace.visualstudio.com/items?itemName=rancher.rancher-desktop) - 端口转发: ```bash rancher kubectl port-forward svc/my-service 8080:80 ``` #### 四、常见问题解决 | 问题现象 | 解决方案 | |---------|---------| | Kubernetes启动失败 | 重置集群:`rancher-desktop-reset` 命令 | | 镜像拉取超时 | 配置国内镜像源:`registry-mirrors.ustc.edu.cn` | | 文件共享失败 | 检查`Settings > Resources`中的共享目录设置 | | 代理认证失败 | 在override.yaml添加`auth: "username:password"`[^1] | > **最佳实践**:企业环境建议配置私有镜像仓库和持久化存储卷,生产环境需启用RBAC权限控制[^4]。 --- ###
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值