当前位置:   article > 正文

Apache SeaTunnel k8s 集群模式 Zeta 引擎部署指南

Apache SeaTunnel k8s 集群模式 Zeta 引擎部署指南

file

SeaTunnel提供了一种运行Zeta引擎(cluster-mode)的方法,可以让Kubernetes在本地运行Zeta引擎,实现更高效的应用程序部署和管理。在本文中,我们将探索SeaTunnel k8s运行zeta引擎(cluster-mode模式)的更多信息,了解如何更好地利用Zeta引擎的优势。

  1. 将SeaTunnel上传至服务器上。我之前已经解压并执行过install-plugin.sh,这里为了方便,我直接用的执行过install-plugin.sh脚本之后的seatunnel做演示。

执行过install-plugin后的lib目录包含如下:

file

tar -zxvf apache-seatunnel-2.3.3-bin.tar.gz
sh apache-seatunnel-2.3.3/bin/install-plugin.sh
tar -czvf  apache-seatunnel-2.3.3-bin.tar.gz  apache-seatunnel-2.3.3
  • 1
  • 2
  1. 构建seatunnel镜像。在安装seatunnel的同级文件夹下创建Dockerfile。配置如下,可自行选择版本:
    FROM openjdk:8
    ENV SEATUNNEL_HOME="/opt/seatunnel"
    ENV SEATUNNEL_VERSION="2.3.3"
    COPY /apache-seatunnel-${SEATUNNEL_VERSION}-bin.tar.gz /opt/apache-seatunnel-${SEATUNNEL_VERSION}-bin.tar.gz
    WORKDIR /opt
    RUN tar -xzvf apache-seatunnel-${SEATUNNEL_VERSION}-bin.tar.gz
    RUN mv apache-seatunnel-${SEATUNNEL_VERSION} seatunnel
    RUN rm -f /opt/apache-seatunnel-${SEATUNNEL_VERSION}-bin.tar.gz
    WORKDIR /opt/seatunnel
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8

执行命令

docker build -t seatunnel:2.3.3 -f Dockerfile.
    1. 查看镜像
    docker images

      如下所示镜像

      file

      1. 将镜像load进k8s,这里用的minikube做演示

        minikube image load seatunnel:2.3.3

          上述可参考:手把手教你掌握SeaTunnel k8s运行Zeta引擎本地模式的技巧

        • 创建configmap如下

          kubectl create configmap hazelcast-client  --from-file= config/hazelcast-client.yaml
          kubectl create configmap hazelcast  --from-file=config/hazelcast.yaml
          kubectl create configmap seatunnelmap  --from-file=config/seatunnel.yaml
          • 1
          • 2
        • 使用Reloader实现更新configmap后自动重启pod

        wget https://raw.githubusercontent.com/stakater/Reloader/master/deployments/kubernetes/reloader.yaml
        
        kubectl apply -f reloader.yaml
        • 1
        • 2

        file

        1. 创建seatunnel-cluster.yml如下
        apiVersion: v1
        kind: Service
        metadata:
          name: seatunnel
        spec:
          selector:
            app: seatunnel
          ports:
          - port: 5801
            name: seatunnel
          clusterIP: None
        ---
        apiVersion: apps/v1
        kind: StatefulSet
        metadata:
          name: seatunnel
          annotations:
            configmap.reloader.stakater.com/reload: "hazelcast,hazelcast-client,seatunnelmap"
        spec:
          serviceName: "seatunnel"
          replicas: 3
          selector:
            matchLabels:
              app: seatunnel
          template:
            metadata:
              labels:
                app: seatunnel
            spec:
              containers:
                - name: seatunnel
                  image: seatunnel:2.3.3
                  imagePullPolicy: IfNotPresent
                  ports:
                    - containerPort: 5801
                      name: client
                  command: ["/bin/sh","-c","/opt/seatunnel/bin/seatunnel-cluster.sh -DJvmOption=-Xms2G -Xmx2G"]
                  resources:
                    limits:
                      cpu: "1"
                      memory: 4G
                    requests:
                      cpu: "1"
                      memory: 2G
                  volumeMounts:
                    - mountPath: "/opt/seatunnel/config/hazelcast.yaml"
                      name: hazelcast
                      subPath: hazelcast.yaml
                    - mountPath: "/opt/seatunnel/config/hazelcast-client.yaml"
                      name: hazelcast-client
                      subPath: hazelcast-client.yaml
                    - mountPath: "/opt/seatunnel/config/seatunnel.yaml"
                      name: seatunnelmap
                      subPath: seatunnel.yaml
              volumes:
                - name: hazelcast
                  configMap:
                    name: hazelcast
                - name: hazelcast-client
                  configMap:
                    name: hazelcast-client
                - name: seatunnelmap
                  configMap:
                    name: seatunnelmap
        • 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
        1. 执行
         kubectl apply -f seatunnel-cluster.yml

          file

          file

          1. 修改configmap中的配置
          kubectl edit cm hazelcast
            修改集群地址 
            这里采用的是headless service访问模式
            一般pod之间访问其格式为 <pod-name>.<service-name>.<namespace>.svc.cluster.local
            • 1
            • 2

            如下示例

            • seatunnel-0.seatunnel.default.svc.cluster.local
            • seatunnel-1.seatunnel.default.svc.cluster.local
            • seatunnel-2.seatunnel.default.svc.cluster.local

            友情提示:不要用tab,用空格 。不然会报错

            file

            kubectl edit cm hazelcast-client

              file

              kubectl edit cm seatunnelmap

                file

                此处改为自己的hdfs地址。

                1. 可以看到如下

                file

                1. 待所有节点都更新完毕处于running状态后 可进入容器内查看路径是否已修改
                kubectl exec -it seatunnel-0 /bin/bash
                cat config/hazelcast.yaml
                • 1

                file

                1. 在容器内查看日志
                tail -200f logs/seatunnel-engine-server.log

                  file

                  我们发现集群已经正常运行.

                  1. 运行任务

                  我们可以再新打开一个连接,登录另一个pod节点执行任务来测试集群:

                  kubectl exec -it seatunnel-1 /bin/bash
                    bin/seatunnel.sh --config config/v2.streaming.conf.template

                      我们发现其他pod内也已经开始运行任务

                      file

                      原文链接:https://blog.csdn.net/weixin_41854429/article/details/132836402

                      本文由 白鲸开源科技 提供发布支持!

                      声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/羊村懒王/article/detail/546776
                      推荐阅读
                      相关标签
                        

                      闽ICP备14008679号