阿里巴巴K8S集成seata
阿里巴巴K8S集成seata
·
正文
在K8S集成seata,官方配置
代码
apiVersion: v1
kind: Service
metadata:
name: seata-server
namespace: wmz-dev
labels:
k8s-app: seata-server
spec:
type: NodePort
ports:
- port: 8091
nodePort: 30091
protocol: TCP
name: http
selector:
k8s-app: seata-server
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: seata-server
namespace: wmz-dev
labels:
k8s-app: seata-server
spec:
replicas: 1
selector:
matchLabels:
k8s-app: seata-server
template:
metadata:
labels:
k8s-app: seata-server
spec:
containers:
- name: seata-server
image: docker.io/seataio/seata-server:latest
imagePullPolicy: IfNotPresent
env:
- name: SEATA_CONFIG_NAME
value: file:/root/seata-config/registry.conf
ports:
- name: http
containerPort: 8091
protocol: TCP
volumeMounts:
- name: seata-config
mountPath: /root/seata-config
volumes:
- name: seata-config
configMap:
name: seata-server-config
---
apiVersion: v1
kind: ConfigMap
metadata:
name: seata-server-config
data:
registry.conf: |
registry {
type = "nacos"
nacos {
application = "seata-server"
serverAddr = "192.168.199.2"
cluster= "default"
group = "WEIMEIZI_GROUP"
username = "nacos"
password = "nacos"
}
}
config {
type = "nacos"
nacos {
serverAddr = "192.168.199.2"
group = "SEATA_GROUP"
group = "WEIMEIZI_GROUP"
username = "nacos"
password = "nacos"
}
}
配置文件主要看中间和最底下的代码
中间:主要看
env:
- name: SEATA_CONFIG_NAME
value: file:/root/seata-config/registry.conf
这代表指定配置文件,下面则是指定ConfigMap
ConfigMap则是seata的config/application.properties文件里的内容
创建后,在阿里的配置项会有这个配置
如果已经有配置项,创建K8S时可以去掉最底层代码
重要
在K8S创建seata,可能在nacos看不到seata的服务,但实际上,seata已经成功运行,并且系统也把事务托管给了seata,我就是这个样子的,nacos找不到,还以为seata没注册成功
nacos配置文件
改了以后,虽然在nacos的服务列表没有seata,但是看了seata的启动日志,发现它已经把系统的事务进行托管,经测试,分布式事务也能正常回滚
更多推荐
已为社区贡献1条内容
所有评论(0)