828华为云征文|华为云Flexus X实例docker部署rancher并构建k8s集群

828华为云征文|华为云Flexus X实例docker部署rancher并构建k8s集群

  • 华为云最近正在举办828 B2B企业节,Flexus X实例的促销力度非常大,特别适合那些对算力性能有高要求的小伙伴。如果你有自建MySQL、Redis、Nginx等服务的需求,一定不要错过这个机会。赶紧去看看吧!

什么是华为云Flexus X实例

  • 华为云Flexus X实例云服务是新一代开箱即用、体验跃级、面向中小企业和开发者打造的高品价比云服务产品。
  • Flexus云服务器X实例是新一代面向中小企业和开发者打造的柔性算力云服务器,可智能感知业务负载,适用于电商直播、企业建站、开发测试环境、游戏服务器、音视频服务等中低负载场景。

开始接触华为云Flexus云服务器X实例

  • 获取华为云Flexus云服务器X实例后第一步就是先去华为云上重置服务器密码

  • 重置完毕后用ssh工具登录华为云服务器,这里我用的是finalshell,也可以用其他工具登陆比如xshell或者Putty都可以

  • 登录上去查看硬盘大小,可以看到是100g硬盘,硬盘总大小是正常的

    root@flexusx-ebe8:~# df -h
    Filesystem Size Used Avail Use% Mounted on
    tmpfs 1.2G 1.1M 1.2G 1% /run
    /dev/vda1 99G 4.2G 90G 5% /
    tmpfs 5.7G 0 5.7G 0% /dev/shm
    tmpfs 5.0M 0 5.0M 0% /run/lock
    tmpfs 1.2G 4.0K 1.2G 1% /run/user/0

  • 然后输入 ufw status可以看到默认防火墙是关闭的,因此我们就不需要额外再去配置端口开放相关的配置,只要在华为云安全组配置端口开放就可以了

    root@flexusx-ebe8:~# ufw status
    Status: inactive

docker环境的安装

  • 如图所示,把离线包传到服务器上,进行安装

    dpkg -i *.deb

  • 查看安装的docker版本

    root@flexusx-ebe8:/home/docker# docker -v
    Docker version 27.1.2, build d01f264

  • 至此docker容器环境安装完毕


什么是rancker

  • Rancher 是一个开源软件平台,旨在简化 Kubernetes 集群的管理。它提供一个用户友好的界面,帮助开发者部署、管理和扩展容器化应用程序。通过 Rancher,用户可以集中管理多个 Kubernetes 集群,无论这些集群是托管在本地数据中心还是云平台上。Rancher 还提供了访问控制、监控和工作负载编排等功能,是 DevOps 团队用于简化容器管理和降低 Kubernetes 复杂度的常用工具。

docker部署rancher

  • 查看rancher启动情况 docker ps

    root@flexusx-ebe8:~# docker ps
    CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
    58a6c708cd8a registry.cn-hangzhou.aliyuncs.com/rancher/rancher:v2.8.4 "entrypoint.sh" About a minute ago Up About a minute 0.0.0.0:80->80/tcp, :::80->80/tcp, 0.0.0.0:443->443/tcp, :::443->443/tcp rancher

  • 然后还需要去华为云安全组开放端口

配置Flexus云服务器X实例安全组

  • 经过上面部署rancher服务,这时候服务是已经部署完毕了,但是我们还没法通过外网进行访问,还需要对Flexus云服务器X安全组的配置进行修改

  • 进入安全组的配置页面

  • 新建安全组

  • 这里我们开放80,443端口

  • 然后加入新建的安全组

  • 这样我们的实例的端口也就开放成功了

配置rancker

  • 输入 弹性公网ip:80 然后会跳转

  • 按说明获取密码

    root@flexusx-ebe8:~# docker logs 58a6c708cd8a 2>&1 | grep "Bootstrap Password:"
    2024/09/07 06:09:06 [INFO] Bootstrap Password: t6rx2x52bmxsbbqrct6lxnjgqbf7dlj6z2jlgt5pb6vbl7wfjzpssk

  • 然后设置自己的密码

  • 然后rancher就登录进去了

  • 先把语言设置为中文

  • 这样rancher配置完毕了

