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集群完成

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

相关推荐
csdn_aspnet4 小时前
使用 Docker 配置 PostgreSQL 和 pgAdmin 4
数据库·docker·postgresql·pgadmin4
Maiko Star5 小时前
Docker保姆级部署AI应用程序(FastAPI)
docker·容器·fastapi
`Levie1 天前
Docker-安装部署、容器管理(一)
docker·容器·eureka
Diligently_1 天前
第 08 篇|单机部署:本地安装与 Docker 最佳实践
运维·spring boot·docker
FungLeo2 天前
FengCMS·PHP+MySQL 升级实录 ·本地容器环境设计:只读挂载、LOCAL_UID、数据卷权限
开发语言·mysql·docker·php·fengcms
cpolar技术支持3 天前
用一份 YAML 画出家里的网络拓扑:哪个口通公网、哪几个容器藏在内网,一张图摊开,再用 cpolar 在外网随时翻这份图
docker·网络拓扑·内网穿透·cpolar·yaml
FriendshipT3 天前
YOLOE Docker 部署实战:三模式推理、掩码输出与跨图视觉的完整实现
运维·人工智能·python·深度学习·docker·容器
the局外人3 天前
Docker 部署:从镜像构建到容器上线
后端·docker·容器
方便面不加香菜4 天前
Docker Compose 文件 -- docker-compose.yml
spring cloud·docker·容器
lambo mercy4 天前
04Docker_Container_容器
docker