优化
This commit is contained in:
4
website/docs/deployment/other-way/_category_.json
Normal file
4
website/docs/deployment/other-way/_category_.json
Normal file
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"label": "Install with other ways",
|
||||
"position": 5
|
||||
}
|
||||
10
website/docs/deployment/other-way/bt.md
Normal file
10
website/docs/deployment/other-way/bt.md
Normal file
@@ -0,0 +1,10 @@
|
||||
---
|
||||
sidebar_position: 3
|
||||
title: Install with BT
|
||||
---
|
||||
|
||||
:::info
|
||||
This document is only available for Chinese.
|
||||
:::
|
||||
|
||||
If you are chinese user, and wanna install Tailchat with bt, please learn more with switch language to chinese and read it.
|
||||
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"label": "Kubernetes",
|
||||
"position": 2
|
||||
}
|
||||
147
website/docs/deployment/other-way/kubernetes/sealos.md
Normal file
147
website/docs/deployment/other-way/kubernetes/sealos.md
Normal file
@@ -0,0 +1,147 @@
|
||||
---
|
||||
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"
|
||||
|
||||

|
||||
|
||||
## Create a new application
|
||||
|
||||

|
||||
|
||||
### 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:
|
||||
|
||||

|
||||
|
||||
Click "Deploy Application" to submit the deployment. Wait patiently for a while, and you can see that the application has started up.
|
||||
|
||||

|
||||
|
||||
> 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`
|
||||
- Change the command parameters to: `server /data`
|
||||
- Set environment variables:
|
||||
- MINIO_ROOT_USER: tailchat
|
||||
- MINIO_ROOT_PASSWORD: com.msgbyte.tailchat
|
||||
- Local storage: `/data`
|
||||
|
||||
The final result is as follows:
|
||||
|
||||

|
||||
|
||||
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:
|
||||
|
||||

|
||||
|
||||
### Create Tailchat itself
|
||||
|
||||
At this point, all the dependencies required by Tailchat have been deployed, as shown below:
|
||||
|
||||

|
||||
|
||||
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:
|
||||
|
||||

|
||||
|
||||
After waiting patiently for a while, you can see that the Tailchat service has started up.
|
||||
|
||||

|
||||
|
||||
## 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://<xxxxxxxxxx>.cloud.sealos.io/health`. When it starts up, the Tailchat service will return content like this:
|
||||
|
||||

|
||||
|
||||
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.
|
||||
|
||||

|
||||
|
||||
Register an account casually, and you can see that we can enter the main interface of Tailchat normally, as shown in the following figure:
|
||||
|
||||

|
||||
|
||||
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:
|
||||
|
||||

|
||||
|
||||

|
||||
|
||||

|
||||
|
||||
At this point, when we access `https://<xxxxxxxxxx>.cloud.sealos.io/health`, we can see that we can access different nodes.
|
||||
|
||||

|
||||
|
||||
## Add Tailchat entry to desktop
|
||||
|
||||
Open Terminal, enter `vim app.yml` to create and edit a configuration file
|
||||
|
||||
Enter the following content, note that the url should be replaced with the url deployed by yourself
|
||||
|
||||
```yml
|
||||
apiVersion: app.sealos.io/v1
|
||||
kind: App
|
||||
metadata:
|
||||
name: tailchat-app-entry
|
||||
spec:
|
||||
name: Tailchat
|
||||
icon:
|
||||
type: iframe
|
||||
data:
|
||||
url: <Your url>
|
||||
desc:
|
||||
icon: https://tailchat.msgbyte.com/img/logo.svg
|
||||
menuData:
|
||||
nameColor: text-black
|
||||
helpDropDown:
|
||||
helpDocs:
|
||||
displayType: normal
|
||||
```
|
||||
|
||||
Press `esc` to exit edit mode, press `:wq` to save and exit vim
|
||||
|
||||
Type `kubectl apply -f app.yml` to start the configuration.
|
||||
|
||||
After refreshing the page, we can see that our entry appears on the desktop of `sealos`
|
||||
|
||||

