复制项目
This commit is contained in:
122
deployments/README.md
Normal file
122
deployments/README.md
Normal file
@@ -0,0 +1,122 @@
|
||||
# OpenIM Chat Deployment
|
||||
|
||||
## Preconditions
|
||||
|
||||
- Ensure deployed OpenIM Server and its dependencies.
|
||||
- Redis
|
||||
- MongoDB
|
||||
- Kafka
|
||||
- MinIO
|
||||
- Expose the corresponding Services and ports of OpenIM Server.
|
||||
|
||||
## Deploy OpenIM Chat
|
||||
|
||||
**Chat depends on OpenIM Server, so you need to deploy OpenIM Server first.**
|
||||
|
||||
enter the target directory
|
||||
|
||||
```shell
|
||||
cd deployments/deploy
|
||||
```
|
||||
|
||||
### Modify ConfigMap
|
||||
|
||||
You need to modify the `chat-config.yml` file to match your environment. Focus on the following fields:
|
||||
**discovery.yml**
|
||||
|
||||
- `kubernetes.namespace`: default is `default`, you can change it to your namespace.
|
||||
|
||||
**mongodb.yml**
|
||||
|
||||
- `address`: set to your already mongodb address or mongo Service name and port in your deployed.
|
||||
- `database`: set to your mongodb database name.(Need have a created database.)
|
||||
- `authSource`: et to your mongodb authSource. (authSource is specify the database name associated with the user's credentials, user need create in this database.)
|
||||
|
||||
**redis.yml**
|
||||
|
||||
- `address`: set to your already redis address or redis Service name and port in your deployed.
|
||||
|
||||
**share.yml**
|
||||
|
||||
- `openIM.apiURL`: modify to your already API address or use your `openim-api` service name and port
|
||||
- `openIM.secret`: same to IM Server `share.secret` value.
|
||||
|
||||
### Set the secret
|
||||
|
||||
A Secret is an object that contains a small amount of sensitive data. Such as password and secret. Secret is similar to ConfigMaps.
|
||||
|
||||
#### Redis:
|
||||
|
||||
Update the `redis-password` value in `redis-secret.yml` to your Redis password encoded in base64.
|
||||
|
||||
```yaml
|
||||
apiVersion: v1
|
||||
kind: Secret
|
||||
metadata:
|
||||
name: openim-redis-secret
|
||||
type: Opaque
|
||||
data:
|
||||
redis-password: b3BlbklNMTIz # update to your redis password encoded in base64, if need empty, you can set to ""
|
||||
```
|
||||
|
||||
#### Mongo:
|
||||
|
||||
Update the `mongo_openim_username`, `mongo_openim_password` value in `mongo-secret.yml` to your Mongo username and password encoded in base64.
|
||||
|
||||
```yaml
|
||||
apiVersion: v1
|
||||
kind: Secret
|
||||
metadata:
|
||||
name: openim-mongo-secret
|
||||
type: Opaque
|
||||
data:
|
||||
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)
|
||||
mongo_openim_password: b3BlbklNMTIz # update to your mongo password encoded in base64, if need empty, you can set to ""
|
||||
```
|
||||
|
||||
### Apply the secret.
|
||||
|
||||
```shell
|
||||
kubectl apply -f redis-secret.yml -f mongo-secret.yml
|
||||
```
|
||||
|
||||
### Apply Config and Services
|
||||
|
||||
deploy the config and services
|
||||
|
||||
```shell
|
||||
kubectl apply -f chat-config.yml -f openim-admin-api-service.yml -f openim-chat-api-service.yml -f openim-admin-rpc-service.yml -f openim-chat-rpc-service.yml
|
||||
```
|
||||
|
||||
### Start Chat Deployments
|
||||
|
||||
```shell
|
||||
kubectl apply -f openim-chat-api-deployment.yml -f openim-admin-api-deployment.yml -f openim-chat-rpc-deployment.yml -f openim-admin-rpc-deployment.yml
|
||||
```
|
||||
|
||||
## Verify
|
||||
|
||||
After the deployment is complete, you can verify the deployment status.
|
||||
|
||||
```shell
|
||||
# Check the status of all pods
|
||||
kubectl get pods
|
||||
|
||||
# Check the status of services
|
||||
kubectl get svc
|
||||
|
||||
# Check the status of deployments
|
||||
kubectl get deployments
|
||||
|
||||
# View all resources
|
||||
kubectl get all
|
||||
|
||||
```
|
||||
|
||||
## clean all
|
||||
|
||||
`kubectl delete -f ./`
|
||||
|
||||
## Notes:
|
||||
|
||||
- If you use a specific namespace for your deployment, be sure to append the -n <namespace> flag to your kubectl commands.
|
||||
148
deployments/deploy/chat-config.yml
Normal file
148
deployments/deploy/chat-config.yml
Normal file
@@ -0,0 +1,148 @@
|
||||
apiVersion: v1
|
||||
kind: ConfigMap
|
||||
metadata:
|
||||
name: openim-chat-config
|
||||
data:
|
||||
discovery.yml: |
|
||||
enable: kubernetes
|
||||
kubernetes:
|
||||
namespace: default
|
||||
etcd:
|
||||
rootDirectory: openim
|
||||
address: [ localhost:12379 ]
|
||||
username: ''
|
||||
password: ''
|
||||
|
||||
rpcService:
|
||||
chat: chat-rpc-service
|
||||
admin: admin-rpc-service
|
||||
|
||||
log.yml: |
|
||||
# Log storage path, default is acceptable, change to a full path if modification is needed
|
||||
# storageLocation: ../../../../logs/
|
||||
storageLocation: ./logs/
|
||||
# Log rotation period (in hours), default is acceptable
|
||||
rotationTime: 24
|
||||
# Number of log files to retain, default is acceptable
|
||||
remainRotationCount: 2
|
||||
# Log level settings: 3 for production environment; 6 for more verbose logging in debugging environments
|
||||
remainLogLevel: 6
|
||||
# Whether to output to standard output, default is acceptable
|
||||
isStdout: true
|
||||
# Whether to log in JSON format, default is acceptable
|
||||
isJson: false
|
||||
# output simplify log when KeyAndValues's value len is bigger than 50 in rpc method log
|
||||
isSimplify: true
|
||||
|
||||
mongodb.yml: |
|
||||
# URI for database connection, leave empty if using address and credential settings directly
|
||||
uri: ''
|
||||
# List of MongoDB server addresses
|
||||
address: [ mongo-service:37017 ]
|
||||
# Name of the database
|
||||
database: openim_v3
|
||||
# Username for database authentication
|
||||
username: openIM
|
||||
# Password for database authentication
|
||||
password: # openIM123
|
||||
# Authentication source for database authentication, if use root user, set it to admin
|
||||
authSource: openim_v3
|
||||
# Maximum number of connections in the connection pool
|
||||
maxPoolSize: 100
|
||||
# Maximum number of retry attempts for a failed database connection
|
||||
maxRetry: 10
|
||||
|
||||
redis.yml: |
|
||||
# List of Redis server addresses
|
||||
address: [ redis-service:16379 ]
|
||||
# Username for Redis authentication (leave blank if not used)
|
||||
username: ''
|
||||
# Password for Redis authentication
|
||||
password: # openIM123
|
||||
# Enable or disable pipeline processing
|
||||
enablePipeline: false
|
||||
# Enable or disable cluster mode
|
||||
clusterMode: false
|
||||
# Database index to be used
|
||||
db: 0
|
||||
# Maximum number of retry attempts for a failed connection
|
||||
maxRetry: 10
|
||||
|
||||
share.yml: |
|
||||
openIM:
|
||||
# OpenIM API address
|
||||
apiURL: http://openim-api-service:10002
|
||||
# OpenIM secret key, must be consistent with OpenIM
|
||||
secret: openIM123
|
||||
# OpenIM administrator userID, must be consistent with OpenIM
|
||||
adminUserID: imAdmin
|
||||
|
||||
chatAdmin:
|
||||
# Default username and password for the admin
|
||||
- "chatAdmin"
|
||||
|
||||
chat-api-admin.yml: |
|
||||
api:
|
||||
# Listening IP; 0.0.0.0 means both internal and external IPs are listened to, default is recommended
|
||||
listenIP: 0.0.0.0
|
||||
# Listening ports; if multiple are configured, multiple instances will be launched
|
||||
ports: [ 10009 ]
|
||||
|
||||
chat-rpc-admin.yml: |
|
||||
rpc:
|
||||
# The IP address where this RPC service registers itself; if left blank, it defaults to the internal network IP
|
||||
registerIP: ''
|
||||
# IP address that the RPC service listens on; setting to 0.0.0.0 listens on both internal and external IPs. If left blank, it automatically uses the internal network IP
|
||||
listenIP: 0.0.0.0
|
||||
# List of ports that the RPC service listens on; configuring multiple ports will launch multiple instances.
|
||||
ports: [ 30200 ]
|
||||
|
||||
tokenPolicy:
|
||||
expire: 90
|
||||
|
||||
secret: chat123
|
||||
chat-api-chat.yml: |
|
||||
api:
|
||||
# Listening IP; 0.0.0.0 means both internal and external IPs are listened to, default is recommended
|
||||
listenIP: 0.0.0.0
|
||||
# Listening ports; if multiple are configured, multiple instances will be launched
|
||||
ports: [ 10008 ]
|
||||
|
||||
chat-rpc-chat.yml: |
|
||||
rpc:
|
||||
# The IP address where this RPC service registers itself; if left blank, it defaults to the internal network IP
|
||||
registerIP: ''
|
||||
# IP address that the RPC service listens on; setting to 0.0.0.0 listens on both internal and external IPs. If left blank, it automatically uses the internal network IP
|
||||
listenIP: 0.0.0.0
|
||||
# List of ports that the RPC service listens on; configuring multiple ports will launch multiple instances.
|
||||
ports: [ 30300 ]
|
||||
|
||||
verifyCode:
|
||||
validTime: 300
|
||||
validCount: 5
|
||||
uintTime: 86400
|
||||
maxCount: 10
|
||||
superCode: "666666"
|
||||
len: 6
|
||||
phone:
|
||||
use: ""
|
||||
ali:
|
||||
endpoint: ""
|
||||
accessKeyId: ""
|
||||
accessKeySecret: ""
|
||||
signName: ""
|
||||
verificationCodeTemplateCode: ""
|
||||
mail:
|
||||
enable: false
|
||||
title: ""
|
||||
senderMail: ""
|
||||
senderAuthorizationCode: ""
|
||||
smtpAddr: ""
|
||||
smtpPort:
|
||||
|
||||
liveKit:
|
||||
url: "ws://127.0.0.1:7880" # LIVEKIT_URL, LiveKit server address and port
|
||||
key: "APIGPW3gnFTzqHH"
|
||||
secret: "23ztfSqsfQ8hKkHzHTl3Z4bvaxro0snjk5jwbp5p6Q3"
|
||||
|
||||
allowRegister: true
|
||||
8
deployments/deploy/mongo-secret.yml
Normal file
8
deployments/deploy/mongo-secret.yml
Normal file
@@ -0,0 +1,8 @@
|
||||
apiVersion: v1
|
||||
kind: Secret
|
||||
metadata:
|
||||
name: openim-mongo-secret
|
||||
type: Opaque
|
||||
data:
|
||||
mongo_openim_username: b3BlbklN # base64 for "openIM", this user credentials need in authSource database.
|
||||
mongo_openim_password: b3BlbklNMTIz # base64 for "openIM123"
|
||||
49
deployments/deploy/openim-admin-api-deployment.yml
Normal file
49
deployments/deploy/openim-admin-api-deployment.yml
Normal file
@@ -0,0 +1,49 @@
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: admin-api-server
|
||||
spec:
|
||||
replicas: 1
|
||||
selector:
|
||||
matchLabels:
|
||||
app: admin-api-server
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: admin-api-server
|
||||
spec:
|
||||
imagePullSecrets:
|
||||
- name: dockerhub-secret
|
||||
containers:
|
||||
- name: openim-admin-api-container
|
||||
image: mag1666888/openim-admin-api:prod
|
||||
imagePullPolicy: Always
|
||||
env:
|
||||
- name: CONFIG_PATH
|
||||
value: "/config"
|
||||
- name: CHATENV_REDIS_PASSWORD
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: openim-redis-secret
|
||||
key: redis-password
|
||||
- name: IMENV_MONGODB_USERNAME
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: openim-mongo-secret
|
||||
key: mongo_openim_username
|
||||
- name: CHATENV_MONGODB_PASSWORD
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: openim-mongo-secret
|
||||
key: mongo_openim_password
|
||||
|
||||
volumeMounts:
|
||||
- name: openim-chat-config
|
||||
mountPath: "/config"
|
||||
readOnly: true
|
||||
ports:
|
||||
- containerPort: 10009
|
||||
volumes:
|
||||
- name: openim-chat-config
|
||||
configMap:
|
||||
name: openim-chat-config
|
||||
13
deployments/deploy/openim-admin-api-service.yml
Normal file
13
deployments/deploy/openim-admin-api-service.yml
Normal file
@@ -0,0 +1,13 @@
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: admin-api-service
|
||||
spec:
|
||||
selector:
|
||||
app: admin-api-server
|
||||
ports:
|
||||
- name: http-10009
|
||||
protocol: TCP
|
||||
port: 10009
|
||||
targetPort: 10009
|
||||
type: NodePort
|
||||
49
deployments/deploy/openim-admin-rpc-deployment.yml
Normal file
49
deployments/deploy/openim-admin-rpc-deployment.yml
Normal file
@@ -0,0 +1,49 @@
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: admin-rpc-server
|
||||
spec:
|
||||
replicas: 1
|
||||
selector:
|
||||
matchLabels:
|
||||
app: admin-rpc-server
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: admin-rpc-server
|
||||
spec:
|
||||
imagePullSecrets:
|
||||
- name: dockerhub-secret
|
||||
containers:
|
||||
- name: openim-admin-rpc-container
|
||||
image: mag1666888/openim-admin-rpc:prod
|
||||
imagePullPolicy: Always
|
||||
env:
|
||||
- name: CONFIG_PATH
|
||||
value: "/config"
|
||||
- name: CHATENV_REDIS_PASSWORD
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: openim-redis-secret
|
||||
key: redis-password
|
||||
- name: IMENV_MONGODB_USERNAME
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: openim-mongo-secret
|
||||
key: mongo_openim_username
|
||||
- name: CHATENV_MONGODB_PASSWORD
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: openim-mongo-secret
|
||||
key: mongo_openim_password
|
||||
|
||||
volumeMounts:
|
||||
- name: openim-chat-config
|
||||
mountPath: "/config"
|
||||
readOnly: true
|
||||
ports:
|
||||
- containerPort: 30200
|
||||
volumes:
|
||||
- name: openim-chat-config
|
||||
configMap:
|
||||
name: openim-chat-config
|
||||
13
deployments/deploy/openim-admin-rpc-service.yml
Normal file
13
deployments/deploy/openim-admin-rpc-service.yml
Normal file
@@ -0,0 +1,13 @@
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: admin-rpc-service
|
||||
spec:
|
||||
selector:
|
||||
app: admin-rpc-server
|
||||
ports:
|
||||
- name: rpc-30200
|
||||
protocol: TCP
|
||||
port: 30200
|
||||
targetPort: 30200
|
||||
type: ClusterIP
|
||||
49
deployments/deploy/openim-chat-api-deployment.yml
Normal file
49
deployments/deploy/openim-chat-api-deployment.yml
Normal file
@@ -0,0 +1,49 @@
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: chat-api-server
|
||||
spec:
|
||||
replicas: 1
|
||||
selector:
|
||||
matchLabels:
|
||||
app: chat-api-server
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: chat-api-server
|
||||
spec:
|
||||
imagePullSecrets:
|
||||
- name: dockerhub-secret
|
||||
containers:
|
||||
- name: openim-chat-api-container
|
||||
image: mag1666888/openim-chat-api:prod
|
||||
imagePullPolicy: Always
|
||||
env:
|
||||
- name: CONFIG_PATH
|
||||
value: "/config"
|
||||
- name: CHATENV_REDIS_PASSWORD
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: openim-redis-secret
|
||||
key: redis-password
|
||||
- name: IMENV_MONGODB_USERNAME
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: openim-mongo-secret
|
||||
key: mongo_openim_username
|
||||
- name: CHATENV_MONGODB_PASSWORD
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: openim-mongo-secret
|
||||
key: mongo_openim_password
|
||||
|
||||
volumeMounts:
|
||||
- name: openim-chat-config
|
||||
mountPath: "/config"
|
||||
readOnly: true
|
||||
ports:
|
||||
- containerPort: 10008
|
||||
volumes:
|
||||
- name: openim-chat-config
|
||||
configMap:
|
||||
name: openim-chat-config
|
||||
13
deployments/deploy/openim-chat-api-service.yml
Normal file
13
deployments/deploy/openim-chat-api-service.yml
Normal file
@@ -0,0 +1,13 @@
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: chat-api-service
|
||||
spec:
|
||||
selector:
|
||||
app: chat-api-server
|
||||
ports:
|
||||
- name: http-10008
|
||||
protocol: TCP
|
||||
port: 10008
|
||||
targetPort: 10008
|
||||
type: NodePort
|
||||
49
deployments/deploy/openim-chat-rpc-deployment.yml
Normal file
49
deployments/deploy/openim-chat-rpc-deployment.yml
Normal file
@@ -0,0 +1,49 @@
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: chat-rpc-server
|
||||
spec:
|
||||
replicas: 1
|
||||
selector:
|
||||
matchLabels:
|
||||
app: chat-rpc-server
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: chat-rpc-server
|
||||
spec:
|
||||
imagePullSecrets:
|
||||
- name: dockerhub-secret
|
||||
containers:
|
||||
- name: openim-chat-rpc-container
|
||||
image: mag1666888/openim-chat-rpc:prod
|
||||
imagePullPolicy: Always
|
||||
env:
|
||||
- name: CONFIG_PATH
|
||||
value: "/config"
|
||||
- name: CHATENV_REDIS_PASSWORD
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: openim-redis-secret
|
||||
key: redis-password
|
||||
- name: IMENV_MONGODB_USERNAME
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: openim-mongo-secret
|
||||
key: mongo_openim_username
|
||||
- name: CHATENV_MONGODB_PASSWORD
|
||||
valueFrom:
|
||||
secretKeyRef:
|
||||
name: openim-mongo-secret
|
||||
key: mongo_openim_password
|
||||
|
||||
volumeMounts:
|
||||
- name: openim-chat-config
|
||||
mountPath: "/config"
|
||||
readOnly: true
|
||||
ports:
|
||||
- containerPort: 30300
|
||||
volumes:
|
||||
- name: openim-chat-config
|
||||
configMap:
|
||||
name: openim-chat-config
|
||||
13
deployments/deploy/openim-chat-rpc-service.yml
Normal file
13
deployments/deploy/openim-chat-rpc-service.yml
Normal file
@@ -0,0 +1,13 @@
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: chat-rpc-service
|
||||
spec:
|
||||
selector:
|
||||
app: chat-rpc-server
|
||||
ports:
|
||||
- name: rpc-30300
|
||||
protocol: TCP
|
||||
port: 30300
|
||||
targetPort: 30300
|
||||
type: ClusterIP
|
||||
7
deployments/deploy/redis-secret.yml
Normal file
7
deployments/deploy/redis-secret.yml
Normal file
@@ -0,0 +1,7 @@
|
||||
apiVersion: v1
|
||||
kind: Secret
|
||||
metadata:
|
||||
name: openim-redis-secret
|
||||
type: Opaque
|
||||
data:
|
||||
redis-password: b3BlbklNMTIz # "openIM123" in base64
|
||||
Reference in New Issue
Block a user