在k8s环境部署Apache Seatunnel2.3.13
说明
Apache Seatunnel在kunernetes环境部署。支持离线部署。
采用Zeta(cluster mode) 模式。当前采用2.3.13版本,后续随官网及时更新。
参考资料
https://seatunnel.apache.org/docs/2.3.13/getting-started/kubernetes/
下载文件
很重要,必须下载https://atomgit.com/zhudev2026/apacheseatunnel-deploy/tree/main/kubernetes/zeta(cluster-mode)
构建容器镜像
仅用于有定制镜像需求时。
Dockerfile内容,
FROM seatunnelhub/openjdk:8u342 ENVSEATUNNEL_VERSION="2.3.13"ENVSEATUNNEL_HOME="/opt/seatunnel"RUNwgethttps://dlcdn.apache.org/seatunnel/${SEATUNNEL_VERSION}/apache-seatunnel-${SEATUNNEL_VERSION}-bin.tar.gz RUNtar-xzvfapache-seatunnel-${SEATUNNEL_VERSION}-bin.tar.gz RUNmvapache-seatunnel-${SEATUNNEL_VERSION}${SEATUNNEL_HOME}RUNmkdir-p$SEATUNNEL_HOME/logs RUNcd${SEATUNNEL_HOME}&&shbin/install-plugin.sh${SEATUNNEL_VERSION}构建镜像
dockerbuild-tseatunnel:2.3.13-fDockerfile.导出为文件
dockersave-oseatunnel.tar seatunnel:2.3.13将镜像加载到k8s集群,注意,新版k8s只有ctr工具。
ctr-nk8s.io imageimportseatunnel.tar创建namespace
kubectl create namespace seatunnel创建配置文件
当前目录已有所有文件。
参考https://github.com/apache/seatunnel/blob/2.3.13-release/config/v2.streaming.conf.template
创建配置
kubectl create cm seatunnel-config --from-file=seatunnel.streaming.conf=seatunnel.streaming.conf-nseatunnel创建配置
kubectl create configmap hazelcast-client --from-file=hazelcast-client.yaml-nseatunnel kubectl create configmap hazelcast --from-file=hazelcast.yaml-nseatunnel kubectl create configmap seatunnelmap --from-file=seatunnel.yaml-nseatunnel# 可选,用于日志持久化kubectl create configmap log4j2.properties --from-file=log4j2.properties-nseatunnel kubectl create configmap log4j2-client.properties --from-file=log4j2_client.properties-nseatunnel创建reloader
下载文件https://raw.githubusercontent.com/stakater/Reloader/master/deployments/kubernetes/reloader.yaml
修改文件中的namespace部分为seatunnel
kubectl apply-freloader.yaml-nseatunnel创建seatunnel集群
注意:默认三副本,若调整副本数量,需调整configmap的hazelcast和hazelcast-client中的成员的完整服务名字。
kubectl apply-fseatunnel-cluster.yml-nseatunnel修改configmap
此处可以优化到部署阶段,一次部署完成。
注意:此处已经做优化,不需要做编辑修改。不需要做修改。不需要做修改。我已经内置了配置。
kubectl edit cm hazelcast-nseatunnel改为
- seatunnel-0.seatunnel.default.svc.cluster.local - seatunnel-1.seatunnel.default.svc.cluster.local - seatunnel-2.seatunnel.default.svc.cluster.local这是seatunnel的完整服务名
kubectl edit cm hazelcast-client改为
- seatunnel-0.seatunnel.default.svc.cluster.local:5801 - seatunnel-1.seatunnel.default.svc.cluster.local:5801 - seatunnel-2.seatunnel.default.svc.cluster.local:5801服务名和端口。
特殊配置说明
业务需求。非通用配置。
单独配置了8080端口,通过web界面查看信息。
单独配置了日志长期存储。
配置了对接HDFS,即Hadoop的namenode:9000
配置了单独的端口转发服务。
开启8080端口,配置端口nodeport类型的服务。
参考https://seatunnel.apache.org/docs/2.3.13/engines/zeta/web-ui
查询验证
# 查询资源状态kubectl get all-nseatunnel# 提交测试任务kubectlexec-it-nseatunnel seatunnel-0 -- /opt/seatunnel/bin/seatunnel.sh--config/data/seatunnel.streaming.conf-nseatunnel