BISHENG组件在K8S上部署的yaml配置参考
以下主要介绍毕昇核心组件的配置,其他组件(Milvus、ES等)的部署方式请参考其官方文档(如:Milvus milvus.io/docs/instal…
基于BISHENG 037版本撰写,后续版本如果docker-compose没有变化则可以继续使用,若我们docker-compose的定义有大的变化,下面的yaml就需要相应的变化(到时候有需求的可以评论提出来)。
变量说明:
以下yaml中以$开头的是一些环境变量,需要根据实际部署环境的配置进行修改。
- $NAMESPACE:部署服务的命名空间名称
- $BACKEND_IMAGE:bisheng-backend服务镜像名称
- $FRONTEND_IMAGE:bisheng-frontend服务镜像名称
- $OFFICE_IMAGE:bisheng-office服务镜像名称
- $GATEWAY_IMAGE:bisheng-gateway服务镜像名称
如何将一个配置文件制作为configmap应用到k8s中:
kubectl -n $NAMESPACE create cm ${CONFIGMAP_NAME} --from-file $CONFIGFILE_PATH -o yaml --dry-run=client > ${CONFIGMAP_NAME}.yml
kubectl apply -f ${CONFIGMAP_NAME}.yml
backend服务的部署yaml参考:
# 先将backend所需的配置文件作为configmap应用到k8s集群中
kubectl -n bisheng create cm backend-conf --from-file bisheng/docker/bisheng/config/config.yaml -o yaml --dry-run=client > backend-conf.yml
kubectl apply -f backend-conf.yml
# bisheng-backend Deployment定义
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app: backend
name: backend
namespace: $NAMESPACE
spec:
replicas: 3
selector:
matchLabels:
app: backend
template:
metadata:
labels:
app: backend
spec:
containers:
- image: $BACKEND_IMAGE
imagePullPolicy: IfNotPresent
name: backend
livenessProbe:
failureThreshold: 3
httpGet:
path: /health
port: 7860
scheme: HTTP
initialDelaySeconds: 30
periodSeconds: 90
successThreshold: 1
timeoutSeconds: 30
command: [ "sh", "entrypoint.sh" ]
env:
- name: TZ
value: Asia/Shanghai
- name: BS_MILVUS_CONNECTION_ARGS
value: '{"host":"milvus","port":"19530","user":"","password":"","secure":false}'
- name: BS_MILVUS_IS_PARTITION
value: "true"
- name: BS_MILVUS_PARTITION_SUFFIX
value: "1"
- name: BS_ELASTICSEARCH_URL
value: "http://elasticsearch:9200"
- name: BS_ELASTICSEARCH_SSL_VERIFY
value: '{}'
- name: BS_MINIO_SCHEMA
value: "false"
- name: BS_MINIO_CERT_CHECK
value: "false"
- name: BS_MINIO_ENDPOINT
value: "minio:9000"
- name: BS_MINIO_SHAREPOIN
value: "minio:9000"
- name: BS_MINIO_ACCESS_KEY
value: "minioadmin"
- name: BS_MINIO_SECRET_KEY
value: "minioadmin"
ports:
- containerPort: 7860
protocol: TCP
volumeMounts:
- mountPath: /app/bisheng/config.yaml
name: backend-conf
subPath: config.yaml
volumes:
- name: backend-conf
configMap:
name: backend-conf
---
# bisheng-backend Service定义
apiVersion: v1
kind: Service
metadata:
labels:
app: backend
name: backend
namespace: $NAMESPACE
spec:
ports:
- name: backend
port: 7860
protocol: TCP
targetPort: 7860
selector:
app: backend
frontend服务的部署yaml参考:
# 先将frontend所需的2个配置文件作为configmap应用到k8s集群中
kubectl -n bisheng create cm default-conf --from-file bisheng/docker/nginx/conf.d/default.conf -o yaml --dry-run=client > default-conf.yml
kubectl apply -f default-conf.yml
kubectl -n bisheng create cm websocket-conf --from-file bisheng/docker/nginx/conf.d/websocket.conf -o yaml --dry-run=client > websocket-conf.yml
kubectl apply -f websocket-conf.yml
# bisheng-frontend Deployment定义
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app: frontend
name: frontend
namespace: $NAMESPACE
spec:
replicas: 3
selector:
matchLabels:
app: frontend
template:
metadata:
labels:
app: frontend
spec:
containers:
- image: $FRONTEND_IMAGE
imagePullPolicy: IfNotPresent
name: frontend
env:
- name: TZ
value: Asia/Shanghai
ports:
- containerPort: 3001
protocol: TCP
volumeMounts:
- mountPath: /etc/nginx/conf.d/default.conf
name: default-conf
subPath: default.conf
- mountPath: /etc/nginx/conf.d/websocket.conf
name: websocket-conf
subPath: websocket.conf
volumes:
- name: default-conf
configMap:
name: default-conf
- name: websocket-conf
configMap:
name: websocket-conf
---
# bisheng-frontend Service定义
apiVersion: v1
kind: Service
metadata:
labels:
app: frontend
name: frontend
namespace: $NAMESPACE
spec:
ports:
- name: http
port: 3001
protocol: TCP
targetPort: 3001
nodePort: 30001
selector:
app: frontend
type: NodePort
office服务的部署yaml参考:
# bisheng-frontend Deployment定义
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app: office
name: office
namespace: $NAMESPACE
spec:
replicas: 3
selector:
matchLabels:
app: office
template:
metadata:
labels:
app: office
spec:
containers:
- image: $OFFICE_IMAGE
imagePullPolicy: IfNotPresent
name: office
args: [ "supervisorctl", "restart", "all" ]
env:
- name: TZ
value: Asia/Shanghai
- name: JWT_ENABLED
value: "false"
ports:
- containerPort: 80
protocol: TCP
volumeMounts:
- mountPath: /var/www/onlyoffice/documentserver/sdkjs-plugins/bisheng
name: office-files
readOnly: true
volumes:
- name: office-files
hostPath:
path: /root/bisheng/docker/office/bisheng
---
# bisheng-office Service定义
apiVersion: v1
kind: Service
metadata:
labels:
app: office
name: office
namespace: $NAMESPACE
spec:
ports:
- name: office
port: 8701
protocol: TCP
targetPort: 80
nodePort: 30701
selector:
app: office
type: NodePort
gateway服务的部署yaml参考:
gateway属于闭源模块,介绍见:毕昇商业拓展套件介绍
需要先将application.yml配置文件只作为configmap应用到k8s集群中。
以下yaml配置仅为gateway服务,不包含所依赖的mysql环境。
# bisheng-gateway Deployment定义
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app: gateway
name: gateway
namespace: $NAMESPACE
spec:
replicas: 3
selector:
matchLabels:
app: gateway
template:
metadata:
labels:
app: gateway
spec:
containers:
- image: $GATEWAY_IMAGE
imagePullPolicy: IfNotPresent
name: gateway
env:
- name: TZ
value: Asia/Shanghai
- name: LANG
value: "C.UTF-8"
- name: LC_ALL
value: "C.UTF-8"
ports:
- containerPort: 8080
protocol: TCP
volumeMounts:
- mountPath: /application.yml
name: gateway-conf
subPath: application.yml
volumes:
- name: gateway-conf
configMap:
name: gateway-conf
---
# bisheng-gateway Service定义
apiVersion: v1
kind: Service
metadata:
labels:
app: gateway
name: gateway
namespace: $NAMESPACE
spec:
ports:
- name: gateway
port: 8080
protocol: TCP
targetPort: 8080
selector:
app: gateway