k8s安装seata

原文

1、初始seata数据库
wget  https://raw.githubusercontent.com/apache/incubator-seata/1.3.0/script/server/db/mysql.sql
mysql -uroot -p
CREATE DATABASE IF NOT EXISTS seata DEFAULT CHARSET utf8mb4 COLLATE utf8mb4_general_ci;
use seata;
source  /root/mysql.sql;
CREATE USER 'seata'@'%' IDENTIFIED BY 'MXl#GX8hw0wEv!ID';
GRANT ALL PRIVILEGES ON seata.* TO 'seata'@'%';
FLUSH PRIVILEGES;
exit;
2、创建seata配置文件

registry.conf

apiVersion: v1
kind: ConfigMap
metadata:
  name: common-seata-server-registry-config
  namespace: common
data:
  registry.conf: |
    registry {
        type = "nacos"
        nacos {
          application = "seata-server"
          serverAddr = "common-nacos.t1-zdbl.svc.cluster.local:8848"
          group = "SEATA_GROUP"
          namespace = "seata"
          cluster = "default"
          username = "nacos"
          password = "m5LqrxYsD7N1F6Cb"
        }
    }
    config {
      type = "file"
      file {
            name = "file:/seata-server/resources/file.conf"
          }
    }

file.conf

apiVersion: v1
kind: ConfigMap
metadata:
  name: common-seata-server-file-config
  namespace: common
data:
  file.conf: |
    store {
        mode = "db"    
        db {
           datasource = "druid"
           dbType = "mysql"
           driverClassName = "com.mysql.cj.jdbc.Driver"
           url = "jdbc:mysql://common-mysql.t1-zdbl.svc.cluster.local:3306/common_seata?useUnicode=true&characterEncoding=UTF-8"
           user = "seata"
           password = "xxxxx"  #连接nacos的密码不能包含特殊字符,否则会报错,403无法注册
           minConn = 5
           maxConn = 100
           globalTable = "global_table"
           branchTable = "branch_table"
           lockTable = "lock_table"
           queryLimit = 100
           maxWait = 5000
        }
    }
3、创建Deployment
apiVersion: apps/v1
kind: Deployment
metadata:
  name: common-seata-server
  namespace: common
  labels:
    k8s-app: common-seata-server
spec:
  replicas: 1
  selector:
    matchLabels:
      k8s-app: common-seata-server
  template:
    metadata:
      labels:
        k8s-app: common-seata-server
    spec:
      containers:
        - name: seata-server
          image: seataio/seata-server:1.3.0
          #command: ["/bin/sh","-c","sleep 3600000"]
          env:
            - name: SEATA_PORT
              value: "8091"
          ports:
            - name: http
              containerPort: 8091
              protocol: TCP
          volumeMounts:
          - mountPath: /seata-server/resources/file.conf
            name: seata-file-conf
            subPath: file.conf
          - mountPath: /seata-server/resources/registry.conf
            name: seata-register-conf
            subPath: registry.conf
      volumes:
      - name: seata-file-conf
        configMap:
          defaultMode: 420
          name: common-seata-server-file-config
      - name: seata-register-conf
        configMap:
          defaultMode: 420
          name: common-seata-server-registry-config
4、创建svc
apiVersion: v1
kind: Service
metadata:
  name: common-seata-server
  namespace: t1-zdbl
  labels:
    k8s-app: common-seata-server
spec:
  ports:
    - port: 8091
      targetPort: 8091
      protocol: TCP
      name: http
  selector:
    k8s-app: common-seata-server
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值