使用 Kubernetes 部署 Seata Server

快速启动

创建 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: http
  15. selector:
  16. k8s-app: seata-server
  17. ---
  18. apiVersion: apps/v1
  19. kind: Deployment
  20. metadata:
  21. name: seata-server
  22. namespace: default
  23. labels:
  24. k8s-app: seata-server
  25. spec:
  26. replicas: 1
  27. selector:
  28. matchLabels:
  29. k8s-app: seata-server
  30. template:
  31. metadata:
  32. labels:
  33. k8s-app: seata-server
  34. spec:
  35. containers:
  36. - name: seata-server
  37. image: docker.io/seataio/seata-server:latest
  38. imagePullPolicy: IfNotPresent
  39. env:
  40. - name: SEATA_PORT
  41. value: "8091"
  42. - name: STORE_MODE
  43. value: file
  44. ports:
  45. - name: http
  46. containerPort: 8091
  47. protocol: TCP
  1. $ kubectl apply -f seata-server.yaml

自定义配置

环境变量

支持的环境变量和 Docker 相同,可以参考 使用 Docker 部署 Seata Server

使用自定义配置文件

指定配置文件可以通过挂载文件或使用 ConfigMap 的方式实现,挂载后需要通过指定 SEATA_CONFIG_NAME 指定配置文件位置,并且环境变量的值需要以file:开始, 如: 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:/root/seata-config/registry
  25. ports:
  26. - name: http
  27. containerPort: 8091
  28. protocol: TCP
  29. volumeMounts:
  30. - name: seata-config
  31. mountPath: /root/seata-config
  32. volumes:
  33. - name: seata-config
  34. configMap:
  35. name: seata-server-config
  36. ---
  37. apiVersion: v1
  38. kind: ConfigMap
  39. metadata:
  40. name: seata-server-config
  41. data:
  42. registry.conf: |
  43. registry {
  44. type = "nacos"
  45. nacos {
  46. application = "seata-server"
  47. serverAddr = "192.168.199.2"
  48. }
  49. }
  50. config {
  51. type = "nacos"
  52. nacos {
  53. serverAddr = "192.168.199.2"
  54. group = "SEATA_GROUP"
  55. }
  56. }