网站建设与推广方案,建筑模板规格尺寸,wordpress交易系统,网站备案迁移文章目录 创建 Deployment 文件创建 ConfigMap 文件创建 Service 文件运行访问高可用部署踩坑 官方文档 k8s中volumeMounts.subPath的巧妙用法 创建 Deployment 文件
deploymemt.yaml
namespace#xff1a;指定命名空间image#xff1a;使用 1.5.2 版本的镜像ports#xf… 文章目录 创建 Deployment 文件创建 ConfigMap 文件创建 Service 文件运行访问高可用部署踩坑 官方文档 k8s中volumeMounts.subPath的巧妙用法 创建 Deployment 文件
deploymemt.yaml
namespace指定命名空间image使用 1.5.2 版本的镜像ports暴露 8091 和 7091 端口volumeMounts容器中的存储mountPath 存储路径subPath指定出具体文件volumespod 存储configMap.name对应 configMap 文件的 metadata. name
apiVersion: apps/v1
kind: Deployment
metadata:name: seata-servernamespace: commonlabels:k8s-app: seata-server
spec:replicas: 1selector:matchLabels:k8s-app: seata-servertemplate:metadata:labels:k8s-app: seata-serverspec:containers:- name: seata-serverimage: docker.io/seataio/seata-server:1.5.2imagePullPolicy: IfNotPresentports:- name: http-7091containerPort: 7091protocol: TCP- name: http-8091containerPort: 8091protocol: TCPvolumeMounts:- name: seata-configmountPath: /seata-server/resources/application.ymlsubPath: application.ymlvolumes:- name: seata-configconfigMap:name: seata-server-config创建 ConfigMap 文件
configmap.yaml 映射 application.yml 文件例子使用 seata 原始配置文件
apiVersion: v1
kind: ConfigMap
metadata:name: seata-server-confignamespace: common
data:application.yml: |server:port: 7091spring:application:name: seata-serverlogging:config: classpath:logback-spring.xmlfile:path: ${user.home}/logs/seataextend:logstash-appender:destination: 127.0.0.1:4560kafka-appender:bootstrap-servers: 127.0.0.1:9092topic: logback_to_logstashconsole:user:username: seatapassword: seataseata:config:# support: nacos, consul, apollo, zk, etcd3type: fileregistry:# support: nacos, eureka, redis, zk, consul, etcd3, sofatype: filestore:# support: file 、 db 、 redismode: file# server:# service-port: 8091 #If not configured, the default is ${server.port} 1000security:secretKey: SeataSecretKey0c382ef121d778043159209298fd40bf3850a017tokenValidityInMilliseconds: 1800000ignore:urls: /,/**/*.css,/**/*.js,/**/*.html,/**/*.map,/**/*.svg,/**/*.png,/**/*.ico,/console-fe/public/**,/api/v1/auth/login创建 Service 文件
service.yaml 对外暴露 NodePort 端口
apiVersion: v1
kind: Service
metadata:name: seata-servernamespace: commonlabels:k8s-app: seata-server
spec:type: NodePortports:- port: 8091nodePort: 30893protocol: TCPname: seata-8091- port: 7091nodePort: 30793protocol: TCPname: seata-7091selector:k8s-app: seata-server运行
kubectl apply -f deployment.yaml
kubectl apply -f configmap.yaml
kubectl apply -f service.yaml访问
访问 ip:30793 即可访问 seata 默认账号seata 默认密码seata 高可用部署
修改 configmap 映射的 application.yml 文件
seata.config配置 seata 配置文件路径seata.registry配置 seata 注册地址
seata:config:type: nacosnacos:server-addr: nacosIp:portnamespace: seatagroup: devusername: nacospassword: nacosdata-id: seata-dev.ymlregistry:type: nacosnacos:application: seata-serverserver-addr: nacosIp:portgroup: devnamespace: seatacluster: defaultusername: nacospassword: nacosdeployment 添加多个 pod
成功注册上 nacos 踩坑 问题按照官方文档 Seata 高可用部署镜像使用 1.5.0 及以上的版本时seata 无法正常注册到 nacos 解决办法镜像使用 1.4.2 版本 问题使用 1.4.2 版本版本后高可用还是有问题nodeport 暴露后无法访问 解决办法使用本文部署