部署DTM
Docker Compose 部署
参考官方文档
- 必须在本机安装mysql和docker desktop
- mysql - 导入以下三个SQL
https://github.com/dtm-labs/dtm/blob/main/sqls/dtmsvr.storage.mysql.sql
https://github.com/dtm-labs/dtm/blob/main/sqls/dtmcli.barrier.mysql.sql
https://github.com/dtm-labs/dtm/blob/main/sqls/busi.mysql.sql
- 在本机创建docker-compose.yaml
version: '3'
services:
dtm:
image: yedf/dtm
environment:
STORE_DRIVER: mysql
STORE_HOST: host.docker.internal #连接宿主机
STORE_USER: root
STORE_PASSWORD: 'root'
STORE_PORT: 3306
ports:
- '36789:36789'
- '36790:36790'
- 运行以下的命令就能启动了
docker-compose up
Kubernetes 部署
参考官方文档
- 必须准备好mysql和kubernetes集群
- mysql - 导入以下三个SQL
https://github.com/dtm-labs/dtm/blob/main/sqls/dtmsvr.storage.mysql.sql
https://github.com/dtm-labs/dtm/blob/main/sqls/dtmcli.barrier.mysql.sql
https://github.com/dtm-labs/dtm/blob/main/sqls/busi.mysql.sql
- 部署以下的yaml文件
apiVersion: apps/v1
kind: Deployment
metadata:
name: dtm
labels:
app: dtm
spec:
replicas: 2
selector:
matchLabels:
app: dtm
template:
metadata:
labels:
app: dtm
spec:
containers:
- name: dtm
image: yedf/dtm:latest
imagePullPolicy: IfNotPresent
args:
- "-c=/app/dtm/configs/config.yaml"
volumeMounts:
- mountPath: /app/dtm/configs
name: config
ports:
- containerPort: 36789
protocol: TCP
name: http
- containerPort: 36790
protocol: TCP
name: grpc
livenessProbe:
httpGet:
path: /api/ping
port: 36789
scheme: HTTP
readinessProbe:
httpGet:
path: /api/ping
port: 36789
scheme: HTTP
resources:
requests:
cpu: 200m
memory: 200Mi
volumes:
- name: config
configMap:
name: dtm-conf
---
apiVersion: v1
kind: ConfigMap
metadata:
name: dtm-conf
labels:
app: dtm
data:
config.yaml: |-
Store:
Driver: mysql # 此处以 mysql 为例,其他数据库可自行替换
Host: dtm-db # 此处设置为集群外部的数据库 host,或者集群内部的数据库 svc-dns
Port: 3306
User: root
Password: ''
---
apiVersion: v1
kind: Service
metadata:
name: dtm-svc
labels:
app: dtm
spec:
ports:
- port: 36790
targetPort: 36790
name: grpc
appProtocol: grpc # Kubernetes v1.20 [stable],低版本请剔除此行
- port: 36789
targetPort: 36789
name: http
appProtocol: http # Kubernetes v1.20 [stable],低版本请剔除此行
selector:
app: dtm
type: ClusterIP
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: dtm-ing
spec:
rules:
- host: "your-domain.com"
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: dtm-svc
port:
number: 36789 # 此处为 http server,grpc server 的设置,请访问 https://kubernetes.github.io/ingress-nginx/examples/grpc/
ingressClassName: nginx # 使用了其他的 ingressClassName, 请自行查询