Deploy Seata Server By Kubernetes

Last Updated

  • 2022.07.23 适配 Seata 1.5.x 增加控制台默认端口7091;seata-sever 在1.5.x 以下版本读取conf配置更改为yml配置文件。

Quick Start

Create file seata-server.yaml

  1. apiVersion: v1
  2. kind: Service
  3. metadata:
  4. name: seata-server
  5. namespace: default
  6. labels:
  7. k8s-app: seata-server
  8. spec:
  9. type: NodePort
  10. ports:
  11. - port: 8091
  12. nodePort: 30091
  13. protocol: TCP
  14. name: service
  15. - port: 7091
  16. nodePort: 30092
  17. protocol: TCP
  18. name: console
  19. selector:
  20. k8s-app: seata-server
  21. ---
  22. apiVersion: apps/v1
  23. kind: Deployment
  24. metadata:
  25. name: seata-server
  26. namespace: default
  27. labels:
  28. k8s-app: seata-server
  29. spec:
  30. replicas: 1
  31. selector:
  32. matchLabels:
  33. k8s-app: seata-server
  34. template:
  35. metadata:
  36. labels:
  37. k8s-app: seata-server
  38. spec:
  39. containers:
  40. - name: seata-server
  41. image: docker.io/seataio/seata-server:latest
  42. imagePullPolicy: IfNotPresent
  43. env:
  44. - name: SEATA_PORT
  45. value: "8091"
  46. - name: STORE_MODE
  47. value: file
  48. ports:
  49. - name: service
  50. containerPort: 8091
  51. protocol: TCP
  52. - name: console
  53. containerPort: 7091
  54. protocol: TCP
  1. $ kubectl apply -f seata-server.yaml

Custom configuration

Environment

The environment is same with Docker, can reference Deploy Seata Server By Docker

Use specify configuration file

Can specify configuration file by mount files or use ConfigMap, and then need specify environment SEATA_CONFIG_NAME, the value need start with file:, like file:/root/seata-config/registry

  • Deployment
  1. apiVersion: apps/v1
  2. kind: Deployment
  3. metadata:
  4. name: seata-server
  5. namespace: default
  6. labels:
  7. k8s-app: seata-server
  8. spec:
  9. replicas: 1
  10. selector:
  11. matchLabels:
  12. k8s-app: seata-server
  13. template:
  14. metadata:
  15. labels:
  16. k8s-app: seata-server
  17. spec:
  18. containers:
  19. - name: seata-server
  20. image: docker.io/seataio/seata-server:latest
  21. imagePullPolicy: IfNotPresent
  22. env:
  23. - name: SEATA_CONFIG_NAME
  24. value: file:/seata-server/conf/
  25. ports:
  26. - name: service
  27. containerPort: 8091
  28. protocol: TCP
  29. - name: console
  30. containerPort: 7091
  31. protocol: TCP
  32. volumeMounts:
  33. - name: seata-config
  34. mountPath: /root/seata-config
  35. volumes:
  36. - name: seata-config
  37. configMap:
  38. name: seata-server-config
  39. ---
  40. 1.5.x 以下版本 ConfigMap
  41. ---
  42. apiVersion: v1
  43. kind: ConfigMap
  44. metadata:
  45. name: seata-server-config
  46. data:
  47. registry.conf: |
  48. registry {
  49. type = "nacos"
  50. nacos {
  51. application = "seata-server"
  52. serverAddr = "127.0.0.1:8848"
  53. }
  54. }
  55. config {
  56. type = "nacos"
  57. nacos {
  58. serverAddr = "127.0.0.1:8848"
  59. group = "SEATA_GROUP"
  60. }
  61. }
  62. ---
  63. 1.5.x 版本 ConfigMap
  64. ---
  65. apiVersion: v1
  66. kind: ConfigMap
  67. metadata:
  68. name: seata-server-config
  69. data:
  70. application.yml: |
  71. server:
  72. port: 7091
  73. spring:
  74. application:
  75. name: seata-server
  76. logging:
  77. config: classpath:logback-spring.xml
  78. file:
  79. path: ${user.home}/logs/seata
  80. console:
  81. user:
  82. username: seata
  83. password: seata
  84. seata:
  85. config:
  86. # support: nacos, consul, apollo, zk, etcd3
  87. type: nacos
  88. nacos:
  89. server-addr: 127.0.0.1:8848
  90. group: SEATA_GROUP
  91. username: xxx
  92. password: xxx
  93. ##if use MSE Nacos with auth, mutex with username/password attribute
  94. #access-key: ""
  95. #secret-key: ""
  96. data-id: seataServer.properties
  97. registry:
  98. # support: nacos, eureka, redis, zk, consul, etcd3, sofa
  99. type: nacos
  100. nacos:
  101. application: seata-server
  102. server-addr: 127.0.0.1:8848
  103. group: SEATA_GROUP
  104. cluster: default
  105. username: xxx
  106. password: xxx
  107. ##if use MSE Nacos with auth, mutex with username/password attribute
  108. #access-key: ""
  109. #secret-key: ""
  110. store:
  111. # support: file 、 db 、 redis
  112. mode: db
  113. db:
  114. datasource: druid
  115. db-type: mysql
  116. driver-class-name: com.mysql.cj.jdbc.Driver
  117. url: jdbc:mysql://xxx:3306/seata
  118. user: xxx
  119. password: xxx
  120. min-conn: 5
  121. max-conn: 100
  122. security:
  123. secretKey: SeataSecretKey0c382ef121d778043159209298fd40bf3850a017
  124. tokenValidityInMilliseconds: 1800000
  125. ignore:
  126. urls: /,/**/*.css,/**/*.js,/**/*.html,/**/*.map,/**/*.svg,/**/*.png,/**/*.ico,/console-fe/public/**,/api/v1/auth/login