|
||||
117
website/docs/deployment/other-way/kubernetes/simple.md
Normal file
117
website/docs/deployment/other-way/kubernetes/simple.md
Normal file
@@ -0,0 +1,117 @@
|
||||
---
|
||||
sidebar_position: 1
|
||||
title: Simple Deployment
|
||||
---
|
||||
|
||||
## Introduction
|
||||
|
||||
Kubernetes is an open-source container orchestration platform used for automating the deployment, scaling, and management of containerized applications. It provides a way to orchestrate containers, automating tasks such as deployment, scheduling, load balancing, and fault recovery, making containerized applications run efficiently in a distributed system.
|
||||
|
||||
Advantages of Kubernetes include:
|
||||
- Automation: Kubernetes automates tasks such as deployment, scheduling, load balancing, and fault recovery, reducing the amount of manual work required.
|
||||
- Scalability: Kubernetes can manage thousands of containerized applications in large-scale clusters, with good horizontal and vertical scalability.
|
||||
- Flexibility: Kubernetes supports multiple container runtimes and multiple cloud platforms, allowing applications to be deployed and managed in different environments.
|
||||
- Reliability: Kubernetes provides powerful fault recovery mechanisms and self-healing capabilities, ensuring high availability and reliability of applications.
|
||||
- Community support: Kubernetes is an active open-source project with a large community support and ecosystem, allowing for quick updates and support.
|
||||
|
||||
## Quick Start
|
||||
|
||||
If you want to deploy the Tailchat project on Kubernetes, you can find the prepared simple Tailchat deployment configuration in the `docker/simple/k8s` subdirectory of the project directory. These configuration files include Kubernetes resource definitions for running Tailchat, such as StatefulSet, Service, and dependencies such as databases and persistent storage. These resource definitions allow you to quickly deploy a simple Tailchat project on Kubernetes without manually creating and configuring these resources.
|
||||
|
||||
:::info
|
||||
Note that the deployed Tailchat in this tutorial does not include the complete Tailchat ecosystem, such as the **Open Platform** and **Admin Management Platform**.
|
||||
:::
|
||||
|
||||
### Environment Dependencies
|
||||
|
||||
To start this chapter, we assume that you have a working Kubernetes environment ready. This section does not describe how to set up a k8s environment.
|
||||
|
||||
### Getting Started
|
||||
|
||||
First, we need to clone the project repository:
|
||||
|
||||
```bash
|
||||
git clone git@github.com:msgbyte/tailchat.git
|
||||
```
|
||||
|
||||
Change the working directory to the configuration file directory:
|
||||
|
||||
```bash
|
||||
cd docker/simple/k8s
|
||||
```
|
||||
|
||||
At this point, you can see many prepared configuration files, and we can start by running a single command:
|
||||
|
||||
```bash
|
||||
kubectl apply -f namespace.yml -f pv.yml -f mongo.yml -f minio.yml -f redis.yml -f tailchat.yml
|
||||
```
|
||||
|
||||
This command will create the `namespace`, create `pv` and `pvc`, create `mongodb`, `minio`, `redis`, and other necessary third-party middleware, and finally start a multi-instance `tailchat` service.
|
||||
|
||||
You can check the status of each service using the following command:
|
||||
|
||||
```bash
|
||||
kubectl get svc -n tailchat
|
||||
```
|
||||
|
||||
### Routing and Load Balancing
|
||||
|
||||
When all services are ready, our Tailchat service is now running in the cluster, but we cannot access it because it has not been exposed to the outside.
|
||||
|
||||
For local testing, we can use the `port forward` function to map the port of a pod to the local machine. In a production environment, however, we need to build routing and forwarding.
|
||||
|
||||
Taking `traefik` as an example:
|
||||
|
||||
> Traefik is an open-source reverse proxy and load balancer designed specifically for routing and load balancing traffic in containerized applications and microservices architectures. Traefik supports multiple backend services, including Docker, Kubernetes, Mesos, Swarm, Consul, Etcd, and more. It can automatically discover and configure backend services and route traffic to the corresponding service instances based on rules.
|
||||
|
||||
#### Installing Helm and Adding Repository Address
|
||||
|
||||
The installation of `helm` is not discussed here. We execute the following command to add `traefik` to the repository list:
|
||||
|
||||
```bash
|
||||
helm repo add traefik https://helm.traefik.io/traefik
|
||||
```
|
||||
|
||||
#### Installing Traefik in the Tailchat Namespace
|
||||
|
||||
```bash
|
||||
helm install traefik traefik/traefik -n tailchat
|
||||
```
|
||||
|
||||
#### Starting Ingress Resource Declaration
|
||||
|
||||
```bash
|
||||
kubectl apply -f ingress.yml
|
||||
```
|
||||
|
||||
If everything is ok, you can see the following output using the following command:
|
||||
|
||||
```bash
|
||||
kubectl get services -n tailchat
|
||||
```
|
||||
|
||||

