1、配置依赖nacos的配置 1.1 创建命名空间
1.2 创建seata需要配置
前往seata github的仓库中,找到script/config-center/config.txt
修改配置,配置mysql模式:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 store.mode =db store.lock.mode =db store.session.mode =db store.publicKey= store.db.datasource =druid store.db.dbType =mysql store.db.driverClassName =com.mysql.cj.jdbc.Driver store.db.url =jdbc:mysql://mysql-brlm.newland:3306/seata?useUnicode=true&useSSL=true&rewriteBatchedStatements=true store.db.user =seata store.db.password =seata
2 部署seata 2.1 构建seata镜像 因为官方镜像的driverClassName不支持com.mysql.cj.jdbc.Driver,所以需要添加mysql8的jar支持。
1 2 [root@k8s -master01 seata1]# ls Dockerfile mysql-connector-java-8.0 .30 .jar
添加mysql8的jar支持,创建新的Dockerfile文件
1 2 FROM seataio/seata-server:1 .5 .0 COPY mysql-connector-java-8 .0 .30 .jar /seata-server/libs
开始构建镜像
1 2 [root@k8s-master01 seata1]# nerdctl build -t docker.io/leellun/ seata-server:1.5 .0 -f ./Dockerfile . [root@k8s-master01 seata1]# nerdctl push docker.io/leellun/ seata-server:1.5 .0
2.2 k8s yml配置 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 apiVersion: v1 kind: Service metadata: name: seata-server namespace: newland labels: k8s-app: seata-server spec: type: NodePort ports: - port: 8091 nodePort: 30091 protocol: TCP name: http selector: k8s-app: seata-server --- apiVersion: apps/v1 kind: Deployment metadata: name: seata-server namespace: newland labels: k8s-app: seata-server spec: replicas: 1 selector: matchLabels: k8s-app: seata-server template: metadata: labels: k8s-app: seata-server spec: containers: - name: seata-server image: docker.io/leellun/seata-server:1.5.0 imagePullPolicy: IfNotPresent env: - name: spring.config.location value: file:/root/seata-config/application-prod.yml - name: spring.profiles.active value: prod ports: - name: http containerPort: 8091 protocol: TCP volumeMounts: - name: seata-config mountPath: /root/seata-config volumes: - name: seata-config configMap: name: seata-server-config --- apiVersion: v1 kind: ConfigMap metadata: name: seata-server-config namespace: newland data: application-prod.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: type: nacos nacos: server-addr: nacos-hs.newland:8848 namespace: eb652337-fc10-4027-9e11-9484ef44f4b6 group: SEATA_GROUP username: nacos password: nacos application: seata-server data-id: seataServer.properties registry: type: nacos nacos: application: seata-server server-addr: nacos-hs.newland:8848 group: SEATA_GROUP namespace: eb652337-fc10-4027-9e11-9484ef44f4b6 cluster: default username: nacos password: nacos security: secretKey: SeataSecretKey0c382ef121d778043159209298fd40bf3850a017 tokenValidityInMilliseconds: 1800000 ignore: urls: /,/**/*.css,/**/*.js,/**/*.html,/**/*.map,/**/*.svg,/**/*.png,/**/*.ico,/console-fe/public/**,/api/v1/auth/login
2.3 开始创建k8s资源 1 kubectl create -f ../../ seata.yaml
3 查看部署情况