This commit is contained in:
2026-04-25 16:36:34 +08:00
commit db90e7579b
1876 changed files with 189777 additions and 0 deletions

View File

@@ -0,0 +1,4 @@
{
"label": "Kubernetes",
"position": 2
}

View 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"
![](/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`
- 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:
![](/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://<xxxxxxxxxx>.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://<xxxxxxxxxx>.cloud.sealos.io/health`, we can see that we can access different nodes.
![](/img/kubernetes/sealos/16.png)
## 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`
![](/img/kubernetes/sealos/17.png)

View 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
```
![](/img/kubernetes/traefik-svc.png)
#### 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
```