|
||||
|
||||
#### Setting up DNS Services
|
||||
|
||||
You can modify the domain address configuration in the `ingress.yml` mentioned above, which defaults to `http://tailchat.internal.com/`.
|
||||
|
||||
If you do not wish to modify or do not have a domain name, you can modify the `hosts` file to achieve this:
|
||||
|
||||
```bash
|
||||
sudo vim /etc/hosts
|
||||
```
|
||||
|
||||
Then add the following path:
|
||||
|
||||
```
|
||||
127.0.0.1 tailchat.internal.com
|
||||
```
|
||||
|
||||
Now you can open your browser and visit `http://tailchat.internal.com` to access the Tailchat service deployed on Kubernetes.
|
||||
|
||||
Of course, you can also check the availability of the service by visiting the following address:
|
||||
|
||||
```
|
||||
http://tailchat.internal.com/health
|
||||
```
|
||||
87
website/docs/deployment/other-way/manual.md
Normal file
87
website/docs/deployment/other-way/manual.md
Normal file
@@ -0,0 +1,87 @@
|
||||
---
|
||||
sidebar_position: 1
|
||||
title: Manual Deployment
|
||||
---
|
||||
|
||||
:::caution
|
||||
The content of this chapter requires you to have a certain degree of understanding of nodejs, git, linux. When there are problems such as dependency problems, environmental problems, system problems, etc., you need to have the ability to solve and troubleshoot problems by yourself.
|
||||
|
||||
If you do not understand this, it is not recommended that you use the contents of this chapter for deployment. It is recommended to use a unified image for deployment.
|
||||
:::
|
||||
|
||||
## Dependencies
|
||||
|
||||
- git
|
||||
- nodejs v16.18.0 or above
|
||||
- pnpm v8.3.1 or above
|
||||
- mongodb
|
||||
- redis
|
||||
- minio
|
||||
|
||||
## Download the source code
|
||||
|
||||
```bash
|
||||
mkdir msgbyte && cd msgbyte
|
||||
|
||||
git clone https://github.com/msgbyte/tailchat.git
|
||||
```
|
||||
|
||||
### Switch to stable code
|
||||
|
||||
Because the cloned code is the latest code, it may be unstable for a short period of time, so if you want to switch to the stable code of each version, you can use the tag function of git
|
||||
|
||||
For example, if you wanna use `v1.7.6`, you can use the command:
|
||||
|
||||
```bash
|
||||
git checkout v1.7.6
|
||||
```
|
||||
|
||||
## Compile the project
|
||||
|
||||
Tailchat is a front-end and back-end separated project. So we have to deal with the front-end code and the back-end code separately
|
||||
|
||||
### Install dependencies
|
||||
|
||||
We assume you have installed `nodejs v16.18.0+` or above. And installed `pnpm v8.3.1` or above
|
||||
|
||||
```bash
|
||||
cd tailchat
|
||||
pnpm install
|
||||
```
|
||||
|
||||
This command will take some time to install all the dependencies of Tailchat. When the installation is complete, the internal plug-in will automatically execute the compilation command.
|
||||
|
||||
### Building the project
|
||||
|
||||
```bash
|
||||
NODE_ENV=production pnpm build
|
||||
```
|
||||
|
||||
This command will execute the commands for compiling the front-end and back-end management terminals in parallel. And move the front-end product to the `server/dist/public` directory of the server
|
||||
|
||||
When the project is built, our product can run normally
|
||||
|
||||
:::caution
|
||||
Please build in `macos` / `linux` environment as much as possible, window does not necessarily fully support shell commands
|
||||
:::
|
||||
|
||||
## Run the project
|
||||
|
||||
In order to ensure the horizontal expansion of the project, although the core code of `Tailchat` is written in the same project, it can be divided into multiple subdivided microservices when it is actually started. Selectively enable different services by passing in a combination of different environment variables.
|
||||
|
||||
Create an environment variable file in the server directory using the `.env.example` directory as an example
|
||||
|
||||
```bash
|
||||
cp server/.env.example server/dist/.env
|
||||
vim .env
|
||||
```
|
||||
|
||||
Modify the necessary environment variables to your own, such as `MONGO_URL`, `REDIS_URL`, `MINIO_URL`
|
||||
|
||||
then start the service
|
||||
|
||||
```bash
|
||||
SERVICEDIR=services,plugins pnpm start:service
|
||||
```
|
||||
|
||||
> `SERVICEDIR` indicates the directory where the microservice is loaded
|
||||
Reference in New Issue
Block a user