当前位置: 首页> 娱乐> 明星 > 第 9 篇 Helm 部署 Seata Server

第 9 篇 Helm 部署 Seata Server

时间:2025/8/1 2:43:52来源:https://blog.csdn.net/u012383839/article/details/142031497 浏览次数:0次

文章目录

  • chart 源代码
    • Chart.yaml
    • values.yaml
    • .helmignore
    • templates\_helpers.tpl
    • templates\deployment.yaml
    • templates\service.yaml
    • templates\NOTES.txt
  • 快速启动
  • 自定义配置
    • 环境变量
    • 自定义配置文件
  • 参考
  • 相关博文

🚀 本文内容:使用 Helm 部署 Seata Server。

👉 官方文档:https://seata.apache.org/zh-cn/docs/ops/deploy-by-helm

chart 源代码

v2.0.0 版本:

  • https://github.com/apache/incubator-seata
  • https://gitee.com/itsforkgithub/incubator-seata

源码包:incubator-seata-v2.0.0.zip

Chart.yaml

apiVersion: v1
appVersion: "1.0"
description: Seata Server
name: seata-server
version: 1.0.0

values.yaml

replicaCount: 1namespace: defaultimage:repository: seataio/seata-servertag: latestpullPolicy: IfNotPresentservice:type: NodePortport: 30091env:seataPort: "8091"storeMode: "file"serverNode: "1"

.helmignore

# Patterns to ignore when building packages.
# This supports shell glob matching, relative path matching, and
# negation (prefixed with !). Only one pattern per line.
.DS_Store
# Common VCS dirs
.git/
.gitignore
.bzr/
.bzrignore
.hg/
.hgignore
.svn/
# Common backup files
*.swp
*.bak
*.tmp
*~
# Various IDEs
.project
.idea/
*.tmproj
.vscode/

templates_helpers.tpl

{{/* vim: set filetype=mustache: */}}
{{/*
Expand the name of the chart.
*/}}
{{- define "seata-server.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}}
{{- end -}}{{/*
Create a default fully qualified app name.
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
If release name contains chart name it will be used as a full name.
*/}}
{{- define "seata-server.fullname" -}}
{{- if .Values.fullnameOverride -}}
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}}
{{- else -}}
{{- $name := default .Chart.Name .Values.nameOverride -}}
{{- if contains $name .Release.Name -}}
{{- .Release.Name | trunc 63 | trimSuffix "-" -}}
{{- else -}}
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}}
{{- end -}}
{{- end -}}
{{- end -}}{{/*
Create chart name and version as used by the chart label.
*/}}
{{- define "seata-server.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
{{- end -}}{{/*
Common labels
*/}}
{{- define "seata-server.labels" -}}
app.kubernetes.io/name: {{ include "seata-server.name" . }}
helm.sh/chart: {{ include "seata-server.chart" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end -}}{{/*
Create the name of the service account to use
*/}}
{{- define "seata-server.serviceAccountName" -}}
{{- if .Values.serviceAccount.create -}}{{ default (include "seata-server.fullname" .) .Values.serviceAccount.name }}
{{- else -}}{{ default "default" .Values.serviceAccount.name }}
{{- end -}}
{{- end -}}

templates\deployment.yaml

apiVersion: apps/v1
kind: Deployment
metadata:
{{- if .Values.namespace }}namespace: {{ .Values.namespace }}
{{- end}}name: {{ include "seata-server.name" . }}labels:
{{ include "seata-server.labels" . | indent 4 }}
spec:replicas: {{ .Values.replicaCount }}selector:matchLabels:app.kubernetes.io/name: {{ include "seata-server.name" . }}app.kubernetes.io/instance: {{ .Release.Name }}template:metadata:labels:app.kubernetes.io/name: {{ include "seata-server.name" . }}app.kubernetes.io/instance: {{ .Release.Name }}spec:containers:- name: {{ .Chart.Name }}image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"imagePullPolicy: {{ .Values.image.pullPolicy }}ports:- name: httpcontainerPort: 8091protocol: TCP{{- if .Values.volume }}volumeMounts:{{- range .Values.volume }}- name: {{ .name }}mountPath: {{ .mountPath }}{{- end}}{{- end}}{{- if .Values.env }}env:{{- if .Values.env.seataIp }}- name: SEATA_IPvalue: {{ .Values.env.seataIp  | quote }}{{- end }}{{- if .Values.env.seataPort }}- name: SEATA_PORTvalue: {{ .Values.env.seataPort | quote }}{{- end }}{{- if .Values.env.seataEnv }}- name: SEATA_ENVvalue: {{ .Values.env.seataEnv }}{{- end }}{{- if .Values.env.seataConfigName }}- name: SEATA_CONFIG_NAMEvalue: {{ .Values.env.seataConfigName }}{{- end }}{{- if .Values.env.serverNode }}- name: SERVER_NODEvalue: {{ .Values.env.serverNode | quote }}{{- end }}{{- if .Values.env.storeMode }}- name: STORE_MODEvalue: {{ .Values.env.storeMode }}{{- end }}{{- end }}{{- if .Values.volume }}volumes:{{- range .Values.volume }}- name: {{ .name }}hostPath:path: {{ .hostPath}}{{- end}}{{- end}}

templates\service.yaml

apiVersion: v1
kind: Service
metadata:name: {{ include "seata-server.fullname" . }}labels:
{{ include "seata-server.labels" . | indent 4 }}
spec:type: {{ .Values.service.type }}ports:- port: {{ .Values.service.port }}targetPort: httpprotocol: TCPname: httpselector:app.kubernetes.io/name: {{ include "seata-server.name" . }}app.kubernetes.io/instance: {{ .Release.Name }}

templates\NOTES.txt

1. Get the application URL by running these commands:
{{- if contains "NodePort" .Values.service.type }}export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "seata-server.fullname" . }})export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}")echo http://$NODE_IP:$NODE_PORT
{{- else if contains "LoadBalancer" .Values.service.type }}NOTE: It may take a few minutes for the LoadBalancer IP to be available.You can watch the status of by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "seata-server.fullname" . }}'export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "seata-server.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}")echo http://$SERVICE_IP:{{ .Values.service.port }}
{{- else if contains "ClusterIP" .Values.service.type }}export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "seata-server.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}")echo "Visit http://127.0.0.1:8080 to use your application"kubectl port-forward $POD_NAME 8080:80
{{- end }}

