From 201f1f009e6e06c92587fc1030090658c5e59787 Mon Sep 17 00:00:00 2001 From: Monet Lee Date: Wed, 13 Nov 2024 12:28:21 +0800 Subject: [PATCH] build: update k8s origin deploys. --- deployments/deploy/README.md | 73 ++ deployments/deploy/ingress.yml | 25 + deployments/deploy/kafka-service.yml | 20 + deployments/deploy/kafka-statefulset.yml | 104 ++ deployments/deploy/minio-service.yml | 18 + deployments/deploy/minio-statefulset.yml | 89 ++ deployments/deploy/mongo-service.yml | 13 + deployments/deploy/mongo-statefulset.yml | 82 ++ deployments/deploy/notification-config.yml | 334 +++++ deployments/deploy/openim-api-deployment.yml | 34 + deployments/deploy/openim-api-service.yml | 17 + deployments/deploy/openim-config.yml | 1124 +++++++++++++++++ .../deploy/openim-crontask-deployment.yml | 30 + .../deploy/openim-msggateway-deployment.yml | 33 + .../deploy/openim-msggateway-service.yml | 17 + .../deploy/openim-msgtransfer-deployment.yml | 33 + .../deploy/openim-msgtransfer-service.yml | 14 + deployments/deploy/openim-push-deployment.yml | 40 + deployments/deploy/openim-push-service.yml | 17 + .../deploy/openim-rpc-auth-deployment.yml | 34 + .../deploy/openim-rpc-auth-service.yml | 17 + .../openim-rpc-conversation-deployment.yml | 41 + .../openim-rpc-conversation-service.yml | 17 + .../deploy/openim-rpc-friend-deployment.yml | 46 + .../deploy/openim-rpc-friend-service.yml | 17 + .../deploy/openim-rpc-group-deployment.yml | 41 + .../deploy/openim-rpc-group-service.yml | 17 + .../deploy/openim-rpc-msg-deployment.yml | 41 + deployments/deploy/openim-rpc-msg-service.yml | 17 + .../deploy/openim-rpc-third-deployment.yml | 51 + .../deploy/openim-rpc-third-service.yml | 17 + .../deploy/openim-rpc-user-deployment.yml | 41 + .../deploy/openim-rpc-user-service.yml | 17 + deployments/deploy/prometheus-config.yml | 112 ++ deployments/deploy/redis-service.yml | 15 + deployments/deploy/redis-statefulset.yml | 66 + 36 files changed, 2724 insertions(+) create mode 100644 deployments/deploy/README.md create mode 100644 deployments/deploy/ingress.yml create mode 100644 deployments/deploy/kafka-service.yml create mode 100644 deployments/deploy/kafka-statefulset.yml create mode 100644 deployments/deploy/minio-service.yml create mode 100644 deployments/deploy/minio-statefulset.yml create mode 100644 deployments/deploy/mongo-service.yml create mode 100644 deployments/deploy/mongo-statefulset.yml create mode 100644 deployments/deploy/notification-config.yml create mode 100644 deployments/deploy/openim-api-deployment.yml create mode 100644 deployments/deploy/openim-api-service.yml create mode 100644 deployments/deploy/openim-config.yml create mode 100644 deployments/deploy/openim-crontask-deployment.yml create mode 100644 deployments/deploy/openim-msggateway-deployment.yml create mode 100644 deployments/deploy/openim-msggateway-service.yml create mode 100644 deployments/deploy/openim-msgtransfer-deployment.yml create mode 100644 deployments/deploy/openim-msgtransfer-service.yml create mode 100644 deployments/deploy/openim-push-deployment.yml create mode 100644 deployments/deploy/openim-push-service.yml create mode 100644 deployments/deploy/openim-rpc-auth-deployment.yml create mode 100644 deployments/deploy/openim-rpc-auth-service.yml create mode 100644 deployments/deploy/openim-rpc-conversation-deployment.yml create mode 100644 deployments/deploy/openim-rpc-conversation-service.yml create mode 100644 deployments/deploy/openim-rpc-friend-deployment.yml create mode 100644 deployments/deploy/openim-rpc-friend-service.yml create mode 100644 deployments/deploy/openim-rpc-group-deployment.yml create mode 100644 deployments/deploy/openim-rpc-group-service.yml create mode 100644 deployments/deploy/openim-rpc-msg-deployment.yml create mode 100644 deployments/deploy/openim-rpc-msg-service.yml create mode 100644 deployments/deploy/openim-rpc-third-deployment.yml create mode 100644 deployments/deploy/openim-rpc-third-service.yml create mode 100644 deployments/deploy/openim-rpc-user-deployment.yml create mode 100644 deployments/deploy/openim-rpc-user-service.yml create mode 100644 deployments/deploy/prometheus-config.yml create mode 100644 deployments/deploy/redis-service.yml create mode 100644 deployments/deploy/redis-statefulset.yml diff --git a/deployments/deploy/README.md b/deployments/deploy/README.md new file mode 100644 index 000000000..874a33976 --- /dev/null +++ b/deployments/deploy/README.md @@ -0,0 +1,73 @@ +# Kubernetes Deployment + +## Origin Deploy + +## First, Deployment All config and services + +1. Enter the target dir +`cd ./deployments/deploy/` + +2. Deploy configs and dependencies + +Apply all config and dependencies +`kubectl apply -f ./openim-config.yml -f ./notification-config.yml -f ./kafka-service.yml` + +Run infrasturcture components. + +`kubectl apply -f minio-service.yml -f minio-statefulset.yml -f mongo-service.yml -f mongo-statefulset.yml -f redis-service.yml -f redis-statefulset.yml -f kafka-service.yml -f kafka-statefulset.yml` + +>Note: Ensure that infrastructure services like MinIO, Redis, and Kafka are running before deploying the main applications. + + +Final, run all deployments and services + +```bash +kubectl apply \ + -f openim-api-deployment.yml \ + -f openim-api-service.yml \ + -f openim-crontask-deployment.yml \ + -f openim-rpc-user-deployment.yml \ + -f openim-rpc-user-service.yml \ + -f openim-msggateway-deployment.yml \ + -f openim-msggateway-service.yml \ + -f openim-push-deployment.yml \ + -f openim-push-service.yml \ + -f openim-msgtransfer-service.yml \ + -f openim-msgtransfer-deployment.yml \ + -f openim-rpc-conversation-deployment.yml \ + -f openim-rpc-conversation-service.yml \ + -f openim-rpc-auth-deployment.yml \ + -f openim-rpc-auth-service.yml \ + -f openim-rpc-group-deployment.yml \ + -f openim-rpc-group-service.yml \ + -f openim-rpc-friend-deployment.yml \ + -f openim-rpc-friend-service.yml \ + -f openim-rpc-msg-deployment.yml \ + -f openim-rpc-msg-service.yml \ + -f openim-rpc-third-deployment.yml \ + -f openim-rpc-third-service.yml +``` + +4. Verification +After deploying the services, verify that everything is running smoothly: + +```bash +# 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 +``` + +5. clean all + +`kubectl delete -f ./` + +### Notes: +- If you use a specific namespace for your deployment, be sure to append the -n flag to your kubectl commands. \ No newline at end of file diff --git a/deployments/deploy/ingress.yml b/deployments/deploy/ingress.yml new file mode 100644 index 000000000..8a4fbaa02 --- /dev/null +++ b/deployments/deploy/ingress.yml @@ -0,0 +1,25 @@ +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + name: openim-ingress + annotations: + nginx.ingress.kubernetes.io/rewrite-target: / +spec: + ingressClassName: openim-nginx + rules: + - http: + paths: + - path: /openim-api + pathType: Prefix + backend: + service: + name: openim-api-service + port: + number: 10002 + - path: /openim-msggateway + pathType: Prefix + backend: + service: + name: openim-msggateway-service + port: + number: 10001 diff --git a/deployments/deploy/kafka-service.yml b/deployments/deploy/kafka-service.yml new file mode 100644 index 000000000..675600b98 --- /dev/null +++ b/deployments/deploy/kafka-service.yml @@ -0,0 +1,20 @@ +apiVersion: v1 +kind: Service +metadata: + name: kafka-service + labels: + app: kafka +spec: + ports: + - name: plaintext + port: 9092 + targetPort: 9092 + - name: controller + port: 9093 + targetPort: 9093 + - name: external + port: 19094 + targetPort: 9094 + selector: + app: kafka + type: ClusterIP diff --git a/deployments/deploy/kafka-statefulset.yml b/deployments/deploy/kafka-statefulset.yml new file mode 100644 index 000000000..27821bb69 --- /dev/null +++ b/deployments/deploy/kafka-statefulset.yml @@ -0,0 +1,104 @@ +apiVersion: apps/v1 +kind: StatefulSet +metadata: + name: kafka-statefulset + labels: + app: kafka +spec: + replicas: 1 + selector: + matchLabels: + app: kafka + serviceName: "kafka-service" + template: + metadata: + labels: + app: kafka + spec: + containers: + - name: kafka + image: bitnami/kafka:3.5.1 + imagePullPolicy: IfNotPresent + resources: + limits: + memory: "2Gi" + cpu: "1000m" + requests: + memory: "1Gi" + cpu: "500m" + ports: + - containerPort: 9092 # PLAINTEXT + - containerPort: 9093 # CONTROLLER + - containerPort: 9094 # EXTERNAL + # command: + # - /bin/bash + # - "-c" + # - | + # # /opt/bitnami/scripts/kafka/run.sh & /opt/bitnami/kafka/create-topic.sh; wait + # # /opt/bitnami/scripts/kafka/entrypoint.sh && /opt/bitnami/scripts/kafka/setup.sh && /opt/bitnami/scripts/kafka/run.sh + # & while ! echo > /dev/tcp/localhost/9092; do + # echo "Waiting for Kafka to start..." + # sleep 5 + # done + # /opt/bitnami/kafka/create-topic.sh + # tail -f /dev/null + env: + - name: TZ + value: "Asia/Shanghai" + - name: KAFKA_CFG_NODE_ID + value: "0" + - name: KAFKA_CFG_PROCESS_ROLES + value: "controller,broker" + - name: KAFKA_CFG_CONTROLLER_QUORUM_VOTERS + value: "0@kafka-service:9093" + - name: KAFKA_CFG_LISTENERS + value: "PLAINTEXT://:9092,CONTROLLER://:9093,EXTERNAL://:9094" + - name: KAFKA_CFG_ADVERTISED_LISTENERS + value: "PLAINTEXT://kafka-service:9092,EXTERNAL://kafka-service:19094" + - name: KAFKA_CFG_LISTENER_SECURITY_PROTOCOL_MAP + value: "CONTROLLER:PLAINTEXT,EXTERNAL:PLAINTEXT,PLAINTEXT:PLAINTEXT" + - name: KAFKA_CFG_CONTROLLER_LISTENER_NAMES + value: "CONTROLLER" + volumeMounts: + - name: kafka-data + mountPath: /bitnami/kafka + - name: kafka-scripts + mountPath: /opt/bitnami/kafka/create-topic.sh + subPath: create-topic.sh + - name: create-topics + image: bitnami/kafka:3.5.1 + command: + - /bin/bash + - "-c" + - | + /opt/bitnami/kafka/create-topic.sh && \ + tail -f /dev/null + volumeMounts: + - name: kafka-scripts + mountPath: /opt/bitnami/kafka/create-topic.sh + subPath: create-topic.sh + - name: kafka-data + mountPath: /bitnami/kafka + volumes: + - name: kafka-scripts + configMap: + name: openim-config + defaultMode: 0755 + items: + - key: create-topic.sh + path: create-topic.sh + - name: kafka-data + persistentVolumeClaim: + claimName: kafka-pvc + +--- +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + name: kafka-pvc +spec: + accessModes: + - ReadWriteOnce + resources: + requests: + storage: 10Gi diff --git a/deployments/deploy/minio-service.yml b/deployments/deploy/minio-service.yml new file mode 100644 index 000000000..1aeeb5f6c --- /dev/null +++ b/deployments/deploy/minio-service.yml @@ -0,0 +1,18 @@ +--- +apiVersion: v1 +kind: Service +metadata: + name: minio-service +spec: + selector: + app: minio + ports: + - name: minio + protocol: TCP + port: 10005 # External port for accessing MinIO service + targetPort: 9000 # Container port for MinIO service + - name: minio-console + protocol: TCP + port: 19090 # External port for accessing MinIO console + targetPort: 9090 # Container port for MinIO console + type: NodePort diff --git a/deployments/deploy/minio-statefulset.yml b/deployments/deploy/minio-statefulset.yml new file mode 100644 index 000000000..f7028d8ef --- /dev/null +++ b/deployments/deploy/minio-statefulset.yml @@ -0,0 +1,89 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: minio + labels: + app: minio +spec: + replicas: 1 + selector: + matchLabels: + app: minio + template: + metadata: + labels: + app: minio + spec: + containers: + - name: minio + image: minio/minio:RELEASE.2024-01-11T07-46-16Z + imagePullPolicy: IfNotPresent + ports: + - containerPort: 9000 # MinIO service port + - containerPort: 9090 # MinIO console port + volumeMounts: + - name: minio-data + mountPath: /data + - name: minio-config + mountPath: /root/.minio + env: + - name: TZ + value: "Asia/Shanghai" + - name: MINIO_ACCESS_KEY + valueFrom: + secretKeyRef: + name: minio-secret + key: minio-root-user + - name: MINIO_SECRET_KEY + valueFrom: + secretKeyRef: + name: minio-secret + key: minio-root-password + + command: + - minio + - server + - /data + - "--console-address" + - ":9090" + volumes: + - name: minio-data + persistentVolumeClaim: + claimName: minio-pvc + - name: minio-config + persistentVolumeClaim: + claimName: minio-config-pvc + +--- +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + name: minio-pvc +spec: + accessModes: + - ReadWriteOnce + resources: + requests: + storage: 10Gi + +--- +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + name: minio-config-pvc +spec: + accessModes: + - ReadWriteOnce + resources: + requests: + storage: 2Gi + +--- +apiVersion: v1 +kind: Secret +metadata: + name: minio-secret +type: Opaque +data: + minio-root-user: cm9vdA== # Base64 encoded "root" + minio-root-password: b3BlbklNMTIz # Base64 encoded "openIM123" diff --git a/deployments/deploy/mongo-service.yml b/deployments/deploy/mongo-service.yml new file mode 100644 index 000000000..ea5a85203 --- /dev/null +++ b/deployments/deploy/mongo-service.yml @@ -0,0 +1,13 @@ +apiVersion: v1 +kind: Service +metadata: + name: mongo-service +spec: + selector: + app: mongo + ports: + - name: mongodb-port + protocol: TCP + port: 37017 + targetPort: 27017 + type: ClusterIP diff --git a/deployments/deploy/mongo-statefulset.yml b/deployments/deploy/mongo-statefulset.yml new file mode 100644 index 000000000..2359cbce9 --- /dev/null +++ b/deployments/deploy/mongo-statefulset.yml @@ -0,0 +1,82 @@ +apiVersion: apps/v1 +kind: StatefulSet +metadata: + name: mongo-statefulset +spec: + serviceName: "mongo" + replicas: 1 + selector: + matchLabels: + app: mongo + template: + metadata: + labels: + app: mongo + spec: + containers: + - name: mongo + image: mongo:6.0.2 + command: + [ + "/bin/bash", + "-c", + "docker-entrypoint.sh mongod --wiredTigerCacheSizeGB 1 --auth & sleep 15; /scripts/mongo-init.sh; wait", + ] + ports: + - containerPort: 27017 + env: + - name: MONGO_INITDB_ROOT_USERNAME + valueFrom: + secretKeyRef: + name: mongo-secret + key: mongo_initdb_root_username + - name: MONGO_INITDB_ROOT_PASSWORD + valueFrom: + secretKeyRef: + name: mongo-secret + key: mongo_initdb_root_password + - name: MONGO_INITDB_DATABASE + valueFrom: + secretKeyRef: + name: mongo-secret + key: mongo_initdb_database + - name: MONGO_OPENIM_USERNAME + valueFrom: + secretKeyRef: + name: mongo-secret + key: mongo_openim_username + - name: MONGO_OPENIM_PASSWORD + valueFrom: + secretKeyRef: + name: mongo-secret + key: mongo_openim_password + volumeMounts: + - name: mongo-storage + mountPath: /data/db + - name: script-volume + mountPath: /scripts + # subPath: mongo-init.sh + + volumes: + - name: script-volume + configMap: + name: openim-config + items: + - key: mongo-init.sh + path: mongo-init.sh + mode: 0755 + - name: mongo-storage + persistentVolumeClaim: + claimName: mongo-pvc + +--- +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + name: mongo-pvc +spec: + accessModes: + - ReadWriteOnce + resources: + requests: + storage: 5Gi diff --git a/deployments/deploy/notification-config.yml b/deployments/deploy/notification-config.yml new file mode 100644 index 000000000..0f45616b0 --- /dev/null +++ b/deployments/deploy/notification-config.yml @@ -0,0 +1,334 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: notification-config +data: + notification.yml: | + groupCreated: + isSendMsg: true + # Reliability level of the message sending. + # Set to 1 to send only when online, 2 for guaranteed delivery. + reliabilityLevel: 1 + # This setting is effective only when 'isSendMsg' is true. + # It controls whether to count unread messages. + unreadCount: false + # Configuration for offline push notifications. + offlinePush: + # Enables or disables offline push notifications. + enable: false + # Title for the notification when a group is created. + title: create group title + # Description for the notification. + desc: create group desc + # Additional information for the notification. + ext: create group ext + + groupInfoSet: + isSendMsg: false + reliabilityLevel: 1 + unreadCount: false + offlinePush: + enable: false + title: groupInfoSet title + desc: groupInfoSet desc + ext: groupInfoSet ext + + + joinGroupApplication: + isSendMsg: false + reliabilityLevel: 1 + unreadCount: false + offlinePush: + enable: false + title: joinGroupApplication title + desc: joinGroupApplication desc + ext: joinGroupApplication ext + + memberQuit: + isSendMsg: true + reliabilityLevel: 1 + unreadCount: false + offlinePush: + enable: false + title: memberQuit title + desc: memberQuit desc + ext: memberQuit ext + + groupApplicationAccepted: + isSendMsg: false + reliabilityLevel: 1 + unreadCount: false + offlinePush: + enable: false + title: groupApplicationAccepted title + desc: groupApplicationAccepted desc + ext: groupApplicationAccepted ext + + groupApplicationRejected: + isSendMsg: false + reliabilityLevel: 1 + unreadCount: false + offlinePush: + enable: false + title: groupApplicationRejected title + desc: groupApplicationRejected desc + ext: groupApplicationRejected ext + + + groupOwnerTransferred: + isSendMsg: true + reliabilityLevel: 1 + unreadCount: false + offlinePush: + enable: false + title: groupOwnerTransferred title + desc: groupOwnerTransferred desc + ext: groupOwnerTransferred ext + + memberKicked: + isSendMsg: true + reliabilityLevel: 1 + unreadCount: false + offlinePush: + enable: false + title: memberKicked title + desc: memberKicked desc + ext: memberKicked ext + + memberInvited: + isSendMsg: true + reliabilityLevel: 1 + unreadCount: false + offlinePush: + enable: false + title: memberInvited title + desc: memberInvited desc + ext: memberInvited ext + + memberEnter: + isSendMsg: true + reliabilityLevel: 1 + unreadCount: false + offlinePush: + enable: false + title: memberEnter title + desc: memberEnter desc + ext: memberEnter ext + + groupDismissed: + isSendMsg: true + reliabilityLevel: 1 + unreadCount: false + offlinePush: + enable: false + title: groupDismissed title + desc: groupDismissed desc + ext: groupDismissed ext + + groupMuted: + isSendMsg: true + reliabilityLevel: 1 + unreadCount: false + offlinePush: + enable: false + title: groupMuted title + desc: groupMuted desc + ext: groupMuted ext + + groupCancelMuted: + isSendMsg: true + reliabilityLevel: 1 + unreadCount: false + offlinePush: + enable: false + title: groupCancelMuted title + desc: groupCancelMuted desc + ext: groupCancelMuted ext + defaultTips: + tips: group Cancel Muted + + + groupMemberMuted: + isSendMsg: true + reliabilityLevel: 1 + unreadCount: false + offlinePush: + enable: false + title: groupMemberMuted title + desc: groupMemberMuted desc + ext: groupMemberMuted ext + + groupMemberCancelMuted: + isSendMsg: true + reliabilityLevel: 1 + unreadCount: false + offlinePush: + enable: false + title: groupMemberCancelMuted title + desc: groupMemberCancelMuted desc + ext: groupMemberCancelMuted ext + + groupMemberInfoSet: + isSendMsg: false + reliabilityLevel: 1 + unreadCount: false + offlinePush: + enable: false + title: groupMemberInfoSet title + desc: groupMemberInfoSet desc + ext: groupMemberInfoSet ext + + groupInfoSetAnnouncement: + isSendMsg: true + reliabilityLevel: 1 + unreadCount: false + offlinePush: + enable: false + title: groupInfoSetAnnouncement title + desc: groupInfoSetAnnouncement desc + ext: groupInfoSetAnnouncement ext + + + groupInfoSetName: + isSendMsg: true + reliabilityLevel: 1 + unreadCount: false + offlinePush: + enable: false + title: groupInfoSetName title + desc: groupInfoSetName desc + ext: groupInfoSetName ext + + + #############################friend################################# + friendApplicationAdded: + isSendMsg: false + reliabilityLevel: 1 + unreadCount: false + offlinePush: + enable: false + title: Somebody applies to add you as a friend + desc: Somebody applies to add you as a friend + ext: Somebody applies to add you as a friend + + friendApplicationApproved: + isSendMsg: true + reliabilityLevel: 1 + unreadCount: false + offlinePush: + enable: true + title: Someone applies to add your friend application + desc: Someone applies to add your friend application + ext: Someone applies to add your friend application + + friendApplicationRejected: + isSendMsg: false + reliabilityLevel: 1 + unreadCount: false + offlinePush: + enable: true + title: Someone rejected your friend application + desc: Someone rejected your friend application + ext: Someone rejected your friend application + + friendAdded: + isSendMsg: false + reliabilityLevel: 1 + unreadCount: false + offlinePush: + enable: true + title: We have become friends + desc: We have become friends + ext: We have become friends + + friendDeleted: + isSendMsg: false + reliabilityLevel: 1 + unreadCount: false + offlinePush: + enable: true + title: deleted a friend + desc: deleted a friend + ext: deleted a friend + + friendRemarkSet: + isSendMsg: false + reliabilityLevel: 1 + unreadCount: false + offlinePush: + enable: true + title: Your friend's profile has been changed + desc: Your friend's profile has been changed + ext: Your friend's profile has been changed + + blackAdded: + isSendMsg: false + reliabilityLevel: 1 + unreadCount: false + offlinePush: + enable: true + title: blocked a user + desc: blocked a user + ext: blocked a user + + blackDeleted: + isSendMsg: false + reliabilityLevel: 1 + unreadCount: false + offlinePush: + enable: true + title: Remove a blocked user + desc: Remove a blocked user + ext: Remove a blocked user + + friendInfoUpdated: + isSendMsg: false + reliabilityLevel: 1 + unreadCount: false + offlinePush: + enable: true + title: friend info updated + desc: friend info updated + ext: friend info updated + + #####################user######################### + userInfoUpdated: + isSendMsg: false + reliabilityLevel: 1 + unreadCount: false + offlinePush: + enable: true + title: userInfo updated + desc: userInfo updated + ext: userInfo updated + + userStatusChanged: + isSendMsg: false + reliabilityLevel: 1 + unreadCount: false + offlinePush: + enable: false + title: user status changed + desc: user status changed + ext: user status changed + + #####################conversation######################### + conversationChanged: + isSendMsg: false + reliabilityLevel: 1 + unreadCount: false + offlinePush: + enable: true + title: conversation changed + desc: conversation changed + ext: conversation changed + + conversationSetPrivate: + isSendMsg: true + reliabilityLevel: 1 + unreadCount: false + offlinePush: + enable: true + title: burn after reading + desc: burn after reading + ext: burn after reading diff --git a/deployments/deploy/openim-api-deployment.yml b/deployments/deploy/openim-api-deployment.yml new file mode 100644 index 000000000..981717156 --- /dev/null +++ b/deployments/deploy/openim-api-deployment.yml @@ -0,0 +1,34 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: openim-api +spec: + replicas: 1 + selector: + matchLabels: + app: openim-api + template: + metadata: + labels: + app: openim-api + spec: + containers: + - name: openim-api-container + image: op-api:v3.90 + # imagePullPolicy: Never + env: + - name: CONFIG_PATH + value: "/config" + - name: DEPLOYMENT_TYPE + value: "kubernetes" + volumeMounts: + - name: openim-config + mountPath: "/config" + readOnly: true + ports: + - containerPort: 10002 + - containerPort: 12002 + volumes: + - name: openim-config + configMap: + name: openim-config diff --git a/deployments/deploy/openim-api-service.yml b/deployments/deploy/openim-api-service.yml new file mode 100644 index 000000000..468b5721f --- /dev/null +++ b/deployments/deploy/openim-api-service.yml @@ -0,0 +1,17 @@ +apiVersion: v1 +kind: Service +metadata: + name: openim-api-service +spec: + selector: + app: openim-api + ports: + - name: http-10302 + protocol: TCP + port: 10002 + targetPort: 10002 + - name: prometheus-20113 + protocol: TCP + port: 12002 + targetPort: 12002 + type: NodePort diff --git a/deployments/deploy/openim-config.yml b/deployments/deploy/openim-config.yml new file mode 100644 index 000000000..30d683c12 --- /dev/null +++ b/deployments/deploy/openim-config.yml @@ -0,0 +1,1124 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: openim-config +data: + discovery.yml: | + enable: "kubernetes" + 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 + # Maximum number of connections in the connection pool + maxPoolSize: 100 + # Maximum number of retry attempts for a failed database connection + maxRetry: 10 + local-cache.yml: | + user: + topic: DELETE_CACHE_USER + slotNum: 100 + slotSize: 2000 + successExpire: 300 + failedExpire: 5 + group: + topic: DELETE_CACHE_GROUP + slotNum: 100 + slotSize: 2000 + successExpire: 300 + failedExpire: 5 + friend: + topic: DELETE_CACHE_FRIEND + slotNum: 100 + slotSize: 2000 + successExpire: 300 + failedExpire: 5 + conversation: + topic: DELETE_CACHE_CONVERSATION + slotNum: 100 + slotSize: 2000 + successExpire: 300 + failedExpire: 5 + + openim-api.yml: | + secret: openIM123 + 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, must be consistent with the number of prometheus.ports + ports: [ 10002 ] + prometheus: + # Whether to enable prometheus + enable: true + # Prometheus listening ports, must match the number of api.ports + ports: [ 12002 ] + # This address can be accessed via a browser + grafanaURL: http://127.0.0.1:13000/ + openim-rpc-user.yml: | + rpc: + # API or other RPCs can access this RPC through this IP; if left blank, the internal network IP is obtained by default + registerIP: '' + # Listening IP; 0.0.0.0 means both internal and external IPs are listened to, if blank, the internal network IP is automatically obtained by default + listenIP: 0.0.0.0 + # Listening ports; if multiple are configured, multiple instances will be launched, and must be consistent with the number of prometheus.ports + ports: [ 10320 ] + prometheus: + # Whether to enable prometheus + enable: true + # Prometheus listening ports, must be consistent with the number of rpc.ports + ports: [ 12320 ] + + openim-crontask.yml: | + cronExecuteTime: 0 2 * * * + retainChatRecords: 365 + fileExpireTime: 90 + + openim-msggateway.yml: | + rpc: + # The IP address where this RPC service registers itself; if left blank, it defaults to the internal network IP + registerIP: + # List of ports that the RPC service listens on; configuring multiple ports will launch multiple instances. These must match the number of configured prometheus ports + ports: [ 10140, 10141, 10142, 10143, 10144, 10145, 10146, 10147, 10148, 10149, 10150, 10151, 10152, 10153, 10154, 10155 ] + + prometheus: + # Enable or disable Prometheus monitoring + enable: true + # List of ports that Prometheus listens on; these must match the number of rpc.ports to ensure correct monitoring setup + ports: [ 12140, 12141, 12142, 12143, 12144, 12145, 12146, 12147, 12148, 12149, 12150, 12151, 12152, 12153, 12154, 12155 ] + + # IP address that the RPC/WebSocket 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 + + longConnSvr: + # WebSocket listening ports, must match the number of rpc.ports + ports: [ 10001 ] + # Maximum number of WebSocket connections + websocketMaxConnNum: 100000 + # Maximum length of the entire WebSocket message packet + websocketMaxMsgLen: 4096 + # WebSocket connection handshake timeout in seconds + websocketTimeout: 10 + + openim-msgtransfer.yml: | + prometheus: + # Enable or disable Prometheus monitoring + enable: true + # List of ports that Prometheus listens on; each port corresponds to an instance of monitoring. Ensure these are managed accordingly + # Because four instances have been launched, four ports need to be specified + ports: [ 12020, 12021, 12022, 12023, 12024, 12025, 12026, 12027, 12028, 12029, 12030, 12031, 12032, 12033, 12034, 12035 ] + + openim-push.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. These must match the number of configured prometheus ports + ports: [ 10170, 10171, 10172, 10173, 10174, 10175, 10176, 10177, 10178, 10179, 10180, 10181, 10182, 10183, 10184, 10185 ] + + prometheus: + # Enable or disable Prometheus monitoring + enable: true + # List of ports that Prometheus listens on; these must match the number of rpc.ports to ensure correct monitoring setup + ports: [ 12170, 12171, 12172, 12173, 12174, 12175, 12176, 12177, 12178, 12179, 12180, 12182, 12183, 12184, 12185, 12186 ] + + maxConcurrentWorkers: 3 + #Use geTui for offline push notifications, or choose fcm or jpns; corresponding configuration settings must be specified. + enable: geTui + geTui: + pushUrl: https://restapi.getui.com/v2/$appId + masterSecret: + appKey: + intent: + channelID: + channelName: + fcm: + # Prioritize using file paths. If the file path is empty, use URL + filePath: # File path is concatenated with the parameters passed in through - c(`mage` default pass in `config/`) and filePath. + authURL: # Must start with https or http. + jpns: + appKey: + masterSecret: + pushURL: + pushIntent: + + # iOS system push sound and badge count + iosPush: + pushSound: xxx + badgeCount: true + production: false + + fullUserCache: true + + openim-rpc-auth.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. These must match the number of configured prometheus ports + ports: [10200] + prometheus: + # Enable or disable Prometheus monitoring + enable: true + # List of ports that Prometheus listens on; these must match the number of rpc.ports to ensure correct monitoring setup + ports: [12200] + tokenPolicy: + # Token validity period, in days + expire: 90 + + openim-rpc-conversation.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. These must match the number of configured prometheus ports + ports: [ 10220 ] + + prometheus: + # Enable or disable Prometheus monitoring + enable: true + # List of ports that Prometheus listens on; these must match the number of rpc.ports to ensure correct monitoring setup + ports: [ 12220 ] + + openim-rpc-friend.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. These must match the number of configured prometheus ports + ports: [ 10240 ] + + prometheus: + # Enable or disable Prometheus monitoring + enable: true + # List of ports that Prometheus listens on; these must match the number of rpc.ports to ensure correct monitoring setup + ports: [ 12240 ] + + openim-rpc-group.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. These must match the number of configured prometheus ports + ports: [ 10260 ] + + prometheus: + # Enable or disable Prometheus monitoring + enable: true + # List of ports that Prometheus listens on; these must match the number of rpc.ports to ensure correct monitoring setup + ports: [ 12260 ] + + enableHistoryForNewMembers: true + + openim-rpc-msg.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. These must match the number of configured prometheus ports + ports: [ 10280 ] + + prometheus: + # Enable or disable Prometheus monitoring + enable: true + # List of ports that Prometheus listens on; these must match the number of rpc.ports to ensure correct monitoring setup + ports: [ 12280 ] + + + # Does sending messages require friend verification + friendVerify: false + + openim-rpc-third.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. These must match the number of configured prometheus ports + ports: [ 10300 ] + + prometheus: + # Enable or disable Prometheus monitoring + enable: true + # List of ports that Prometheus listens on; these must match the number of rpc.ports to ensure correct monitoring setup + ports: [ 12300 ] + + + object: + # Use MinIO as object storage, or set to "cos", "oss", "kodo", "aws", while also configuring the corresponding settings + enable: minio + cos: + bucketURL: https://temp-1252357374.cos.ap-chengdu.myqcloud.com + secretID: + secretKey: + sessionToken: + publicRead: false + oss: + endpoint: https://oss-cn-chengdu.aliyuncs.com + bucket: demo-9999999 + bucketURL: https://demo-9999999.oss-cn-chengdu.aliyuncs.com + accessKeyID: + accessKeySecret: + sessionToken: + publicRead: false + kodo: + endpoint: http://s3.cn-south-1.qiniucs.com + bucket: kodo-bucket-test + bucketURL: http://kodo-bucket-test-oetobfb.qiniudns.com + accessKeyID: + accessKeySecret: + sessionToken: + publicRead: false + + share.yml: | + secret: openIM123 + rpcRegisterName: + user: user-rpc-service:10320 + friend: friend-rpc-service:10240 + msg: msg-rpc-service:10280 + push: openim-push-service + messageGateway: openim-msggateway-service + group: group-rpc-service:10260 + auth: auth-rpc-service:10200 + conversation: conversation-rpc-service:10220 + third: third-rpc-service:10300 + + imAdminUserID: ["imAdmin"] + + # 1: For Android, iOS, Windows, Mac, and web platforms, only one instance can be online at a time + multiLogin: + policy: 1 + maxNumOneEnd: 30 + customizeLoginNum: + ios: 1 + android: 1 + windows: 1 + osx: 1 + web: 1 + miniWeb: 1 + linux: 1 + aPad: 1 + iPad: 1 + admin: 1 + + kafka.yml: | + username: '' + password: '' + producerAck: all + compressType: none + address: [ "kafka-service:19094" ] + toRedisTopic: toRedis + toMongoTopic: toMongo + toPushTopic: toPush + toOfflinePushTopic: toOfflinePush + toRedisGroupID: redis + toMongoGroupID: mongo + toPushGroupID: push + toOfflinePushGroupID: offlinePush + tls: + enableTLS: false + caCrt: + clientCrt: + clientKey: + clientKeyPwd: + insecureSkipVerify: false + redis.yml: | + address: [ "redis-service:16379" ] + username: + password: openIM123 + clusterMode: false + db: 0 + maxRetry: 10 + poolSize: 100 + minio.yml: | + # Name of the bucket in MinIO + bucket: openim + # Access key ID for MinIO authentication + accessKeyID: root # ${MINIO_ACCESS_KEY} + # Secret access key for MinIO authentication + secretAccessKey: openIM123 # ${MINIO_SECRET_KEY} + # Session token for MinIO authentication (optional) + sessionToken: "" + # Internal address of the MinIO server + internalAddress: minio-service:10005 + # External address of the MinIO server, accessible from outside. Supports both HTTP and HTTPS using a domain name + externalAddress: http://minio-service:10005 + # Flag to enable or disable public read access to the bucket + publicRead: "false" + + notification.yml: | + groupCreated: + isSendMsg: true + # Reliability level of the message sending. + # Set to 1 to send only when online, 2 for guaranteed delivery. + reliabilityLevel: 1 + # This setting is effective only when 'isSendMsg' is true. + # It controls whether to count unread messages. + unreadCount: false + # Configuration for offline push notifications. + offlinePush: + # Enables or disables offline push notifications. + enable: false + # Title for the notification when a group is created. + title: create group title + # Description for the notification. + desc: create group desc + # Additional information for the notification. + ext: create group ext + + groupInfoSet: + isSendMsg: false + reliabilityLevel: 1 + unreadCount: false + offlinePush: + enable: false + title: groupInfoSet title + desc: groupInfoSet desc + ext: groupInfoSet ext + + + joinGroupApplication: + isSendMsg: false + reliabilityLevel: 1 + unreadCount: false + offlinePush: + enable: false + title: joinGroupApplication title + desc: joinGroupApplication desc + ext: joinGroupApplication ext + + memberQuit: + isSendMsg: true + reliabilityLevel: 1 + unreadCount: false + offlinePush: + enable: false + title: memberQuit title + desc: memberQuit desc + ext: memberQuit ext + + groupApplicationAccepted: + isSendMsg: false + reliabilityLevel: 1 + unreadCount: false + offlinePush: + enable: false + title: groupApplicationAccepted title + desc: groupApplicationAccepted desc + ext: groupApplicationAccepted ext + + groupApplicationRejected: + isSendMsg: false + reliabilityLevel: 1 + unreadCount: false + offlinePush: + enable: false + title: groupApplicationRejected title + desc: groupApplicationRejected desc + ext: groupApplicationRejected ext + + + groupOwnerTransferred: + isSendMsg: true + reliabilityLevel: 1 + unreadCount: false + offlinePush: + enable: false + title: groupOwnerTransferred title + desc: groupOwnerTransferred desc + ext: groupOwnerTransferred ext + + memberKicked: + isSendMsg: true + reliabilityLevel: 1 + unreadCount: false + offlinePush: + enable: false + title: memberKicked title + desc: memberKicked desc + ext: memberKicked ext + + memberInvited: + isSendMsg: true + reliabilityLevel: 1 + unreadCount: false + offlinePush: + enable: false + title: memberInvited title + desc: memberInvited desc + ext: memberInvited ext + + memberEnter: + isSendMsg: true + reliabilityLevel: 1 + unreadCount: false + offlinePush: + enable: false + title: memberEnter title + desc: memberEnter desc + ext: memberEnter ext + + groupDismissed: + isSendMsg: true + reliabilityLevel: 1 + unreadCount: false + offlinePush: + enable: false + title: groupDismissed title + desc: groupDismissed desc + ext: groupDismissed ext + + groupMuted: + isSendMsg: true + reliabilityLevel: 1 + unreadCount: false + offlinePush: + enable: false + title: groupMuted title + desc: groupMuted desc + ext: groupMuted ext + + groupCancelMuted: + isSendMsg: true + reliabilityLevel: 1 + unreadCount: false + offlinePush: + enable: false + title: groupCancelMuted title + desc: groupCancelMuted desc + ext: groupCancelMuted ext + defaultTips: + tips: group Cancel Muted + + + groupMemberMuted: + isSendMsg: true + reliabilityLevel: 1 + unreadCount: false + offlinePush: + enable: false + title: groupMemberMuted title + desc: groupMemberMuted desc + ext: groupMemberMuted ext + + groupMemberCancelMuted: + isSendMsg: true + reliabilityLevel: 1 + unreadCount: false + offlinePush: + enable: false + title: groupMemberCancelMuted title + desc: groupMemberCancelMuted desc + ext: groupMemberCancelMuted ext + + groupMemberInfoSet: + isSendMsg: false + reliabilityLevel: 1 + unreadCount: false + offlinePush: + enable: false + title: groupMemberInfoSet title + desc: groupMemberInfoSet desc + ext: groupMemberInfoSet ext + + groupInfoSetAnnouncement: + isSendMsg: true + reliabilityLevel: 1 + unreadCount: false + offlinePush: + enable: false + title: groupInfoSetAnnouncement title + desc: groupInfoSetAnnouncement desc + ext: groupInfoSetAnnouncement ext + + + groupInfoSetName: + isSendMsg: true + reliabilityLevel: 1 + unreadCount: false + offlinePush: + enable: false + title: groupInfoSetName title + desc: groupInfoSetName desc + ext: groupInfoSetName ext + + + #############################friend################################# + friendApplicationAdded: + isSendMsg: false + reliabilityLevel: 1 + unreadCount: false + offlinePush: + enable: false + title: Somebody applies to add you as a friend + desc: Somebody applies to add you as a friend + ext: Somebody applies to add you as a friend + + friendApplicationApproved: + isSendMsg: true + reliabilityLevel: 1 + unreadCount: false + offlinePush: + enable: true + title: Someone applies to add your friend application + desc: Someone applies to add your friend application + ext: Someone applies to add your friend application + + friendApplicationRejected: + isSendMsg: false + reliabilityLevel: 1 + unreadCount: false + offlinePush: + enable: true + title: Someone rejected your friend application + desc: Someone rejected your friend application + ext: Someone rejected your friend application + + friendAdded: + isSendMsg: false + reliabilityLevel: 1 + unreadCount: false + offlinePush: + enable: true + title: We have become friends + desc: We have become friends + ext: We have become friends + + friendDeleted: + isSendMsg: false + reliabilityLevel: 1 + unreadCount: false + offlinePush: + enable: true + title: deleted a friend + desc: deleted a friend + ext: deleted a friend + + friendRemarkSet: + isSendMsg: false + reliabilityLevel: 1 + unreadCount: false + offlinePush: + enable: true + title: Your friend's profile has been changed + desc: Your friend's profile has been changed + ext: Your friend's profile has been changed + + blackAdded: + isSendMsg: false + reliabilityLevel: 1 + unreadCount: false + offlinePush: + enable: true + title: blocked a user + desc: blocked a user + ext: blocked a user + + blackDeleted: + isSendMsg: false + reliabilityLevel: 1 + unreadCount: false + offlinePush: + enable: true + title: Remove a blocked user + desc: Remove a blocked user + ext: Remove a blocked user + + friendInfoUpdated: + isSendMsg: false + reliabilityLevel: 1 + unreadCount: false + offlinePush: + enable: true + title: friend info updated + desc: friend info updated + ext: friend info updated + + #####################user######################### + userInfoUpdated: + isSendMsg: false + reliabilityLevel: 1 + unreadCount: false + offlinePush: + enable: true + title: userInfo updated + desc: userInfo updated + ext: userInfo updated + + userStatusChanged: + isSendMsg: false + reliabilityLevel: 1 + unreadCount: false + offlinePush: + enable: false + title: user status changed + desc: user status changed + ext: user status changed + + #####################conversation######################### + conversationChanged: + isSendMsg: false + reliabilityLevel: 1 + unreadCount: false + offlinePush: + enable: true + title: conversation changed + desc: conversation changed + ext: conversation changed + + conversationSetPrivate: + isSendMsg: true + reliabilityLevel: 1 + unreadCount: false + offlinePush: + enable: true + title: burn after reading + desc: burn after reading + ext: burn after reading + + prometheus.yml: | + # my global config + global: + scrape_interval: 15s # Set the scrape interval to every 15 seconds. Default is every 1 minute. + evaluation_interval: 15s # Evaluate rules every 15 seconds. The default is every 1 minute. + # scrape_timeout is set to the global default (10s). + + # Alertmanager configuration + alerting: + alertmanagers: + - static_configs: + - targets: [internal_ip:19093] + + # Load rules once and periodically evaluate them according to the global evaluation_interval. + rule_files: + - instance-down-rules.yml + # - first_rules.yml + # - second_rules.yml + + # A scrape configuration containing exactly one endpoint to scrape: + # Here it's Prometheus itself. + scrape_configs: + # The job name is added as a label "job=job_name" to any timeseries scraped from this config. + # Monitored information captured by prometheus + + # prometheus fetches application services + - job_name: node_exporter + static_configs: + - targets: [internal_ip:20500] + - job_name: openimserver-openim-api + static_configs: + - targets: [internal_ip:12002] + labels: + namespace: default + - job_name: openimserver-openim-msggateway + static_configs: + - targets: [internal_ip:12140] + # - targets: [ internal_ip:12140, internal_ip:12141, internal_ip:12142, internal_ip:12143, internal_ip:12144, internal_ip:12145, internal_ip:12146, internal_ip:12147, internal_ip:12148, internal_ip:12149, internal_ip:12150, internal_ip:12151, internal_ip:12152, internal_ip:12153, internal_ip:12154, internal_ip:12155 ] + labels: + namespace: default + - job_name: openimserver-openim-msgtransfer + static_configs: + - targets: + [ + internal_ip:12020, + internal_ip:12021, + internal_ip:12022, + internal_ip:12023, + internal_ip:12024, + internal_ip:12025, + internal_ip:12026, + internal_ip:12027, + ] + # - targets: [ internal_ip:12020, internal_ip:12021, internal_ip:12022, internal_ip:12023, internal_ip:12024, internal_ip:12025, internal_ip:12026, internal_ip:12027, internal_ip:12028, internal_ip:12029, internal_ip:12030, internal_ip:12031, internal_ip:12032, internal_ip:12033, internal_ip:12034, internal_ip:12035 ] + labels: + namespace: default + - job_name: openimserver-openim-push + static_configs: + - targets: + [ + internal_ip:12170, + internal_ip:12171, + internal_ip:12172, + internal_ip:12173, + internal_ip:12174, + internal_ip:12175, + internal_ip:12176, + internal_ip:12177, + ] + # - targets: [ internal_ip:12170, internal_ip:12171, internal_ip:12172, internal_ip:12173, internal_ip:12174, internal_ip:12175, internal_ip:12176, internal_ip:12177, internal_ip:12178, internal_ip:12179, internal_ip:12180, internal_ip:12182, internal_ip:12183, internal_ip:12184, internal_ip:12185, internal_ip:12186 ] + labels: + namespace: default + - job_name: openimserver-openim-rpc-auth + static_configs: + - targets: [internal_ip:12200] + labels: + namespace: default + - job_name: openimserver-openim-rpc-conversation + static_configs: + - targets: [internal_ip:12220] + labels: + namespace: default + - job_name: openimserver-openim-rpc-friend + static_configs: + - targets: [internal_ip:12240] + labels: + namespace: default + - job_name: openimserver-openim-rpc-group + static_configs: + - targets: [internal_ip:12260] + labels: + namespace: default + - job_name: openimserver-openim-rpc-msg + static_configs: + - targets: [internal_ip:12280] + labels: + namespace: default + - job_name: openimserver-openim-rpc-third + static_configs: + - targets: [internal_ip:12300] + labels: + namespace: default + - job_name: openimserver-openim-rpc-user + static_configs: + - targets: [internal_ip:12320] + labels: + namespace: default + + mongo-init.sh: | + echo "before running mongosh..." + mongosh < 0) { + try { + print('Attempting to connect to MongoDB. Remaining retries: ' + maxRetries); + db = connect('mongodb://127.0.0.1:27017/admin'); + var authResult = db.auth(rootUsername, rootPassword); + if (authResult) { + print('Authentication successful for root user: ' + rootUsername); + connected = true; + } else { + print('Authentication failed for root user: ' + rootUsername + ' with password: ' + rootPassword); + quit(1); + } + } catch (e) { + maxRetries--; + print('Connection failed due to error: ' + e); + print('Retrying... Remaining attempts: ' + maxRetries); + sleep(1000); // Sleep for 1 second + } + } + + if (connected) { + print('Connected to MongoDB successfully. Proceeding to create user...'); + db = db.getSiblingDB(dbName); + var createUserResult = db.createUser({ + user: openimUsername, + pwd: openimPassword, + roles: [{ + role: 'readWrite', + db: dbName + }] + }); + + if (createUserResult.ok == 1) { + print('User creation successful. User: ' + openimUsername + ', Database: ' + dbName); + } else { + print('User creation failed for user: ' + openimUsername + ' in database: ' + dbName); + quit(1); + } + } else { + print('Failed to connect to MongoDB after 300 retries.'); + quit(1); + } + + print('Script execution completed.'); + EOF + echo "mongosh completed..." + + create-topic.sh: | + #!/usr/bin/env bash + # Wait for Kafka to be ready + + KAFKA_SERVER=kafka-service:9092 + + MAX_ATTEMPTS=300 + attempt_num=1 + + echo "Waiting for Kafka to be ready..." + + until /opt/bitnami/kafka/bin/kafka-topics.sh --list --bootstrap-server $KAFKA_SERVER; do + echo "Attempt $attempt_num of $MAX_ATTEMPTS: Kafka not ready yet..." + if [ $attempt_num -eq $MAX_ATTEMPTS ]; then + echo "Kafka not ready after $MAX_ATTEMPTS attempts, exiting" + exit 1 + fi + attempt_num=$((attempt_num+1)) + sleep 1 + done + + echo "Kafka is ready. Creating topics..." + + + topics=("toRedis" "toMongo" "toPush" "toOfflinePush") + partitions=8 + replicationFactor=1 + + for topic in "${topics[@]}"; do + if /opt/bitnami/kafka/bin/kafka-topics.sh --create \ + --bootstrap-server $KAFKA_SERVER \ + --replication-factor $replicationFactor \ + --partitions $partitions \ + --topic $topic + then + echo "Topic $topic created." + else + echo "Failed to create topic $topic." + fi + done + + echo "All topics created." + + webhooks.yml: | + url: http://127.0.0.1:10006/callbackExample + beforeSendSingleMsg: + enable: false + timeout: 5 + failedContinue: true + # Only the contentType in allowedTypes will send the callback. + # Supports two formats: a single type or a range. The range is defined by the lower and upper bounds connected with a hyphen ("-"). + # e.g. allowedTypes: [1, 100, 200-500, 600-700] means that only contentType within the range + # {1, 100} ∪ [200, 500] ∪ [600, 700] will be allowed through the filter. + # If not set, all contentType messages will through this filter. + allowedTypes: [] + # Only the contentType not in deniedTypes will send the callback. + # Supports two formats, same as allowedTypes. + # If not set, all contentType messages will through this filter. + deniedTypes: [] + beforeUpdateUserInfoEx: + enable: false + timeout: 5 + failedContinue: true + afterUpdateUserInfoEx: + enable: false + timeout: 5 + afterSendSingleMsg: + enable: false + timeout: 5 + # Only the senID/recvID specified in attentionIds will send the callback + # if not set, all user messages will be callback + attentionIds: [] + # See beforeSendSingleMsg comment. + allowedTypes: [] + deniedTypes: [] + beforeSendGroupMsg: + enable: false + timeout: 5 + failedContinue: true + # See beforeSendSingleMsg comment. + allowedTypes: [] + deniedTypes: [] + beforeMsgModify: + enable: false + timeout: 5 + failedContinue: true + # See beforeSendSingleMsg comment. + allowedTypes: [] + deniedTypes: [] + afterSendGroupMsg: + enable: false + timeout: 5 + # See beforeSendSingleMsg comment. + allowedTypes: [] + deniedTypes: [] + afterUserOnline: + enable: false + timeout: 5 + afterUserOffline: + enable: false + timeout: 5 + afterUserKickOff: + enable: false + timeout: 5 + beforeOfflinePush: + enable: false + timeout: 5 + failedContinue: true + beforeOnlinePush: + enable: false + timeout: 5 + failedContinue: true + beforeGroupOnlinePush: + enable: false + timeout: 5 + failedContinue: true + beforeAddFriend: + enable: false + timeout: 5 + failedContinue: true + beforeUpdateUserInfo: + enable: false + timeout: 5 + failedContinue: true + afterUpdateUserInfo: + enable: false + timeout: 5 + beforeCreateGroup: + enable: false + timeout: 5 + failedContinue: true + afterCreateGroup: + enable: false + timeout: 5 + beforeMemberJoinGroup: + enable: false + timeout: 5 + failedContinue: true + beforeSetGroupMemberInfo: + enable: false + timeout: 5 + failedContinue: true + afterSetGroupMemberInfo: + enable: false + timeout: 5 + afterQuitGroup: + enable: false + timeout: 5 + afterKickGroupMember: + enable: false + timeout: 5 + afterDismissGroup: + enable: false + timeout: 5 + beforeApplyJoinGroup: + enable: false + timeout: 5 + failedContinue: true + afterGroupMsgRead: + enable: false + timeout: 5 + afterSingleMsgRead: + enable: false + timeout: 5 + beforeUserRegister: + enable: false + timeout: 5 + failedContinue: true + afterUserRegister: + enable: false + timeout: 5 + afterTransferGroupOwner: + enable: false + timeout: 5 + beforeSetFriendRemark: + enable: false + timeout: 5 + failedContinue: true + afterSetFriendRemark: + enable: false + timeout: 5 + afterGroupMsgRevoke: + enable: false + timeout: 5 + afterJoinGroup: + enable: false + timeout: 5 + beforeInviteUserToGroup: + enable: false + timeout: 5 + failedContinue: true + afterSetGroupInfo: + enable: false + timeout: 5 + beforeSetGroupInfo: + enable: false + timeout: 5 + failedContinue: true + afterSetGroupInfoEx: + enable: false + timeout: 5 + beforeSetGroupInfoEx: + enable: false + timeout: 5 + failedContinue: true + afterRevokeMsg: + enable: false + timeout: 5 + beforeAddBlack: + enable: false + timeout: 5 + failedContinue: + afterAddFriend: + enable: false + timeout: 5 + beforeAddFriendAgree: + enable: false + timeout: 5 + failedContinue: true + afterAddFriendAgree: + enable: false + timeout: 5 + afterDeleteFriend: + enable: false + timeout: 5 + beforeImportFriends: + enable: false + timeout: 5 + failedContinue: true + afterImportFriends: + enable: false + timeout: 5 + afterRemoveBlack: + enable: false + timeout: 5 + +--- +apiVersion: v1 +kind: Secret +metadata: + name: mongo-secret +type: Opaque +data: + mongo_initdb_root_username: cm9vdA== # base64 for "root" + mongo_initdb_root_password: b3BlbklNMTIz # base64 for "openIM123" + mongo_initdb_database: b3BlbmltX3Yz # base64 for "openim_v3" + mongo_openim_username: b3BlbklN # base64 for "openIM" + mongo_openim_password: b3BlbklNMTIz # base64 for "openIM123" diff --git a/deployments/deploy/openim-crontask-deployment.yml b/deployments/deploy/openim-crontask-deployment.yml new file mode 100644 index 000000000..969837de4 --- /dev/null +++ b/deployments/deploy/openim-crontask-deployment.yml @@ -0,0 +1,30 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: openim-crontask +spec: + replicas: 1 + selector: + matchLabels: + app: crontask + template: + metadata: + labels: + app: crontask + spec: + containers: + - name: crontask-container + image: op-crontask:v3.9 + env: + - name: CONFIG_PATH + value: "/config" + - name: DEPLOYMENT_TYPE + value: "kubernetes" + volumeMounts: + - name: openim-config + mountPath: "/config" + readOnly: true + volumes: + - name: openim-config + configMap: + name: openim-config diff --git a/deployments/deploy/openim-msggateway-deployment.yml b/deployments/deploy/openim-msggateway-deployment.yml new file mode 100644 index 000000000..1c0a1d43c --- /dev/null +++ b/deployments/deploy/openim-msggateway-deployment.yml @@ -0,0 +1,33 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: openim-msggateway-server +spec: + replicas: 1 + selector: + matchLabels: + app: openim-msggateway-server + template: + metadata: + labels: + app: openim-msggateway-server + spec: + containers: + - name: openim-msggateway-container + image: op-msggateway:v3.9 + env: + - name: CONFIG_PATH + value: "/config" + - name: DEPLOYMENT_TYPE + value: "kubernetes" + volumeMounts: + - name: openim-config + mountPath: "/config" + readOnly: true + ports: + - containerPort: 10001 + - containerPort: 12001 + volumes: + - name: openim-config + configMap: + name: openim-config diff --git a/deployments/deploy/openim-msggateway-service.yml b/deployments/deploy/openim-msggateway-service.yml new file mode 100644 index 000000000..25af48c88 --- /dev/null +++ b/deployments/deploy/openim-msggateway-service.yml @@ -0,0 +1,17 @@ +apiVersion: v1 +kind: Service +metadata: + name: openim-msggateway-service +spec: + selector: + app: openim-msggateway-server + ports: + - name: http-10001 + protocol: TCP + port: 10001 + targetPort: 10001 + - name: prometheus-12001 + protocol: TCP + port: 12001 + targetPort: 12001 + type: NodePort diff --git a/deployments/deploy/openim-msgtransfer-deployment.yml b/deployments/deploy/openim-msgtransfer-deployment.yml new file mode 100644 index 000000000..ccc0f6471 --- /dev/null +++ b/deployments/deploy/openim-msgtransfer-deployment.yml @@ -0,0 +1,33 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: openim-msgtransfer-server +spec: + replicas: 1 + selector: + matchLabels: + app: openim-msgtransfer-server + template: + metadata: + labels: + app: openim-msgtransfer-server + spec: + containers: + - name: openim-msgtransfer-container + image: op-msgtransfer:v3.9 + env: + - name: CONFIG_PATH + value: "/config" + - name: DEPLOYMENT_TYPE + value: "kubernetes" + volumeMounts: + - name: openim-config + mountPath: "/config" + readOnly: true + ports: + # - containerPort: 15200 + - containerPort: 12020 + volumes: + - name: openim-config + configMap: + name: openim-config diff --git a/deployments/deploy/openim-msgtransfer-service.yml b/deployments/deploy/openim-msgtransfer-service.yml new file mode 100644 index 000000000..a2eafd39f --- /dev/null +++ b/deployments/deploy/openim-msgtransfer-service.yml @@ -0,0 +1,14 @@ +apiVersion: v1 +kind: Service +metadata: + name: openim-msgtransfer-service +spec: + selector: + app: openim-msgtransfer-server + ports: + # TODO Need check port!!! + - name: prometheus-12020 + protocol: TCP + port: 12020 + targetPort: 12020 + type: ClusterIP diff --git a/deployments/deploy/openim-push-deployment.yml b/deployments/deploy/openim-push-deployment.yml new file mode 100644 index 000000000..06c44b60c --- /dev/null +++ b/deployments/deploy/openim-push-deployment.yml @@ -0,0 +1,40 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: openim-push-server +spec: + replicas: 1 + selector: + matchLabels: + app: openim-push-server + template: + metadata: + labels: + app: openim-push-server + spec: + containers: + - name: openim-push-container + image: op-push:v3.9 + env: + - name: CONFIG_PATH + value: "/config" + - name: DEPLOYMENT_TYPE + value: "kubernetes" + volumeMounts: + - name: openim-config + mountPath: "/config" + readOnly: true + - name: notification-config + mountPath: "/config/notification.yml" + subPath: notification.yml + readOnly: true + ports: + - containerPort: 10170 + - containerPort: 12170 + volumes: + - name: openim-config + configMap: + name: openim-config + - name: notification-config + configMap: + name: notification-config diff --git a/deployments/deploy/openim-push-service.yml b/deployments/deploy/openim-push-service.yml new file mode 100644 index 000000000..237f755f0 --- /dev/null +++ b/deployments/deploy/openim-push-service.yml @@ -0,0 +1,17 @@ +apiVersion: v1 +kind: Service +metadata: + name: openim-push-service +spec: + selector: + app: openim-push-server + ports: + - name: http-10170 + protocol: TCP + port: 10170 + targetPort: 10170 + - name: prometheus-12170 + protocol: TCP + port: 12170 + targetPort: 12170 + type: ClusterIP diff --git a/deployments/deploy/openim-rpc-auth-deployment.yml b/deployments/deploy/openim-rpc-auth-deployment.yml new file mode 100644 index 000000000..baccaf544 --- /dev/null +++ b/deployments/deploy/openim-rpc-auth-deployment.yml @@ -0,0 +1,34 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: auth-rpc-server +spec: + replicas: 1 + selector: + matchLabels: + app: auth-rpc-server + template: + metadata: + labels: + app: auth-rpc-server + spec: + containers: + - name: auth-rpc-server-container + image: op-auth:v3.9 + imagePullPolicy: Never + env: + - name: DEPLOYMENT_TYPE + value: "kubernetes" + - name: CONFIG_PATH + value: "/config" + volumeMounts: + - name: openim-config + mountPath: "/config" + readOnly: true + ports: + - containerPort: 10200 + - containerPort: 12200 + volumes: + - name: openim-config + configMap: + name: openim-config diff --git a/deployments/deploy/openim-rpc-auth-service.yml b/deployments/deploy/openim-rpc-auth-service.yml new file mode 100644 index 000000000..7d798383f --- /dev/null +++ b/deployments/deploy/openim-rpc-auth-service.yml @@ -0,0 +1,17 @@ +apiVersion: v1 +kind: Service +metadata: + name: auth-rpc-service +spec: + selector: + app: auth-rpc-server + ports: + - name: http-10200 + protocol: TCP + port: 10200 + targetPort: 10200 + - name: prometheus-12200 + protocol: TCP + port: 12200 + targetPort: 12200 + type: ClusterIP diff --git a/deployments/deploy/openim-rpc-conversation-deployment.yml b/deployments/deploy/openim-rpc-conversation-deployment.yml new file mode 100644 index 000000000..44713ff44 --- /dev/null +++ b/deployments/deploy/openim-rpc-conversation-deployment.yml @@ -0,0 +1,41 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: conversation-rpc-server +spec: + replicas: 1 + selector: + matchLabels: + app: conversation-rpc-server + template: + metadata: + labels: + app: conversation-rpc-server + spec: + containers: + - name: conversation-rpc-server-container + image: op-conversation:v3.9 + imagePullPolicy: Never + env: + - name: DEPLOYMENT_TYPE + value: "kubernetes" + - name: CONFIG_PATH + value: "/config" + volumeMounts: + - name: openim-config + mountPath: "/config" + readOnly: true + - name: notification-config + mountPath: "/config/notification.yml" + subPath: notification.yml + readOnly: true + ports: + - containerPort: 10220 + - containerPort: 12220 + volumes: + - name: openim-config + configMap: + name: openim-config + - name: notification-config + configMap: + name: notification-config diff --git a/deployments/deploy/openim-rpc-conversation-service.yml b/deployments/deploy/openim-rpc-conversation-service.yml new file mode 100644 index 000000000..f9be231ad --- /dev/null +++ b/deployments/deploy/openim-rpc-conversation-service.yml @@ -0,0 +1,17 @@ +apiVersion: v1 +kind: Service +metadata: + name: conversation-rpc-service +spec: + selector: + app: conversation-rpc-server + ports: + - name: http-10220 + protocol: TCP + port: 10220 + targetPort: 10220 + - name: prometheus-12220 + protocol: TCP + port: 12220 + targetPort: 12220 + type: ClusterIP diff --git a/deployments/deploy/openim-rpc-friend-deployment.yml b/deployments/deploy/openim-rpc-friend-deployment.yml new file mode 100644 index 000000000..cf38d86c1 --- /dev/null +++ b/deployments/deploy/openim-rpc-friend-deployment.yml @@ -0,0 +1,46 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: friend-rpc-server +spec: + replicas: 1 + selector: + matchLabels: + app: friend-rpc-server + template: + metadata: + labels: + app: friend-rpc-server + spec: + containers: + - name: friend-rpc-server-container + image: op-friend:v3.9 + # imagePullPolicy: Never + env: + - name: DEPLOYMENT_TYPE + value: "kubernetes" + - name: CONFIG_PATH + value: "/config" + - name: REDIS_PASSWORD + valueFrom: + secretKeyRef: + name: redis-secret + key: redis-password + volumeMounts: + - name: openim-config + mountPath: "/config" + readOnly: true + - name: notification-config + mountPath: "/config/notification.yml" + subPath: notification.yml + readOnly: true + ports: + - containerPort: 10240 + - containerPort: 12240 + volumes: + - name: openim-config + configMap: + name: openim-config + - name: notification-config + configMap: + name: notification-config diff --git a/deployments/deploy/openim-rpc-friend-service.yml b/deployments/deploy/openim-rpc-friend-service.yml new file mode 100644 index 000000000..b6b512baa --- /dev/null +++ b/deployments/deploy/openim-rpc-friend-service.yml @@ -0,0 +1,17 @@ +apiVersion: v1 +kind: Service +metadata: + name: friend-rpc-service +spec: + selector: + app: friend-rpc-server + ports: + - name: http-10240 + protocol: TCP + port: 10240 + targetPort: 10240 + - name: prometheus-12240 + protocol: TCP + port: 12240 + targetPort: 12240 + type: ClusterIP diff --git a/deployments/deploy/openim-rpc-group-deployment.yml b/deployments/deploy/openim-rpc-group-deployment.yml new file mode 100644 index 000000000..bf433413a --- /dev/null +++ b/deployments/deploy/openim-rpc-group-deployment.yml @@ -0,0 +1,41 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: group-rpc-server +spec: + replicas: 1 + selector: + matchLabels: + app: group-rpc-server + template: + metadata: + labels: + app: group-rpc-server + spec: + containers: + - name: group-rpc-server-container + image: op-group:v3.9 + # imagePullPolicy: Never + env: + - name: DEPLOYMENT_TYPE + value: "kubernetes" + - name: CONFIG_PATH + value: "/config" + volumeMounts: + - name: openim-config + mountPath: "/config" + readOnly: true + - name: notification-config + mountPath: "/config/notification.yml" + subPath: notification.yml + readOnly: true + ports: + - containerPort: 10260 + - containerPort: 12260 + volumes: + - name: openim-config + configMap: + name: openim-config + - name: notification-config + configMap: + name: notification-config diff --git a/deployments/deploy/openim-rpc-group-service.yml b/deployments/deploy/openim-rpc-group-service.yml new file mode 100644 index 000000000..bccc0803f --- /dev/null +++ b/deployments/deploy/openim-rpc-group-service.yml @@ -0,0 +1,17 @@ +apiVersion: v1 +kind: Service +metadata: + name: group-rpc-service +spec: + selector: + app: group-rpc-server + ports: + - name: http-10260 + protocol: TCP + port: 10260 + targetPort: 10260 + - name: prometheus-12260 + protocol: TCP + port: 12260 + targetPort: 12260 + type: ClusterIP diff --git a/deployments/deploy/openim-rpc-msg-deployment.yml b/deployments/deploy/openim-rpc-msg-deployment.yml new file mode 100644 index 000000000..dee3cb3d1 --- /dev/null +++ b/deployments/deploy/openim-rpc-msg-deployment.yml @@ -0,0 +1,41 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: msg-rpc-server +spec: + replicas: 1 + selector: + matchLabels: + app: msg-rpc-server + template: + metadata: + labels: + app: msg-rpc-server + spec: + containers: + - name: msg-rpc-server-container + image: op-msg:v3.9 + # imagePullPolicy: Never + env: + - name: DEPLOYMENT_TYPE + value: "kubernetes" + - name: CONFIG_PATH + value: "/config" + volumeMounts: + - name: openim-config + mountPath: "/config" + readOnly: true + - name: notification-config + mountPath: "/config/notification.yml" + subPath: notification.yml + readOnly: true + ports: + - containerPort: 10280 + - containerPort: 12280 + volumes: + - name: openim-config + configMap: + name: openim-config + - name: notification-config + configMap: + name: notification-config diff --git a/deployments/deploy/openim-rpc-msg-service.yml b/deployments/deploy/openim-rpc-msg-service.yml new file mode 100644 index 000000000..db7610e8b --- /dev/null +++ b/deployments/deploy/openim-rpc-msg-service.yml @@ -0,0 +1,17 @@ +apiVersion: v1 +kind: Service +metadata: + name: msg-rpc-service +spec: + selector: + app: msg-rpc-server + ports: + - name: http-10280 + protocol: TCP + port: 10280 + targetPort: 10280 + - name: prometheus-12280 + protocol: TCP + port: 12280 + targetPort: 12280 + type: ClusterIP diff --git a/deployments/deploy/openim-rpc-third-deployment.yml b/deployments/deploy/openim-rpc-third-deployment.yml new file mode 100644 index 000000000..052b47c6b --- /dev/null +++ b/deployments/deploy/openim-rpc-third-deployment.yml @@ -0,0 +1,51 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: third-rpc-server +spec: + replicas: 1 + selector: + matchLabels: + app: third-rpc-server + template: + metadata: + labels: + app: third-rpc-server + spec: + containers: + - name: third-rpc-server-container + image: op-third:v3.9 + # imagePullPolicy: Never + env: + - name: DEPLOYMENT_TYPE + value: "kubernetes" + - name: CONFIG_PATH + value: "/config" + - name: MINIO_ACCESS_KEY + valueFrom: + secretKeyRef: + name: minio-secret + key: minio-root-user + - name: MINIO_SECRET_KEY + valueFrom: + secretKeyRef: + name: minio-secret + key: minio-root-password + volumeMounts: + - name: openim-config + mountPath: "/config" + readOnly: true + - name: notification-config + mountPath: "/config/notification.yml" + subPath: notification.yml + readOnly: true + ports: + - containerPort: 10300 + - containerPort: 12300 + volumes: + - name: openim-config + configMap: + name: openim-config + - name: notification-config + configMap: + name: notification-config diff --git a/deployments/deploy/openim-rpc-third-service.yml b/deployments/deploy/openim-rpc-third-service.yml new file mode 100644 index 000000000..8cd34c285 --- /dev/null +++ b/deployments/deploy/openim-rpc-third-service.yml @@ -0,0 +1,17 @@ +apiVersion: v1 +kind: Service +metadata: + name: third-rpc-service +spec: + selector: + app: third-rpc-server + ports: + - name: http-10300 + protocol: TCP + port: 10300 + targetPort: 10300 + - name: prometheus-12300 + protocol: TCP + port: 12300 + targetPort: 12300 + type: ClusterIP diff --git a/deployments/deploy/openim-rpc-user-deployment.yml b/deployments/deploy/openim-rpc-user-deployment.yml new file mode 100644 index 000000000..cea41ee85 --- /dev/null +++ b/deployments/deploy/openim-rpc-user-deployment.yml @@ -0,0 +1,41 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: user-rpc-server +spec: + replicas: 1 + selector: + matchLabels: + app: user-rpc-server + template: + metadata: + labels: + app: user-rpc-server + spec: + containers: + - name: user-rpc-server-container + image: op-user:v3.9 + # imagePullPolicy: Never + env: + - name: DEPLOYMENT_TYPE + value: "kubernetes" + - name: CONFIG_PATH + value: "/config" + volumeMounts: + - name: openim-config + mountPath: "/config" + readOnly: true + - name: notification-config + mountPath: "/config/notification.yml" + subPath: notification.yml + readOnly: true + ports: + - containerPort: 10320 + - containerPort: 12320 + volumes: + - name: openim-config + configMap: + name: openim-config + - name: notification-config + configMap: + name: notification-config diff --git a/deployments/deploy/openim-rpc-user-service.yml b/deployments/deploy/openim-rpc-user-service.yml new file mode 100644 index 000000000..50cef3c88 --- /dev/null +++ b/deployments/deploy/openim-rpc-user-service.yml @@ -0,0 +1,17 @@ +apiVersion: v1 +kind: Service +metadata: + name: user-rpc-service +spec: + selector: + app: user-rpc-server + ports: + - name: http-10320 + protocol: TCP + port: 10320 + targetPort: 10320 + - name: prometheus-12320 + protocol: TCP + port: 12320 + targetPort: 12320 + type: ClusterIP diff --git a/deployments/deploy/prometheus-config.yml b/deployments/deploy/prometheus-config.yml new file mode 100644 index 000000000..0fc51b1fd --- /dev/null +++ b/deployments/deploy/prometheus-config.yml @@ -0,0 +1,112 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: prometheus-config +data: + prometheus.yml: | + # my global config + global: + scrape_interval: 15s # Set the scrape interval to every 15 seconds. Default is every 1 minute. + evaluation_interval: 15s # Evaluate rules every 15 seconds. The default is every 1 minute. + # scrape_timeout is set to the global default (10s). + + # Alertmanager configuration + alerting: + alertmanagers: + - static_configs: + - targets: [internal_ip:19093] + + # Load rules once and periodically evaluate them according to the global evaluation_interval. + rule_files: + - instance-down-rules.yml + # - first_rules.yml + # - second_rules.yml + + # A scrape configuration containing exactly one endpoint to scrape: + # Here it's Prometheus itself. + scrape_configs: + # The job name is added as a label "job=job_name" to any timeseries scraped from this config. + # Monitored information captured by prometheus + + # prometheus fetches application services + - job_name: node_exporter + static_configs: + - targets: [internal_ip:20500] + - job_name: openimserver-openim-api + static_configs: + - targets: [internal_ip:12002] + labels: + namespace: default + - job_name: openimserver-openim-msggateway + static_configs: + - targets: [internal_ip:12140] + # - targets: [ internal_ip:12140, internal_ip:12141, internal_ip:12142, internal_ip:12143, internal_ip:12144, internal_ip:12145, internal_ip:12146, internal_ip:12147, internal_ip:12148, internal_ip:12149, internal_ip:12150, internal_ip:12151, internal_ip:12152, internal_ip:12153, internal_ip:12154, internal_ip:12155 ] + labels: + namespace: default + - job_name: openimserver-openim-msgtransfer + static_configs: + - targets: + [ + internal_ip:12020, + internal_ip:12021, + internal_ip:12022, + internal_ip:12023, + internal_ip:12024, + internal_ip:12025, + internal_ip:12026, + internal_ip:12027, + ] + # - targets: [ internal_ip:12020, internal_ip:12021, internal_ip:12022, internal_ip:12023, internal_ip:12024, internal_ip:12025, internal_ip:12026, internal_ip:12027, internal_ip:12028, internal_ip:12029, internal_ip:12030, internal_ip:12031, internal_ip:12032, internal_ip:12033, internal_ip:12034, internal_ip:12035 ] + labels: + namespace: default + - job_name: openimserver-openim-push + static_configs: + - targets: + [ + internal_ip:12170, + internal_ip:12171, + internal_ip:12172, + internal_ip:12173, + internal_ip:12174, + internal_ip:12175, + internal_ip:12176, + internal_ip:12177, + ] + # - targets: [ internal_ip:12170, internal_ip:12171, internal_ip:12172, internal_ip:12173, internal_ip:12174, internal_ip:12175, internal_ip:12176, internal_ip:12177, internal_ip:12178, internal_ip:12179, internal_ip:12180, internal_ip:12182, internal_ip:12183, internal_ip:12184, internal_ip:12185, internal_ip:12186 ] + labels: + namespace: default + - job_name: openimserver-openim-rpc-auth + static_configs: + - targets: [internal_ip:12200] + labels: + namespace: default + - job_name: openimserver-openim-rpc-conversation + static_configs: + - targets: [internal_ip:12220] + labels: + namespace: default + - job_name: openimserver-openim-rpc-friend + static_configs: + - targets: [internal_ip:12240] + labels: + namespace: default + - job_name: openimserver-openim-rpc-group + static_configs: + - targets: [internal_ip:12260] + labels: + namespace: default + - job_name: openimserver-openim-rpc-msg + static_configs: + - targets: [internal_ip:12280] + labels: + namespace: default + - job_name: openimserver-openim-rpc-third + static_configs: + - targets: [internal_ip:12300] + labels: + namespace: default + - job_name: openimserver-openim-rpc-user + static_configs: + - targets: [internal_ip:12320] + labels: + namespace: default diff --git a/deployments/deploy/redis-service.yml b/deployments/deploy/redis-service.yml new file mode 100644 index 000000000..d076fd119 --- /dev/null +++ b/deployments/deploy/redis-service.yml @@ -0,0 +1,15 @@ +apiVersion: v1 +kind: Service +metadata: + name: redis-service + labels: + app: redis +spec: + type: ClusterIP + selector: + app: redis + ports: + - name: redis-port + protocol: TCP + port: 16379 + targetPort: 6379 diff --git a/deployments/deploy/redis-statefulset.yml b/deployments/deploy/redis-statefulset.yml new file mode 100644 index 000000000..a2f9d8cfc --- /dev/null +++ b/deployments/deploy/redis-statefulset.yml @@ -0,0 +1,66 @@ +apiVersion: apps/v1 +kind: StatefulSet +metadata: + name: redis-statefulset +spec: + serviceName: "redis" + replicas: 1 + selector: + matchLabels: + app: redis + template: + metadata: + labels: + app: redis + spec: + containers: + - name: redis + image: redis:7.0.0 + ports: + - containerPort: 6379 + env: + - name: TZ + value: "Asia/Shanghai" + - name: REDIS_PASSWORD + valueFrom: + secretKeyRef: + name: redis-secret + key: redis-password + volumeMounts: + - name: redis-data + mountPath: /data + # - name: redis-config-volume + # mountPath: /usr/local/redis/config/redis.conf + # subPath: redis.conf + command: + [ + "/bin/sh", + "-c", + 'redis-server --requirepass "$REDIS_PASSWORD" --appendonly yes', + ] + volumes: + - name: redis-config-volume + configMap: + name: openim-config + - name: redis-data + persistentVolumeClaim: + claimName: redis-pvc +--- +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + name: redis-pvc +spec: + accessModes: + - ReadWriteOnce + resources: + requests: + storage: 5Gi +--- +apiVersion: v1 +kind: Secret +metadata: + name: redis-secret +type: Opaque +data: + redis-password: b3BlbklNMTIz # "openIM123" in base64