阿里云 ACK 中部署 SeataServer

背景

经纪人部分模块使用到此服务,需要以容器化的方式进行部署。
SeataServer官方文档地址

部署

步骤一:创建ConfigMap配置文件

kind: ConfigMap
apiVersion: v1
metadata:
  name: seata-application-yml
  namespace: seata
  annotations:
    kubesphere.io/creator: admin
data:
  application.yml: |-
    server:
      port: 8091

    spring:
      application:
        name: seata-server

    logging:
      config: classpath:logback-spring.xml
      file:
        path: ${user.home}/logs
      extend:
        logstash-appender:
          destination: 127.0.0.1:4560
        kafka-appender:
          bootstrap-servers: 127.0.0.1:9092
          topic: logback_to_logstash

    seata:
      config:
        # support: nacos 、 consul 、 apollo 、 zk  、 etcd3
        type: nacos
        nacos:
          server-addr: nacos.com:8848
          namespace: 300cb9b7-***-***-96ca-9a6****b994f
          group: SEATA_GROUP
          username: seata
          password: ****
          data-id: seataServer.properties
      registry:
        # support: nacos 、 eureka 、 redis 、 zk  、 consul 、 etcd3 、 sofa
        type: nacos
        nacos:
          application: seata-server
          server-addr: nacos.com:8848
          group: SEATA_GROUP
          namespace: 300cb9b7-***-***-96ca-9a6****b994f
          cluster: default
          username: seata
          password: ****

      server:
        service-port: 8091

可以看到,Seata的配置和注册均使用我们自建的Nacos,Seata的服务端口为8091.

步骤二:创建Deployment

kind: Deployment
apiVersion: apps/v1
metadata:
  name: seata-server
  namespace: seata
  labels:
    app: seata-server
spec:
  replicas: 1
  selector:
    matchLabels:
      app: seata-server
  template:
    metadata:
      creationTimestamp: null
      labels:
        app: seata-server
      annotations:
        logging.kubesphere.io/logsidecar-config: '{}'
    spec:
      volumes:
        - name: host-time
          hostPath:
            path: /etc/localtime
            type: ''
        - name: volume-2lah18
          persistentVolumeClaim:
            claimName: seata-logs
        - name: volume-9y0ixe
          configMap:
            name: seata-application-yml
            defaultMode: 420
      containers:
        - name: container-7bm5dl
          image: 'registry.cn-hangzhou.aliyuncs.com/mq_basic/seata-server:1.5.0-SNAPSHOT'
          ports:
            - name: tcp-8091
              containerPort: 8091
              protocol: TCP
          resources:
            limits:
              memory: 1Gi
            requests:
              memory: 1Gi
          volumeMounts:
            - name: host-time
              readOnly: true
              mountPath: /etc/localtime
            - name: volume-2lah18
              mountPath: /root/logs
            - name: volume-9y0ixe
              mountPath: /seata-server/resources/application.yml
              subPath: application.yml
          terminationMessagePath: /dev/termination-log
          terminationMessagePolicy: File
          imagePullPolicy: IfNotPresent
      restartPolicy: Always
      terminationGracePeriodSeconds: 30
      dnsPolicy: ClusterFirst
      serviceAccountName: default
      serviceAccount: default
      securityContext: {}
      affinity: {}
      schedulerName: default-scheduler
  strategy:
    type: RollingUpdate
    rollingUpdate:
      maxUnavailable: 25%
      maxSurge: 25%
  revisionHistoryLimit: 10
  progressDeadlineSeconds: 600

将上面创建的Configmap挂载到/seata-server/resources/application.yml路径,限制为1G的内存资源。

结果验证

  1. 查看seata-server工作负载的日志,确认可以正常启动。

  2. 查看Nacos的注册中心,确认seata-server注册成功,且服务地址为pod的地址。


    image.png
image

备注

  • 刚查了一下seata的官网,官网上说service.default.grouplist是在file注册中心时有效,nacos注册中心不用管这个配置

  • 记得修改配置中心里与Seata有关的配置信息。

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容