部署
可执行文件部署
dtm 目前已支持brew直接安装,暂未支持apt/yum等方式直接安装,您可以从github上面下载相应版本,或者通过go环境,编译出相关的二进制文件。
编译
您需要有go 1.16以上的环境,通过下面命令编译出二进制文件
go build
配置
您可以设置相关的环境变量(参见部署基础),也可以在工作目录下,参考配置样板文件创建conf.yml文件
启动
dtm会监听
- HTTP: 36789
- gRPC: 36790
./dtm -c ./conf.yml
Docker部署
Docker启动
docker run --name dtm -p 36789:36789 -p 36790:36790 -e STORE_DRIVER=mysql -e STORE_HOST=localhost -e STORE_USER=root -e STORE_PASSWORD= -e STORE_PORT=3306 yedf/dtm:latest
各个参数,详见部署基础
docker-compose启动
示例 docker-compose.yaml 文件:
version: '3'services:dtm:image: yedf/dtmenvironment:STORE_DRIVER: mysqlSTORE_HOST: localhostSTORE_USER: rootSTORE_PASSWORD: ''STORE_PORT: 3306ports:- '36789:36789'- '36790:36790'
容器其他命令
交互式使用dtm容器
docker exec -it dtm sh
查看日志
docker logs -f dtm
Kubernetes部署
当前dtm支持http协议,可以把前面docker部署的方式,增加K8S的deployment配置,完成K8S部署,下面给出一个deployment.yml的一个参考
apiVersion: apps/v1kind: Deploymentmetadata:name: dtmlabels:app: dtmspec:replicas: 2selector:matchLabels:app: dtmtemplate:metadata:labels:app: dtmspec:containers:- name: dtmimage: yedf/dtm:latestimagePullPolicy: IfNotPresentargs:- "-c=/app/dtm/configs/config.yaml"volumeMounts:- mountPath: /app/dtm/configsname: configports:- containerPort: 36789protocol: TCPname: http- containerPort: 36790protocol: TCPname: grpclivenessProbe:httpGet:path: /api/pingport: 36789scheme: HTTPreadinessProbe:httpGet:path: /api/pingport: 36789scheme: HTTPresources:requests:cpu: 200mmemory: 200Mivolumes:- name: configconfigMap:name: dtm-conf---apiVersion: v1kind: ConfigMapmetadata:name: dtm-conflabels:app: dtmdata:config.yaml: |-Store:Driver: mysql # 此处以 mysql 为例,其他数据库可自行替换Host: dtm-db # 此处设置为集群外部的数据库 host,或者集群内部的数据库 svc-dnsPort: 3306User: rootPassword: ''---apiVersion: v1kind: Servicemetadata:name: dtm-svclabels:app: dtmspec:ports:- port: 36790targetPort: 36790name: grpcappProtocol: grpc # Kubernetes v1.20 [stable],低版本请剔除此行- port: 36789targetPort: 36789name: httpappProtocol: http # Kubernetes v1.20 [stable],低版本请剔除此行selector:app: dtmtype: ClusterIP---apiVersion: networking.k8s.io/v1kind: Ingressmetadata:name: dtm-ingspec:rules:- host: "your-domain.com"http:paths:- path: /pathType: Prefixbackend:service:name: dtm-svcport:number: 36789 # 此处为 http server,grpc server 的设置,请访问 https://kubernetes.github.io/ingress-nginx/examples/grpc/ingressClassName: nginx # 使用了其他的 ingressClassName, 请自行查询
Helm部署
使用
安装 DTM chart:
helm install --create-namespace -n dtm-system dtm ./charts
升级 DTM chart:
helm upgrade -n dtm-system dtm ./charts
拆卸 DTM chart:
helm delete -n dtm-system dtm
参数
Configuration 参数
| Key | Description | Value |
|---|---|---|
configuration |
DTM 配置. 为 DTM 生成 config.yaml, 参考: sample config |
"" |
Autoscaling 参数
| Name | Description | Value |
|---|---|---|
autoscaling.enabled |
为 DTM 启用 pods 弹性伸缩 | false |
autoscaling.minReplicas |
DTM 副本的最小数量 | 1 |
autoscaling.maxReplicas |
DTM 副本的最大数量 | 10 |
autoscaling.targetCPUUtilizationPercentage |
目标cpu使用率 | 80 |
autoscaling.targetMemoryUtilizationPercentage |
目标内存使用率 | 80 |
Ingress 参数
| Key | Description | Value |
|---|---|---|
ingress.enabled |
为 DTM 启用 ingress | false |
ingress.className |
为 Ingress 指定一个 Ingress class。 (Kubernetes 1.18+) | "nginx" |
ingress.annotations |
配置 TLS 证书的自动签发注解等. | {} |
ingress.hosts.host |
为 DTM 指定主机名. | "your-domain.com" |
ingress.hosts.paths.path |
为 DTM 配置匹配路径 | "/" |
ingress.hosts.paths.pathType |
Ingress 匹配类型, Prefix 或 Exact |
"Prefix" |
ingress.tls |
为 DTM 主机名配置 TLS secret | [] |
