正文
在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的启动日志,发现它已经把系统的事务进行托管,经测试,分布式事务也能正常回滚
原文地址:https://blog.csdn.net/weixin_39388918/article/details/133357674
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。