程序员的资源宝库

网站首页 > gitee 正文

k8s部署seata1.7.0

sanyeah 2024-04-08 12:53:47 gitee 3 ℃ 0 评论

seata官网:http://seata.io/zh-cn/index.html

seata1.7.0是采用application.yml方式配置的。

seata的注册加配置中心采用nacos设置,所以需要修改application.yml文件,我将此文件通过cofigmap方式挂载出来了。可直接修改cofigmap,然后重启seata服务生效。nacos的server地址和namespace等根据自己实际情况修改。

configmap.yaml如下:

---
apiVersion: v1
data:
  application.yml: >-
    server:
      port: 7091
    spring:
      application:
        name: seata-server
    logging:
      config: classpath:logback-spring.xml
      file:
        path: ${user.home}/logs/seata
      extend:
        logstash-appender:
          destination: 127.0.0.1:4560
        kafka-appender:
          bootstrap-servers: 127.0.0.1:9092
          topic: logback_to_logstash
    console:
      user:
        username: seata
        password: seata
    seata:
      config:
        # support: nacos, consul, apollo, zk, etcd3
        type: nacos
        nacos:
          server-addr: 192.168.111.90:30848
          namespace: cloud
          username: nacos
          password: nacos
          dataId: seata.properties
      registry:
        # support: nacos, eureka, redis, zk, consul, etcd3, sofa
        type: nacos
        nacos:
          server-addr: 192.168.111.90:30848
          namespace: cloud
          cluster: default
          username: nacos
          password: nacos
      store:
        # support: file 、 db 、 redis
        mode: file
    #  server:

    #    service-port: 8091 #If not configured, the default is '${server.port} +
    1000'
      security:
        secretKey: SeataSecretKey0c382ef121d778043159209298fd40bf3850a017
        tokenValidityInMilliseconds: 1800000
        ignore:
          urls: /,/**/*.css,/**/*.js,/**/*.html,/**/*.map,/**/*.svg,/**/*.png,/**/*.jpeg,/**/*.ico,/api/v1/auth/login
kind: ConfigMap
metadata:
  name: seata-server-config
  namespace: kube-public

Deployment及sevice服务的yaml文件如下:
---
apiVersion: apps/v1
kind: Deployment
metadata:
   labels:
    k8s-app: seata-server
    k8s.kuboard.cn/layer: cloud
  name: seata-server
  namespace: kube-public
spec:
  selector:
    matchLabels:
      k8s-app: seata-server
  template:
    metadata:
      labels:
        k8s-app: seata-server
    spec:
      containers:
        - env:
            - name: SEATA_IP
              value: 192.168.111.90
            - name: SEATA_PORT
              value: '30091'
          image: 'docker.io/seataio/seata-server:1.7.0'
          imagePullPolicy: IfNotPresent
          name: seata-server
          volumeMounts:
            - mountPath: /seata-server/resources/application.yml
              name: seata-config
              subPath: application.yml
      restartPolicy: Always
      volumes:
        - configMap:
            defaultMode: 420
            items:
              - key: application.yml
                path: application.yml
            name: seata-server-config
          name: seata-config

---
apiVersion: v1
kind: Service
metadata:
  labels:
    k8s-app: seata-server
  name: seata-server
  namespace: kube-public
spec:
  ports:
    - name: http
      nodePort: 30091
      port: 30091
      protocol: TCP
      targetPort: 30091
    - name: 8pxfed
      nodePort: 30791
      port: 7091
      protocol: TCP
      targetPort: 7091
  selector:
    k8s-app: seata-server
  type: NodePort

 

seata的在nacos的配置,需要注意几点:

1.seata客户端要和seata在一个namesapce和group下。

2.seata.properties要在nacos的配置管理中添加。具体内容可去seata的官网上查看。

3.seata客户端的一些配置要和nacos配置的对起来。具体在springboot集成seata中再说。

本文暂时没有评论,来添加一个吧(●'◡'●)

欢迎 发表评论:

最近发表
标签列表