首页
首页
文章目录
  1. 前因
  2. yaml配置文件

Seata在kubernetes中使用自定义配置文件创建服务

前因

好久没有写博客了,因为工作的原因,使我现在无法静下心来记录自己的工作内容。

今天 一个项目上的数据库事务从txlcn-tm换到了Seata上。然后研发负责人很急说这边要上线了,把这个服务赶紧部署到集群里面。

我们这边所有的服务均是“微服务”(现在这个词很火)部署在kubernetes上。

打开了官方文档一顿撸。官方文写的使用自定义配置文件不能拿来即用,我这种懒人很是不喜欢。所以自己写了一个可以给大家哪来即用的yaml

yaml配置文件

再啰嗦一句 这是基于nacos的 将数据库配置到file.conf配置文件中。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
apiVersion: apps/v1
kind: Deployment
metadata:
name: seata-server
namespace: default
labels:
app: seata-server
spec:
replicas: 2
selector:
matchLabels:
app: seata-server
template:
metadata:
labels:
app: seata-server
spec:
containers:
- name: seata-server
image: dzero.com/base/seata-server:1
imagePullPolicy: IfNotPresent
env:
- name: SEATA_CONFIG_NAME
value: file:/root/seata-config/registry
ports:
- name: http
containerPort: 8091
protocol: TCP
volumeMounts:
- name: seata-config
mountPath: /root/seata-config
- name: seata-file
mountPath: /root/seata-config-file
volumes:
- name: seata-config
configMap:
name: seata-server-config
- name: seata-file
configMap:
name: seata-server-file
imagePullSecrets:
- name: myregistrykey

---
apiVersion: v1
kind: ConfigMap
metadata:
name: seata-server-config
data:
registry.conf: |
registry {
type = "nacos"
nacos {
application = "seata-server"
serverAddr = "nacos地址"
}
}
config {
type = "file"
file {
name = "/root/seata-config-file/file.conf"
}
}
---
apiVersion: v1
kind: ConfigMap
metadata:
name: seata-server-file
data:
file.conf: |
store {
mode = "db"
file {
dir = "sessionStore"
maxBranchSessionSize = 16384
maxGlobalSessionSize = 512
fileWriteBufferCacheSize = 16384
sessionReloadReadSize = 100
flushDiskMode = async
}
db {
datasource = "druid"
dbType = "postgresql"
driverClassName = "org.postgresql.Driver"
url = "jdbc:postgresql://数据库地址/数据库?stringtype=unspecified"
user = "账户"
password = "密码"
minConn = 5
maxConn = 30
globalTable = "global_table"
branchTable = "branch_table"
lockTable = "lock_table"
queryLimit = 100
maxWait = 5000
}
}
---
apiVersion: v1
kind: Service
metadata:
name: seata-server
labels:
app: seata-server
spec:
type: NodePort
ports:
- port: 8091
targetPort: 8091
protocol: TCP
nodePort: 8091
selector:
app: seata-server

注: service 可以按需创建 这边创建的NodePort 如果有dns可以不需要 直接内部使用即可。这边方便调试所有选择的是NodePort

以上可以直接拿来即用。

End

支持一下
扫一扫,我会更有动力更新
  • 微信扫一扫
  • 支付宝扫一扫