rancher创建k8s集群

  • 回到首页点击创建

  • 选择自定义

  • 输入集群名称,然后把容器网络改为flannel

  • 勾选跳过TLS验证,复制命令去服务器执行

  • 然后等待k8s集群创建完毕即可

    root@flexusx-ebe8:~# curl --insecure -fL https://弹性公网ip/system-agent-install.sh | sudo sh -s - --server https://弹性公网ip --label 'cattle.io/os=linux' --token qfshnvnspcc92x4vblwnfvl2bgwz4zhx5d5dmft6kqgh4pmglbl55q --ca-checksum 06a3532ccb7d3995f65fcd6063c173e8544f13b04a3f155ad21284d449ce43b8 --etcd --controlplane --worker
    % Total % Received % Xferd Average Speed Time Time Time Current
    Dload Upload Total Spent Left Speed
    100 32283 0 32283 0 0 1477k 0 --:--:-- --:--:-- --:--:-- 1501k
    [INFO] Label: cattle.io/os=linux
    [INFO] Role requested: etcd
    [INFO] Role requested: controlplane
    [INFO] Role requested: worker
    [INFO] Using default agent configuration directory /etc/rancher/agent
    [INFO] Using default agent var directory /var/lib/rancher/agent
    [INFO] Determined CA is necessary to connect to Rancher
    [INFO] Successfully downloaded CA certificate
    [INFO] Value from https://弹性公网ip/cacerts is an x509 certificate
    [INFO] Successfully tested Rancher connection
    [INFO] Downloading rancher-system-agent binary from https://121.37.21.99/assets/rancher-system-agent-amd64
    [INFO] Successfully downloaded the rancher-system-agent binary.
    [INFO] Downloading rancher-system-agent-uninstall.sh script from https://弹性公网ip/assets/system-agent-uninstall.sh
    [INFO] Successfully downloaded the rancher-system-agent-uninstall.sh script.
    [INFO] Generating Cattle ID
    [INFO] Successfully downloaded Rancher connection information
    [INFO] systemd: Creating service file
    [INFO] Creating environment file /etc/systemd/system/rancher-system-agent.env
    [INFO] Enabling rancher-system-agent.service
    Created symlink /etc/systemd/system/multi-user.target.wants/rancher-system-agent.service → /etc/systemd/system/rancher-system-agent.service.
    [INFO] Starting/restarting rancher-system-agent.service

  • 当状态变为active时,代表k8s集群已经成功启动

  • 点进去可以查看集群状态

  • 至此华为云Flexus X实例docker部署rancher并构建k8s集群完成

欢迎大家一起加入华为云!

相关推荐
wydd99_lll9 小时前
docker特权模式下逃逸
运维·docker·容器
mseaspring10 小时前
一款用于监控跨多台主机 Docker 容器的实时终端
运维·docker·容器
SPC的存折14 小时前
6、Docker常用配置
运维·docker·容器
图图玩ai14 小时前
SSH 命令管理工具怎么选?从命令收藏到批量执行一次讲清
linux·nginx·docker·ai·程序员·ssh·可视化·gmssh·批量命令执行
SPC的存折15 小时前
4、Docker私有仓库
运维·docker·容器
齐潇宇16 小时前
Docker概述与安装
linux·运维·docker·容器
亚空间仓鼠17 小时前
Docker 容器技术入门与实践 (二):Dockerfile文件
运维·docker·容器
亚空间仓鼠17 小时前
Docker 容器技术入门与实践 (一):命令与镜像、容器管理
运维·docker·容器
东北甜妹18 小时前
Docker 多阶段构建
运维·docker·容器
Zhu75818 小时前
【软件部署】docker环境部署nagios
运维·docker·容器