快速启动

# 安装 git
yum install -y git# 克隆代码
git clone https://github.com/apache/incubator-seata.git
# 切换到 v2.0.0 版本
cd incubator-seata/
git checkout tags/v2.0.0# 快速启动
cd ./script/server/helm/seata-server
helm install seata-server .
# NAME: seata-server
# LAST DEPLOYED: Tue May 28 14:00:30 2024
# NAMESPACE: default
# STATUS: deployed
# REVISION: 1
# NOTES:
# 1. Get the application URL by running these commands:
#   export NODE_PORT=$(kubectl get --namespace default -o jsonpath="{.spec.ports[0].nodePort}" services seata-server)
#   export NODE_IP=$(kubectl get nodes --namespace default -o jsonpath="{.items[0].status.addresses[0].address}")
#   echo http://$NODE_IP:$NODE_PORT

自定义配置

环境变量

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

自定义配置文件

指定配置文件可以通过挂载的方式实现,如将 /root/workspace/seata/seata-config/file 下的配置文件挂载到 pod 中,挂载后需要通过指定 SEATA_CONFIG_NAME 指定配置文件位置,并且环境变量的值需要以file:开始, 如: file:/root/seata-config/registry

replicaCount: 1namespace: defaultimage:repository: seataio/seata-servertag: latestpullPolicy: IfNotPresentservice:type: NodePortport: 30091env:seataPort: "8091"storeMode: "file"seataIp: "127.0.0.1"seataConfigName: "file:/root/seata-config/registry"volume:- name: seata-configmountPath: /root/seata-confighostPath: /root/workspace/seata/seata-config/file

至此,部署完成!!!

附 Chart:seata-server-1.0.0.tgz.zip

参考

1.https://github.com/apache/incubator-seata/issues/4896
2.k8s helm Seata1.5.1-CSDN博客

相关博文

1.第 1 篇 Helm 简介及安装
2.第 2 篇 Helm 部署 MySQL【入门案例】
3.第 3 篇 Helm 命令、环境变量、相关目录
4.第 4 篇 Chart 仓库详解
5.第 5 篇 Chart 文件结构详解
6.第 6 篇 自定义 Helm Chart
7.第 7 篇 Helm 部署 Nacos【详细步骤】
8.第 8 篇 Chart 修改入门示例:Nacos
9.第 9 篇 Helm 部署 Seata Server
10.第 10 篇 Chart 修改完美示例:Seata Server
11.第 11篇 Helm 部署 RabbitMQ
12.第 12 篇 Helm 部署 Redis
13.第13 篇 Helm 部署 ElasticSearch

关键字:第 9 篇 Helm 部署 Seata Server

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com

责任编辑: