k8s_deployment

pull/232/head
wangchuxiao 3 years ago
parent e8e4af7286
commit cb497fe720

@ -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

@ -35,7 +35,7 @@ metadata:
name: api
spec:
ports:
- name: api
- name: api-port
protocol: TCP
port: 10002
targetPort: 10002

@ -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 # 滚动更新

@ -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 # 滚动更新

@ -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

@ -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 # 滚动更新

@ -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

@ -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 # 滚动更新

@ -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 # 滚动更新

@ -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

@ -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.

@ -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 启动所有deploymentservicesingress
### 6. 查看k8s deployment service ingress状态
kubectl -n openim get services
kubectl -n openim get deployment
kubectl -n openim get ingress

@ -22,3 +22,8 @@ service=(
demo
)
for i in ${service[*]}
do
kubectl -n openim apply -f ./${i}/deployment.yaml
done

@ -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

@ -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 # 滚动更新

@ -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 # 滚动更新

@ -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

@ -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 # 滚动更新

@ -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 # 滚动更新

@ -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 # 滚动更新

@ -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

@ -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 # 滚动更新

@ -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 # 滚动更新

@ -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 # 滚动更新
Loading…
Cancel
Save