diff --git a/deploy_k8s/admin_cms/deployment.yaml b/deploy_k8s/admin_cms/deployment.yaml index c37061e64..437b1ffc5 100644 --- a/deploy_k8s/admin_cms/deployment.yaml +++ b/deploy_k8s/admin_cms/deployment.yaml @@ -2,22 +2,22 @@ apiVersion: apps/v1 kind: Deployment metadata: - name: api-deployment + name: admin-cms-deployment spec: selector: matchLabels: - app: admin_cms # 选择这个指定标签执行 + app: admin-cms # 选择这个指定标签执行 replicas: 2 # 运行pod数量 template: metadata: labels: - app: api # 标签 + app: admin-cms # 标签 spec: containers: - - name: api - image: openim/api:v2.0.10 + - name: admin-cms + image: openim/admin_cms:v2.0.10 ports: - - containerPort: 10002 + - containerPort: 10200 volumeMounts: - name: config mountPath: /Open-IM-Server/config diff --git a/deploy_k8s/api/deployment.yaml b/deploy_k8s/api/deployment.yaml index c8c8a177c..870423066 100644 --- a/deploy_k8s/api/deployment.yaml +++ b/deploy_k8s/api/deployment.yaml @@ -35,7 +35,7 @@ metadata: name: api spec: ports: - - name: api + - name: api-port protocol: TCP port: 10002 targetPort: 10002 diff --git a/deploy_k8s/auth/deployment.yaml b/deploy_k8s/auth/deployment.yaml new file mode 100644 index 000000000..89428d08c --- /dev/null +++ b/deploy_k8s/auth/deployment.yaml @@ -0,0 +1,30 @@ +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: auth-deployment +spec: + selector: + matchLabels: + app: auth # 选择这个指定标签执行 + replicas: 2 # 运行pod数量 + template: + metadata: + labels: + app: auth # 标签 + spec: + containers: + - name: auth + image: openim/auth:v2.0.10 + ports: + - containerPort: 10160 + volumeMounts: + - name: config + mountPath: /Open-IM-Server/config + readOnly: true + volumes: + - name: config + configMap: + name: config + strategy: #更新策略 + type: RollingUpdate # 滚动更新 \ No newline at end of file diff --git a/deploy_k8s/cache/deployment.yaml b/deploy_k8s/cache/deployment.yaml new file mode 100644 index 000000000..f957a8ef5 --- /dev/null +++ b/deploy_k8s/cache/deployment.yaml @@ -0,0 +1,30 @@ +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: cache-deployment +spec: + selector: + matchLabels: + app: cache # 选择这个指定标签执行 + replicas: 2 # 运行pod数量 + template: + metadata: + labels: + app: cache # 标签 + spec: + containers: + - name: cache + image: openim/cache:v2.0.10 + ports: + - containerPort: 10240 + volumeMounts: + - name: config + mountPath: /Open-IM-Server/config + readOnly: true + volumes: + - name: config + configMap: + name: config + strategy: #更新策略 + type: RollingUpdate # 滚动更新 \ No newline at end of file diff --git a/deploy_k8s/cms_api/deployment.yaml b/deploy_k8s/cms_api/deployment.yaml new file mode 100644 index 000000000..cdaa78fd9 --- /dev/null +++ b/deploy_k8s/cms_api/deployment.yaml @@ -0,0 +1,43 @@ +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: cms-api-deployment +spec: + selector: + matchLabels: + app: cms-api # 选择这个指定标签执行 + replicas: 2 # 运行pod数量 + template: + metadata: + labels: + app: cms-api # 标签 + spec: + containers: + - name: cms-api + image: openim/cms_api:v2.0.10 + ports: + - containerPort: 10006 + volumeMounts: + - name: config + mountPath: /Open-IM-Server/config + readOnly: true + volumes: + - name: config + configMap: + name: config + strategy: #更新策略 + type: RollingUpdate # 滚动更新 +--- +apiVersion: v1 +kind: Service +metadata: + name: cms-api +spec: + ports: + - name: cms-api-port + protocol: TCP + port: 10006 + targetPort: 10006 + selector: + app: cms_api \ No newline at end of file diff --git a/deploy_k8s/conversation/deployment.yaml b/deploy_k8s/conversation/deployment.yaml new file mode 100644 index 000000000..1e14e794a --- /dev/null +++ b/deploy_k8s/conversation/deployment.yaml @@ -0,0 +1,31 @@ +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: conversation-deployment +spec: + selector: + matchLabels: + app: conversation # 选择这个指定标签执行 + replicas: 2 # 运行pod数量 + template: + metadata: + labels: + app: conversation # 标签 + spec: + containers: + - name: conversation + image: openim/conversation:v2.0.10 + ports: + - containerPort: 10230 + volumeMounts: + - name: config + mountPath: /Open-IM-Server/config + readOnly: true + volumes: + - name: config + configMap: + name: config + strategy: #更新策略 + type: RollingUpdate # 滚动更新 + diff --git a/deploy_k8s/demo/deployment.yaml b/deploy_k8s/demo/deployment.yaml new file mode 100644 index 000000000..edaaf1d03 --- /dev/null +++ b/deploy_k8s/demo/deployment.yaml @@ -0,0 +1,43 @@ +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: demo-deployment +spec: + selector: + matchLabels: + app: demo # 选择这个指定标签执行 + replicas: 2 # 运行pod数量 + template: + metadata: + labels: + app: demo # 标签 + spec: + containers: + - name: demo + image: openim/demo:v2.0.10 + ports: + - containerPort: 10004 + volumeMounts: + - name: config + mountPath: /Open-IM-Server/config + readOnly: true + volumes: + - name: config + configMap: + name: config + strategy: #更新策略 + type: RollingUpdate # 滚动更新 +--- +apiVersion: v1 +kind: Service +metadata: + name: demo +spec: + ports: + - name: demo + protocol: TCP + port: 10004 + targetPort: 10004 + selector: + app: demo \ No newline at end of file diff --git a/deploy_k8s/friend/deployment.yaml b/deploy_k8s/friend/deployment.yaml new file mode 100644 index 000000000..79070b768 --- /dev/null +++ b/deploy_k8s/friend/deployment.yaml @@ -0,0 +1,31 @@ +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: friend-deployment +spec: + selector: + matchLabels: + app: friend # 选择这个指定标签执行 + replicas: 2 # 运行pod数量 + template: + metadata: + labels: + app: friend # 标签 + spec: + containers: + - name: friend + image: openim/friend:v2.0.10 + ports: + - containerPort: 10120 + volumeMounts: + - name: config + mountPath: /Open-IM-Server/config + readOnly: true + volumes: + - name: config + configMap: + name: config + strategy: #更新策略 + type: RollingUpdate # 滚动更新 + diff --git a/deploy_k8s/group/deployment.yaml b/deploy_k8s/group/deployment.yaml new file mode 100644 index 000000000..47acea4a8 --- /dev/null +++ b/deploy_k8s/group/deployment.yaml @@ -0,0 +1,30 @@ +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: group-deployment +spec: + selector: + matchLabels: + app: group # 选择这个指定标签执行 + replicas: 2 # 运行pod数量 + template: + metadata: + labels: + app: group # 标签 + spec: + containers: + - name: group + image: openim/group:v2.0.10 + ports: + - containerPort: 10150 + volumeMounts: + - name: config + mountPath: /Open-IM-Server/config + readOnly: true + volumes: + - name: config + configMap: + name: config + strategy: #更新策略 + type: RollingUpdate # 滚动更新 \ No newline at end of file diff --git a/deploy_k8s/ingress.yaml b/deploy_k8s/ingress.yaml index 271cc8e10..47c6268f4 100644 --- a/deploy_k8s/ingress.yaml +++ b/deploy_k8s/ingress.yaml @@ -2,7 +2,6 @@ apiVersion: networking.k8s.io/v1 kind: Ingress metadata: - # 配置注解 支持websocket annotations: nginx.ingress.kubernetes.io/proxy-http-version: "1.1" nginx.ingress.kubernetes.io/proxy-read-timeout: "3600" @@ -17,7 +16,7 @@ spec: service: name: sdk-server port: - number: 30000 + number: 10003 path: / pathType: Prefix --- @@ -38,7 +37,7 @@ spec: service: name: msg-gateway port: - number: 17778 + number: 10001 path: / pathType: Prefix --- @@ -55,7 +54,7 @@ spec: service: name: api port: - number: 10000 + number: 10002 path: / pathType: Prefix --- @@ -75,3 +74,37 @@ spec: number: 42233 path: / pathType: Prefix +--- +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + name: demo.openim.xxx.com +spec: + rules: + - host: demo.openim.xxx.com + http: + paths: + - backend: + service: + name: demo + port: + number: 10004 + path: / + pathType: Prefix +--- +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + name: cms-api.openim.xxx.com +spec: + rules: + - host: cms-api.openim.xxx.com + http: + paths: + - backend: + service: + name: cms-api + port: + number: 10006 + path: / + pathType: Prefix diff --git a/deploy_k8s/k8s_deploy.md b/deploy_k8s/k8s_deploy.md deleted file mode 100644 index d91019f80..000000000 --- a/deploy_k8s/k8s_deploy.md +++ /dev/null @@ -1,10 +0,0 @@ -#### im k8s部署文档 -### 1.修改配置文件 -在Open-IM-SERVER目录下修改config/config.yaml配置文件 - -### 2. 项目根目录创建im configMap到k8s -kubectl -n {namespace} create configmap config --from-file=config/config.yaml -namespace 为im项目的namespace - -### 3. - diff --git a/deploy_k8s/k8s_openim_deploy.md b/deploy_k8s/k8s_openim_deploy.md new file mode 100644 index 000000000..b96497f93 --- /dev/null +++ b/deploy_k8s/k8s_openim_deploy.md @@ -0,0 +1,27 @@ +#### openIM k8s部署文档 +### 1. 修改配置文件 +在Open-IM-SERVER目录下修改config/config.yaml配置文件, 将MySQL, Kafka, MongoDB等配置修改。 + +### 2. 项目根目录创建im configMap到k8s openim namespace +kubectl create namespace openim +kubectl -n openim create configmap config --from-file=config/config.yaml +openim 为im项目的namespace, 可选 + +### 3(可选). 修改每个deployment.yml +kubectl get nodes +kubectl label node k8s-node1 role=kube-Node +应需要调度的node打上标签 +nodeSelector: + node: kube-Node +创建资源清单时添加上nodeSelector属性对应即可 +修改每种服务数量,建议至少每种2个rpc。 + +### 4. 修改ingress.yaml配置文件 + +### 5. 执行./kubectl_start.sh脚本 +kubectl 启动所有deployment,services,ingress + +### 6. 查看k8s deployment service ingress状态 +kubectl -n openim get services +kubectl -n openim get deployment +kubectl -n openim get ingress diff --git a/deploy_k8s/kubctl_start.sh b/deploy_k8s/kubectl_start_all.sh similarity index 74% rename from deploy_k8s/kubctl_start.sh rename to deploy_k8s/kubectl_start_all.sh index f1db196f3..afc56aeaa 100644 --- a/deploy_k8s/kubctl_start.sh +++ b/deploy_k8s/kubectl_start_all.sh @@ -22,3 +22,8 @@ service=( demo ) +for i in ${service[*]} +do + kubectl -n openim apply -f ./${i}/deployment.yaml +done + diff --git a/deploy_k8s/kubectl_stop_all.sh b/deploy_k8s/kubectl_stop_all.sh new file mode 100644 index 000000000..d672a53c2 --- /dev/null +++ b/deploy_k8s/kubectl_stop_all.sh @@ -0,0 +1,36 @@ +service=( + #api service file + api + cms-api + #rpc service file + user + friend + group + auth + admin-cms + message-cms + statistics + office + organization + conversation + cache + msg-gateway + transfer + msg + push + sdk-server + demo +) + +for i in ${service[*]} +do + kubectl -n openim delete deployment "${i}-deployment" +done + +kubectl -n openim delete service api +kubectl -n openim delete service cms-api +kubectl -n openim delete service sdk-server +kubectl -n openim delete service msg-gateway +kubectl -n openim delete service demo + +echo done \ No newline at end of file diff --git a/deploy_k8s/message_cms/deployment.yaml b/deploy_k8s/message_cms/deployment.yaml new file mode 100644 index 000000000..3792e4da4 --- /dev/null +++ b/deploy_k8s/message_cms/deployment.yaml @@ -0,0 +1,30 @@ +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: message-cms-deployment +spec: + selector: + matchLabels: + app: message-cms # 选择这个指定标签执行 + replicas: 2 # 运行pod数量 + template: + metadata: + labels: + app: message-cms # 标签 + spec: + containers: + - name: message-cms + image: openim/message_cms:v2.0.10 + ports: + - containerPort: 10190 + volumeMounts: + - name: config + mountPath: /Open-IM-Server/config + readOnly: true + volumes: + - name: config + configMap: + name: config + strategy: #更新策略 + type: RollingUpdate # 滚动更新 \ No newline at end of file diff --git a/deploy_k8s/msg/deployment.yaml b/deploy_k8s/msg/deployment.yaml new file mode 100644 index 000000000..4ab52e999 --- /dev/null +++ b/deploy_k8s/msg/deployment.yaml @@ -0,0 +1,30 @@ +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: msg-deployment +spec: + selector: + matchLabels: + app: msg # 选择这个指定标签执行 + replicas: 2 # 运行pod数量 + template: + metadata: + labels: + app: msg # 标签 + spec: + containers: + - name: msg + image: openim/msg:v2.0.10 + ports: + - containerPort: 10130 + volumeMounts: + - name: config + mountPath: /Open-IM-Server/config + readOnly: true + volumes: + - name: config + configMap: + name: config + strategy: #更新策略 + type: RollingUpdate # 滚动更新 \ No newline at end of file diff --git a/deploy_k8s/msg_gateway/deployment.yaml b/deploy_k8s/msg_gateway/deployment.yaml new file mode 100644 index 000000000..85f51721b --- /dev/null +++ b/deploy_k8s/msg_gateway/deployment.yaml @@ -0,0 +1,46 @@ +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: msg-gateway-deployment +spec: + selector: + matchLabels: + app: msg-gateway # 选择这个指定标签执行 + replicas: 2 # 运行pod数量 + template: + metadata: + labels: + app: msg-gateway # 标签 + spec: + containers: + - name: msg-gateway + image: openim/msg_gateway:v2.0.10 + ports: + - containerPort: 10140 + - containerPort: 10001 + volumeMounts: + - name: config + mountPath: /Open-IM-Server/config + readOnly: true + volumes: + - name: config + configMap: + name: config + strategy: #更新策略 + type: RollingUpdate # 滚动更新 +--- +apiVersion: v1 +kind: Service +metadata: + name: msg-gateway +spec: + ports: + - name: msg-gateway-port + protocol: TCP + port: 10001 + targetPort: 10001 + selector: + app: demo + + \ No newline at end of file diff --git a/deploy_k8s/office/deployment.yaml b/deploy_k8s/office/deployment.yaml new file mode 100644 index 000000000..5fec3450a --- /dev/null +++ b/deploy_k8s/office/deployment.yaml @@ -0,0 +1,30 @@ +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: office-deployment +spec: + selector: + matchLabels: + app: office # 选择这个指定标签执行 + replicas: 2 # 运行pod数量 + template: + metadata: + labels: + app: office # 标签 + spec: + containers: + - name: office + image: openim/office:v2.0.10 + ports: + - containerPort: 10210 + volumeMounts: + - name: config + mountPath: /Open-IM-Server/config + readOnly: true + volumes: + - name: config + configMap: + name: config + strategy: #更新策略 + type: RollingUpdate # 滚动更新 \ No newline at end of file diff --git a/deploy_k8s/organization/deployment.yaml b/deploy_k8s/organization/deployment.yaml new file mode 100644 index 000000000..7d5318c64 --- /dev/null +++ b/deploy_k8s/organization/deployment.yaml @@ -0,0 +1,30 @@ +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: organization-deployment +spec: + selector: + matchLabels: + app: organization # 选择这个指定标签执行 + replicas: 2 # 运行pod数量 + template: + metadata: + labels: + app: organization # 标签 + spec: + containers: + - name: organization + image: openim/organization:v2.0.10 + ports: + - containerPort: 10220 + volumeMounts: + - name: config + mountPath: /Open-IM-Server/config + readOnly: true + volumes: + - name: config + configMap: + name: config + strategy: #更新策略 + type: RollingUpdate # 滚动更新 \ No newline at end of file diff --git a/deploy_k8s/push/deployment.yaml b/deploy_k8s/push/deployment.yaml new file mode 100644 index 000000000..61c9929fc --- /dev/null +++ b/deploy_k8s/push/deployment.yaml @@ -0,0 +1,30 @@ +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: push-deployment +spec: + selector: + matchLabels: + app: push # 选择这个指定标签执行 + replicas: 2 # 运行pod数量 + template: + metadata: + labels: + app: push # 标签 + spec: + containers: + - name: push + image: openim/push:v2.0.10 + ports: + - containerPort: 10170 + volumeMounts: + - name: config + mountPath: /Open-IM-Server/config + readOnly: true + volumes: + - name: config + configMap: + name: config + strategy: #更新策略 + type: RollingUpdate # 滚动更新 \ No newline at end of file diff --git a/deploy_k8s/sdk_server/deployment.yaml b/deploy_k8s/sdk_server/deployment.yaml new file mode 100644 index 000000000..7ea15856f --- /dev/null +++ b/deploy_k8s/sdk_server/deployment.yaml @@ -0,0 +1,45 @@ +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: sdk-server-deployment +spec: + selector: + matchLabels: + app: sdk-server # 选择这个指定标签执行 + replicas: 2 # 运行pod数量 + template: + metadata: + labels: + app: sdk-server # 标签 + spec: + containers: + - name: sdk-server + image: openim/sdk_server:v2.0.10 + ports: + - containerPort: 10003 + volumeMounts: + - name: config + mountPath: /Open-IM-Server/config + readOnly: true + volumes: + - name: config + configMap: + name: config + strategy: #更新策略 + type: RollingUpdate # 滚动更新 +--- +apiVersion: v1 +kind: Service +metadata: + name: sdk-server +spec: + ports: + - name: sdk-server-port + protocol: TCP + port: 10003 + targetPort: 10003 + selector: + app: demo + + \ No newline at end of file diff --git a/deploy_k8s/statistics/deployment.yaml b/deploy_k8s/statistics/deployment.yaml new file mode 100644 index 000000000..a517caf7d --- /dev/null +++ b/deploy_k8s/statistics/deployment.yaml @@ -0,0 +1,30 @@ +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: statistics-deployment +spec: + selector: + matchLabels: + app: statistics # 选择这个指定标签执行 + replicas: 2 # 运行pod数量 + template: + metadata: + labels: + app: statistics # 标签 + spec: + containers: + - name: statistics + image: openim/statistics:v2.0.10 + ports: + - containerPort: 10180 + volumeMounts: + - name: config + mountPath: /Open-IM-Server/config + readOnly: true + volumes: + - name: config + configMap: + name: config + strategy: #更新策略 + type: RollingUpdate # 滚动更新 diff --git a/deploy_k8s/transfer/deployment.yaml b/deploy_k8s/transfer/deployment.yaml new file mode 100644 index 000000000..c65d4d65f --- /dev/null +++ b/deploy_k8s/transfer/deployment.yaml @@ -0,0 +1,28 @@ +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: transfer-deployment +spec: + selector: + matchLabels: + app: transfer # 选择这个指定标签执行 + replicas: 2 # 运行pod数量 + template: + metadata: + labels: + app: transfer # 标签 + spec: + containers: + - name: transfer + image: openim/transfer:v2.0.10 + volumeMounts: + - name: config + mountPath: /Open-IM-Server/config + readOnly: true + volumes: + - name: config + configMap: + name: config + strategy: #更新策略 + type: RollingUpdate # 滚动更新 diff --git a/deploy_k8s/user/deployment.yaml b/deploy_k8s/user/deployment.yaml new file mode 100644 index 000000000..8ad91a526 --- /dev/null +++ b/deploy_k8s/user/deployment.yaml @@ -0,0 +1,28 @@ +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: user-deployment +spec: + selector: + matchLabels: + app: user # 选择这个指定标签执行 + replicas: 2 # 运行pod数量 + template: + metadata: + labels: + app: user # 标签 + spec: + containers: + - name: user + image: openim/user:v2.0.10 + volumeMounts: + - name: config + mountPath: /Open-IM-Server/config + readOnly: true + volumes: + - name: config + configMap: + name: config + strategy: #更新策略 + type: RollingUpdate # 滚动更新