diff --git a/website/docs/kubernetes/_category_.json b/website/docs/deployment/kubernetes/_category_.json similarity index 63% rename from website/docs/kubernetes/_category_.json rename to website/docs/deployment/kubernetes/_category_.json index e23349cc..d2ddffa2 100644 --- a/website/docs/kubernetes/_category_.json +++ b/website/docs/deployment/kubernetes/_category_.json @@ -1,4 +1,4 @@ { "label": "Kubernetes", - "position": 50 + "position": 5 } diff --git a/website/docs/deployment/kubernetes/sealos.md b/website/docs/deployment/kubernetes/sealos.md new file mode 100644 index 00000000..ba77cbfc --- /dev/null +++ b/website/docs/deployment/kubernetes/sealos.md @@ -0,0 +1,112 @@ +--- +sidebar_position: 2 +title: Deployment in sealos +--- + +`Sealos` is an open-source Kubernetes deployment system that allows us to quickly create an on-demand, pay-as-you-go application cluster. + +## First, enter Sealos and open "Application Management" + +![](/img/kubernetes/sealos/1.png) + +## Create a new application + +![](/img/kubernetes/sealos/2.png) + +### Create dependencies + +As an enterprise-level application, `tailchat` has the minimum dependencies of `mongodb`, `redis`, and `minio`. Let's create them one by one. + +#### MongoDB + +For convenience, we will fix one instance and bind it to local storage. The image used is `mongo:4`. Note that because we did not set a password for the database, do not provide network services to the public network. The container exposes port 27017, which is the default database service port. The content is as follows: + +![](/img/kubernetes/sealos/3.png) + +Click "Deploy Application" to submit the deployment. Wait patiently for a while, and you can see that the application has started up. + +![](/img/kubernetes/sealos/4.png) + +> Note: that the initial allocation of 64m is too small for MongoDB, so I changed it to 128m by modifying the application. Resource allocation can be changed at any time, which is also a convenient feature of Sealos/Kubernetes. + +#### Minio + +Next, we will create Minio, an open-source object storage service. We can also quickly create it through Sealos's UI. The image used is `minio/minio`. Note that we need to make some adjustments: + +- Expose port: 9000 +- Change the run command to: `minio server /data` +- Set environment variables: +- MINIO_ROOT_USER: tailchat +- MINIO_ROOT_PASSWORD: com.msgbyte.tailchat +- Local storage: `/data` + +The final result is as follows: + +![](/img/kubernetes/sealos/5.png) + +Click the "Deploy" button and you can see that the service has started up normally. + +#### Redis + +Finally, we need to deploy Redis as a content cache and message forwarding. The image used is `redis:alpine`, and the exposed port is `6379`. The final result is as follows: + +![](/img/kubernetes/sealos/6.png) + +### Create Tailchat itself + +At this point, all the dependencies required by Tailchat have been deployed, as shown below: + +![](/img/kubernetes/sealos/7.png) + +Now we can deploy the Tailchat itself. The Tailchat itself will be relatively complex, but because Sealos is purely UI-based, it will not be too complicated. + +- Use image: `moonrailgun/tailchat` +- Expose port: `11000` (remember to open external access) +- Configure environment variables as follows: + ``` + SERVICEDIR=services,plugins + TRANSPORTER=redis://redis:6379 + REDIS_URL=redis://redis:6379 + MONGO_URL=mongodb://mongo/tailchat + MINIO_URL=minio:9000 + MINIO_USER=tailchat + MINIO_PASS=com.msgbyte.tailchat + ``` + +The final effect is as follows: + +![](/img/kubernetes/sealos/8.png) + +After waiting patiently for a while, you can see that the Tailchat service has started up. + +![](/img/kubernetes/sealos/9.png) + +## Preview service + +First, we can check the availability of the Tailchat service by adding `/health` to the external address provided by the service, such as `https://.cloud.sealos.io/health`. When it starts up, the Tailchat service will return content like this: + +![](/img/kubernetes/sealos/10.png) + +This JSON string contains the image version used, node name, system usage, and microservice loading status. Here we can see that my common services, such as `user`/`chat.message`, and some services with plugin prefixes such as `plugin.registry`, have all started up normally, indicating that our server is running normally. Now we can directly access our external address and see that after a short loading time, the page opens normally and automatically jumps to the login page. + +![](/img/kubernetes/sealos/11.png) + +Register an account casually, and you can see that we can enter the main interface of Tailchat normally, as shown in the following figure: + +![](/img/kubernetes/sealos/12.png) + +At this point, our service has successfully landed in Sealos. + +## Scaling service + +Of course, as a distributed architecture system, Tailchat naturally supports horizontal scaling. In Sealos, scaling is also very simple. Just modify the number of instances through the change operation: + +![](/img/kubernetes/sealos/13.png) + +![](/img/kubernetes/sealos/14.png) + +![](/img/kubernetes/sealos/15.png) + +At this point, when we access `https://.cloud.sealos.io/health`, we can see that we can access different nodes. + +![](/img/kubernetes/sealos/16.png) diff --git a/website/docs/kubernetes/simple.md b/website/docs/deployment/kubernetes/simple.md similarity index 100% rename from website/docs/kubernetes/simple.md rename to website/docs/deployment/kubernetes/simple.md diff --git a/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/kubernetes/_category_.json b/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/deployment/kubernetes/_category_.json similarity index 63% rename from website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/kubernetes/_category_.json rename to website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/deployment/kubernetes/_category_.json index e23349cc..d2ddffa2 100644 --- a/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/kubernetes/_category_.json +++ b/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/deployment/kubernetes/_category_.json @@ -1,4 +1,4 @@ { "label": "Kubernetes", - "position": 50 + "position": 5 } diff --git a/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/deployment/kubernetes/sealos.md b/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/deployment/kubernetes/sealos.md new file mode 100644 index 00000000..c3ab9493 --- /dev/null +++ b/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/deployment/kubernetes/sealos.md @@ -0,0 +1,141 @@ +--- +sidebar_position: 2 +title: 在 Sealos 上部署Tailchat +--- + +`Sealos` 是一款开源的 Kubernetes 部署系统。通过 `Sealos` 我们可以快捷的创建一个按需付费的应用集群。 + +## 首先进入 Sealos 并打开「应用管理」 + +![](/img/kubernetes/sealos/1.png) + +## 新建应用 + +![](/img/kubernetes/sealos/2.png) + +### 创建依赖 + +`tailchat` 作为企业级的应用,最小依赖: `mongodb`, `redis`, `minio`. + +接下来让我们来一一创建。 + +#### mongodb + +为了方便起见我们固定一个实例,并且为数据库绑定本地存储。 + +使用的镜像是 `mongo:4` + +需要注意的是因为我没有给数据库设置密码,因此不要对外网提供网络服务。容器暴露端口填数据库默认服务端口 `27017` 即可 + +内容如下: + +![](/img/kubernetes/sealos/3.png) + +点击部署应用提交部署 + +耐心等待一会,就可以看到应用已经启动起来了 + +![](/img/kubernetes/sealos/4.png) + +> 需要注意的是初始分配的64m对于mongodb来说实在太小了,所以通过变更应用改为了128m。可以随时分配资源大小这也是sealos/k8s很方便的一点 + +#### minio + +接下来我们创建minio, minio是一个开源的对象存储服务。我们同样可以通过`sealos`的点点点来快速创建 + +使用的镜像是: `minio/minio` + +需要注意的是我们要进行一些调整: + +- 暴露端口: 9000 +- 运行命令改为: `minio server /data` +- 设置环境变量: + - MINIO_ROOT_USER: tailchat + - MINIO_ROOT_PASSWORD: com.msgbyte.tailchat +- 本地存储: `/data` + +最终结果如下: + +![](/img/kubernetes/sealos/5.png) + +点击部署按钮同样看到服务已经正常启动起来了。 + +#### redis + +最后我们需要部署redis作为内容缓存与信息转发。 + +使用镜像: `redis:alpine` + +暴露端口: `6379` + +最终结果如下: + +![](/img/kubernetes/sealos/6.png) + + +### 创建 Tailchat 本体 + +此时Tailchat所需要的依赖均已部署完毕,如下: + +![](/img/kubernetes/sealos/7.png) + +现在我们来部署 `Tailchat` 本体。 + +`Tailchat` 的本体会相对复杂一点,不过因为`sealos`纯UI操作也不会太过复杂。 + +- 使用镜像: `moonrailgun/tailchat` +- 暴露端口: `11000`(记得要打开外网访问) +- 配置环境变量如下: + ``` + SERVICEDIR=services,plugins + TRANSPORTER=redis://redis:6379 + REDIS_URL=redis://redis:6379 + MONGO_URL=mongodb://mongo/tailchat + MINIO_URL=minio:9000 + MINIO_USER=tailchat + MINIO_PASS=com.msgbyte.tailchat + ``` + +最终效果如下: + +![](/img/kubernetes/sealos/8.png) + +耐心等待一段时间后可以看到`Tailchat` 服务已经启动起来了 + +![](/img/kubernetes/sealos/9.png) + +## 预览服务 + +首先我们可以先检查一下`Tailchat`服务的可用性,可以通过外网地址提供的服务后面加上 `/health` 来检查服务可用性, 如: `https://.cloud.sealos.io/health` + +当启动完毕后,Tailchat服务会返回如下内容: + +![](/img/kubernetes/sealos/10.png) + +这段json字符串中包含了使用的镜像版本,节点名称,系统占用,微服务加载情况。 + +这里我们可以看到我的常见的服务, 如`user`/`chat.message`以及一些带有插件前缀的服务如`plugin.registry`都已经正常启动起来了,说明我们的服务端是正常运行的。 + +现在我们可以直接访问我们的外网地址,可以看到经过短暂的加载后,页面正常打开自动跳转到了登录界面。 + +![](/img/kubernetes/sealos/11.png) + +随便注册一个账号,可以看到我们可以正常进入Tailchat的主界面, 如下图: + +![](/img/kubernetes/sealos/12.png) + +至此我们的服务已经成功在 sealos 中落地了。 + +## 扩容服务 + +当然,作为一个分布式架构的系统,`Tailchat` 天然是支持水平扩容的。而在 `sealos` 想要实现扩容也非常简单, 只需要通过变更操作修改实例数即可: + +![](/img/kubernetes/sealos/13.png) + +![](/img/kubernetes/sealos/14.png) + +![](/img/kubernetes/sealos/15.png) + +此时当我们访问 `https://.cloud.sealos.io/health` 可以看到我们可以访问到不同的节点 + +![](/img/kubernetes/sealos/16.png) diff --git a/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/kubernetes/simple.md b/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/deployment/kubernetes/simple.md similarity index 100% rename from website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/kubernetes/simple.md rename to website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/deployment/kubernetes/simple.md diff --git a/website/static/img/kubernetes/sealos/1.png b/website/static/img/kubernetes/sealos/1.png new file mode 100644 index 00000000..a1c28153 Binary files /dev/null and b/website/static/img/kubernetes/sealos/1.png differ diff --git a/website/static/img/kubernetes/sealos/10.png b/website/static/img/kubernetes/sealos/10.png new file mode 100644 index 00000000..b9a8e8df Binary files /dev/null and b/website/static/img/kubernetes/sealos/10.png differ diff --git a/website/static/img/kubernetes/sealos/11.png b/website/static/img/kubernetes/sealos/11.png new file mode 100644 index 00000000..2d0cd45d Binary files /dev/null and b/website/static/img/kubernetes/sealos/11.png differ diff --git a/website/static/img/kubernetes/sealos/12.png b/website/static/img/kubernetes/sealos/12.png new file mode 100644 index 00000000..ccd52d6e Binary files /dev/null and b/website/static/img/kubernetes/sealos/12.png differ diff --git a/website/static/img/kubernetes/sealos/13.png b/website/static/img/kubernetes/sealos/13.png new file mode 100644 index 00000000..5e952496 Binary files /dev/null and b/website/static/img/kubernetes/sealos/13.png differ diff --git a/website/static/img/kubernetes/sealos/14.png b/website/static/img/kubernetes/sealos/14.png new file mode 100644 index 00000000..edfe162a Binary files /dev/null and b/website/static/img/kubernetes/sealos/14.png differ diff --git a/website/static/img/kubernetes/sealos/15.png b/website/static/img/kubernetes/sealos/15.png new file mode 100644 index 00000000..83f28476 Binary files /dev/null and b/website/static/img/kubernetes/sealos/15.png differ diff --git a/website/static/img/kubernetes/sealos/16.png b/website/static/img/kubernetes/sealos/16.png new file mode 100644 index 00000000..61fdcc2f Binary files /dev/null and b/website/static/img/kubernetes/sealos/16.png differ diff --git a/website/static/img/kubernetes/sealos/2.png b/website/static/img/kubernetes/sealos/2.png new file mode 100644 index 00000000..0cbffe89 Binary files /dev/null and b/website/static/img/kubernetes/sealos/2.png differ diff --git a/website/static/img/kubernetes/sealos/3.png b/website/static/img/kubernetes/sealos/3.png new file mode 100644 index 00000000..cae2a86e Binary files /dev/null and b/website/static/img/kubernetes/sealos/3.png differ diff --git a/website/static/img/kubernetes/sealos/4.png b/website/static/img/kubernetes/sealos/4.png new file mode 100644 index 00000000..315242c1 Binary files /dev/null and b/website/static/img/kubernetes/sealos/4.png differ diff --git a/website/static/img/kubernetes/sealos/5.png b/website/static/img/kubernetes/sealos/5.png new file mode 100644 index 00000000..79800246 Binary files /dev/null and b/website/static/img/kubernetes/sealos/5.png differ diff --git a/website/static/img/kubernetes/sealos/6.png b/website/static/img/kubernetes/sealos/6.png new file mode 100644 index 00000000..9252f6ca Binary files /dev/null and b/website/static/img/kubernetes/sealos/6.png differ diff --git a/website/static/img/kubernetes/sealos/7.png b/website/static/img/kubernetes/sealos/7.png new file mode 100644 index 00000000..47c5295d Binary files /dev/null and b/website/static/img/kubernetes/sealos/7.png differ diff --git a/website/static/img/kubernetes/sealos/8.png b/website/static/img/kubernetes/sealos/8.png new file mode 100644 index 00000000..8fb13f3e Binary files /dev/null and b/website/static/img/kubernetes/sealos/8.png differ diff --git a/website/static/img/kubernetes/sealos/9.png b/website/static/img/kubernetes/sealos/9.png new file mode 100644 index 00000000..0731b0ce Binary files /dev/null and b/website/static/img/kubernetes/sealos/9.png differ