Skip to content

Commit 9a122d2

Browse files
authored
Merge pull request #3014 from openimsdk/cherry-pick-7563aff
deps: Merge #2914 #2957 #2972 #2973 #2977 #2985 #2993 #2995 #3001 #3002 #3007 #3009 PRs into pre-release-v3.8.3
2 parents 716e06f + b805113 commit 9a122d2

File tree

119 files changed

+4195
-3426
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

119 files changed

+4195
-3426
lines changed

deployments/Readme.md

+132-119
Original file line numberDiff line numberDiff line change
@@ -1,175 +1,188 @@
1-
# OpenIM Application Containerization Deployment Guide
1+
# Kubernetes Deployment
22

3-
OpenIM supports a variety of cluster deployment methods, including but not limited to `helm`, `sealos`, `kustomize`
3+
## Resource Requests
44

5-
Various contributors, as well as previous official releases, have provided some referenceable solutions:
5+
- CPU: 2 cores
6+
- Memory: 4 GiB
7+
- Disk usage: 20 GiB (on Node)
68

7-
+ [k8s-jenkins Repository](https://github.com/OpenIMSDK/k8s-jenkins)
8-
+ [open-im-server-k8s-deploy Repository](https://github.com/openimsdk/open-im-server-k8s-deploy)
9-
+ [openim-charts Repository](https://github.com/OpenIMSDK/openim-charts)
10-
+ [deploy-openim Repository](https://github.com/showurl/deploy-openim)
9+
## Preconditions
1110

12-
### Dependency Check
11+
ensure that you have already deployed the following components:
1312

14-
```bash
15-
Kubernetes: >= 1.16.0-0
16-
Helm: >= 3.0
17-
```
13+
- Redis
14+
- MongoDB
15+
- Kafka
16+
- MinIO
1817

19-
### Minimum Configuration
18+
## Origin Deploy
2019

21-
The recommended minimum configuration for a production environment is as follows:
20+
### Enter the target dir
2221

23-
```yaml
24-
CPU: 4
25-
Memory: 8G
26-
Disk: 100G
27-
```
22+
`cd ./deployments/deploy/`
2823

29-
## Configuration File Generation
24+
### Deploy configs and dependencies
3025

31-
We have automated all the files, making the generation of configuration files optional for OpenIM. However, if you desire custom configurations, you can follow the steps below:
26+
Upate your configMap `openim-config.yml`. **You can check the official docs for more details.**
3227

33-
```bash
34-
$ make init
35-
# Alternatively, use script:
36-
# ./scripts/init-config.sh
37-
```
28+
In `openim-config.yml`, you need modify the following configurations:
3829

39-
At this point, configuration files will be generated under `deployments/openim/config`, which you can modify as per your requirements.
30+
**discovery.yml**
4031

41-
## Cluster Setup
32+
- `kubernetes.namespace`: default is `default`, you can change it to your namespace.
4233

43-
If you already have a `kubernetes` cluster, or if you wish to build a `kubernetes` cluster from scratch, you can skip this step.
34+
**mongodb.yml**
4435

45-
For a quick start, I used [sealos](https://github.com/labring/sealos) to rapidly set up the cluster, with sealos also being a wrapper for kubeadm at its core:
36+
- `address`: set to your already mongodb address or mongo Service name and port in your deployed.
37+
- `database`: set to your mongodb database name.(Need have a created database.)
38+
- `authSource`: set to your mongodb authSource. (authSource is specify the database name associated with the user's credentials, user need create in this database.)
4639

47-
```bash
48-
$ SEALOS_VERSION=`curl -s https://api.github.com/repos/labring/sealos/releases/latest | grep -oE '"tag_name": "[^"]+"' | head -n1 | cut -d'"' -f4` && \
49-
curl -sfL https://raw.githubusercontent.com/labring/sealos/${SEALOS_VERSION}/scripts/install.sh |
50-
sh -s ${SEALOS_VERSION} labring/sealos
51-
```
40+
**kafka.yml**
5241

53-
**Supported Versions:**
42+
- `address`: set to your already kafka address or kafka Service name and port in your deployed.
5443

55-
+ docker: `labring/kubernetes-docker`:(v1.24.0~v1.27.0)
56-
+ containerd: `labring/kubernetes`:(v1.24.0~v1.27.0)
44+
**redis.yml**
5745

58-
#### Cluster Installation:
46+
- `address`: set to your already redis address or redis Service name and port in your deployed.
5947

60-
Cluster details are as follows:
48+
**minio.yml**
6149

62-
| Hostname | IP Address | System Info |
63-
| -------- | ---------- | ------------------------------------------------------------ |
64-
| master01 | 10.0.0.9 | `Linux VM-0-9-ubuntu 5.15.0-76-generic #83-Ubuntu SMP Thu Jun 15 19:16:32 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux` |
65-
| node01 | 10.0.0.4 | Similar to master01 |
66-
| node02 | 10.0.0.10 | Similar to master01 |
50+
- `internalAddress`: set to your minio Service name and port in your deployed.
51+
- `externalAddress`: set to your already expose minio external address.
6752

68-
```bash
69-
$ export CLUSTER_USERNAME=ubuntu
70-
$ export CLUSTER_PASSWORD=123456
71-
$ sudo sealos run labring/kubernetes:v1.25.0 labring/helm:v3.8.2 labring/calico:v3.24.1 \
72-
--masters 10.0.0.9 \
73-
--nodes 10.0.0.4,10.0.0.10 \
74-
-u "$CLUSTER_USERNAME" \
75-
-p "$CLUSTER_PASSWORD"
76-
```
53+
### Set the secret
7754

78-
> **Node** Uninstallation method: using `kubeadm` for uninstallation does not remove `etcd` and `cni` related configurations. Manual clearance or using `sealos` for uninstallation is needed.
79-
>
80-
> ```bash
81-
> $ sealos reset
82-
> ```
55+
A Secret is an object that contains a small amount of sensitive data. Such as password and secret. Secret is similar to ConfigMaps.
8356

84-
If you are local, you can also use Kind and Minikube to test, for example, using Kind:
57+
#### Redis:
8558

86-
```bash
87-
$ GO111MODULE="on" go get sigs.k8s.io/[email protected]
88-
$ kind create cluster
89-
```
59+
Update the `redis-password` value in `redis-secret.yml` to your Redis password encoded in base64.
9060

91-
### Installing helm
61+
```yaml
62+
apiVersion: v1
63+
kind: Secret
64+
metadata:
65+
name: openim-redis-secret
66+
type: Opaque
67+
data:
68+
redis-password: b3BlbklNMTIz # update to your redis password encoded in base64, if need empty, you can set to ""
69+
```
9270
93-
Helm simplifies the deployment and management of Kubernetes applications to a large extent by offering version control and release management through packaging.
71+
#### Mongo:
9472
95-
**Using Script:**
73+
Update the `mongo_openim_username`, `mongo_openim_password` value in `mongo-secret.yml` to your Mongo username and password encoded in base64.
9674

97-
```bash
98-
$ curl https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 | bash
75+
```yaml
76+
apiVersion: v1
77+
kind: Secret
78+
metadata:
79+
name: openim-mongo-secret
80+
type: Opaque
81+
data:
82+
mongo_openim_username: b3BlbklN # update to your mongo username encoded in base64, if need empty, you can set to "" (this user credentials need in authSource database).
83+
mongo_openim_password: b3BlbklNMTIz # update to your mongo password encoded in base64, if need empty, you can set to ""
9984
```
10085

101-
**Adding Repository:**
86+
#### Minio:
10287

103-
```bash
104-
$ helm repo add brigade https://openimsdk.github.io/openim-charts
88+
Update the `minio-root-user` and `minio-root-password` value in `minio-secret.yml` to your MinIO accessKeyID and secretAccessKey encoded in base64.
89+
90+
```yaml
91+
apiVersion: v1
92+
kind: Secret
93+
metadata:
94+
name: openim-minio-secret
95+
type: Opaque
96+
data:
97+
minio-root-user: cm9vdA== # update to your minio accessKeyID encoded in base64, if need empty, you can set to ""
98+
minio-root-password: b3BlbklNMTIz # update to your minio secretAccessKey encoded in base64, if need empty, you can set to ""
10599
```
106100

107-
### OpenIM Image Strategy
101+
#### Kafka:
108102

109-
Automated offerings include aliyun, ghcr, docker hub: [Image Documentation](https://github.com/openimsdk/open-im-server/blob/main/docs/contrib/images.md)
103+
Update the `kafka-password` value in `kafka-secret.yml` to your Kafka password encoded in base64.
110104

111-
**Local Test Build Method:**
105+
```yaml
106+
apiVersion: v1
107+
kind: Secret
108+
metadata:
109+
name: openim-kafka-secret
110+
type: Opaque
111+
data:
112+
kafka-password: b3BlbklNMTIz # update to your kafka password encoded in base64, if need empty, you can set to ""
113+
```
112114

113-
```bash
114-
$ make image
115+
### Apply the secret.
116+
117+
```shell
118+
kubectl apply -f redis-secret.yml -f minio-secret.yml -f mongo-secret.yml -f kafka-secret.yml
115119
```
116120

117-
> This command assists in quickly building the required images locally. For a detailed build strategy, refer to the [Build Documentation](https://github.com/openimsdk/open-im-server/blob/main/build/README.md).
121+
### Apply all config
118122

119-
## Installation
123+
`kubectl apply -f ./openim-config.yml`
120124

121-
Explore our Helm-Charts repository and read through: [Helm-Charts Repository](https://github.com/openimsdk/helm-charts)
125+
> Attation: If you use `default` namespace, you can excute `clusterRile.yml` to create a cluster role binding for default service account.
126+
>
127+
> Namespace is modify to `discovery.yml` in `openim-config.yml`, you can change `kubernetes.namespace` to your namespace.
122128

129+
**Excute `clusterRole.yml`**
123130

124-
Using the helm charts repository, you can ignore the following configuration, but if you want to just use the server and scale on top of it, you can go ahead:
131+
`kubectl apply -f ./clusterRole.yml`
125132

126-
**Use the Helm template to generate the deployment yaml file: `openim-charts.yaml`**
133+
### run all deployments and services
127134

128-
**Gen Image:**
135+
> Note: Ensure that infrastructure services like MinIO, Redis, and Kafka are running before deploying the main applications.
129136

130137
```bash
131-
../scripts/genconfig.sh ../scripts/install/environment.sh ./templates/helm-image.yaml > ./charts/generated-configs/helm-image.yaml
138+
kubectl apply \
139+
-f openim-api-deployment.yml \
140+
-f openim-api-service.yml \
141+
-f openim-crontask-deployment.yml \
142+
-f openim-rpc-user-deployment.yml \
143+
-f openim-rpc-user-service.yml \
144+
-f openim-msggateway-deployment.yml \
145+
-f openim-msggateway-service.yml \
146+
-f openim-push-deployment.yml \
147+
-f openim-push-service.yml \
148+
-f openim-msgtransfer-service.yml \
149+
-f openim-msgtransfer-deployment.yml \
150+
-f openim-rpc-conversation-deployment.yml \
151+
-f openim-rpc-conversation-service.yml \
152+
-f openim-rpc-auth-deployment.yml \
153+
-f openim-rpc-auth-service.yml \
154+
-f openim-rpc-group-deployment.yml \
155+
-f openim-rpc-group-service.yml \
156+
-f openim-rpc-friend-deployment.yml \
157+
-f openim-rpc-friend-service.yml \
158+
-f openim-rpc-msg-deployment.yml \
159+
-f openim-rpc-msg-service.yml \
160+
-f openim-rpc-third-deployment.yml \
161+
-f openim-rpc-third-service.yml
132162
```
133163

134-
**Gen Charts:**
164+
### Verification
165+
166+
After deploying the services, verify that everything is running smoothly:
135167

136168
```bash
137-
for chart in ./charts/*/; do
138-
if [[ "$chart" == *"generated-configs"* || "$chart" == *"helmfile.yaml"* ]]; then
139-
continue
140-
fi
141-
142-
if [ -f "${chart}values.yaml" ]; then
143-
helm template "$chart" -f "./charts/generated-configs/helm-image.yaml" -f "./charts/generated-configs/config.yaml" -f "./charts/generated-configs/notification.yaml" >> openim-charts.yaml
144-
else
145-
helm template "$chart" >> openim-charts.yaml
146-
fi
147-
done
148-
```
169+
# Check the status of all pods
170+
kubectl get pods
149171
150-
**Use Helmfile:**
172+
# Check the status of services
173+
kubectl get svc
151174
152-
```bash
153-
GO111MODULE=on go get github.com/roboll/helmfile@latest
154-
```
175+
# Check the status of deployments
176+
kubectl get deployments
155177
156-
```bash
157-
export MONGO_ADDRESS=im-mongo
158-
export MONGO_PORT=27017
159-
export REDIS_ADDRESS=im-redis-master
160-
export REDIS_PORT=6379
161-
export KAFKA_ADDRESS=im-kafka
162-
export KAFKA_PORT=9092
163-
export OBJECT_APIURL="https://openim.server.com/api"
164-
export MINIO_ENDPOINT="http://im-minio:9000"
165-
export MINIO_SIGN_ENDPOINT="https://openim.server.com/im-minio-api"
166-
167-
mkdir ./charts/generated-configs
168-
../scripts/genconfig.sh ../scripts/install/environment.sh ./templates/config.yaml > ./charts/generated-configs/config.yaml
169-
cp ../config/notification.yaml ./charts/generated-configs/notification.yaml
170-
../scripts/genconfig.sh ../scripts/install/environment.sh ./templates/helm-image.yaml > ./charts/generated-configs/helm-image.yaml
178+
# View all resources
179+
kubectl get all
171180
```
172181

173-
```bash
174-
helmfile apply
175-
```
182+
### clean all
183+
184+
`kubectl delete -f ./`
185+
186+
### Notes:
187+
188+
- If you use a specific namespace for your deployment, be sure to append the -n <namespace> flag to your kubectl commands.

deployments/deploy/kafka-secret.yml

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
apiVersion: v1
2+
kind: Secret
3+
metadata:
4+
name: openim-kafka-secret
5+
type: Opaque
6+
data:
7+
kafka-password: ""

deployments/deploy/minio-secret.yml

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
apiVersion: v1
2+
kind: Secret
3+
metadata:
4+
name: openim-minio-secret
5+
type: Opaque
6+
data:
7+
minio-root-user: cm9vdA== # Base64 encoded "root"
8+
minio-root-password: b3BlbklNMTIz # Base64 encoded "openIM123"

0 commit comments

Comments
 (0)