手把手教你掌握SeaTunnel k8s執行Zeta引擎本地模式的技巧

ApacheSeaTunnel發表於2024-04-23

file

轉載自小蝦米0.0

導讀:隨著Kubernetes的普及和發展,越來越多的企業和團隊開始使用Kubernetes來管理和部署應用程式。然而,Kubernetes的預設工作方式可能不是最佳的選擇,尤其是在需要更高效、更可靠的應用程式部署和管理能力時。因此,SeaTunnel提供了一種執行Zeta引擎(local-mode模式)的方法,可以讓Kubernetes在本地執行Zeta引擎,實現更高效的應用程式部署和管理。在本文中,我們將探索SeaTunnel k8s執行zeta引擎(local-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. 構建SeaTunnel映象。在安裝seatunnel的同級資料夾下建立Dockerfile。配置如下,可自行選擇版本
FROM openjdk:8

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

執行命令

docker build -t seatunnel:2.3.3 -f Dockerfile.
  1. 檢視映象
docker images

如下所示映象

file

  1. 將映象load進k8s,這裡用的minikube做演示
minikube image load seatunnel:2.3.3
minikube image ls 

檢視映象

file

  1. 建立seatunnel.streaming.conf
    如下所示
env {
  execution.parallelism = 1
  job.mode = "STREAMING"
  checkpoint.interval = 2000
}

source {
    FakeSource {
      result_table_name = "fake"
      row.num = 160000
      schema = {
        fields {
          name = "string"
          age = "int"
        }
      }
    }
}

transform {

}

sink {
  Console {}
}
  1. 建立configmap
kubectl create cm seatunnel-config \
--from-file=seatunnel.streaming.conf=seatunnel.streaming.conf
  1. 建立seatunnel.yaml如下示例
apiVersion: v1
kind: Pod
metadata:
  name: seatunneltest
spec:
  containers:
  - name: seatunnel
    image: seatunnel:2.3.3
    command: ["/bin/sh","-c","/opt/seatunnel/bin/seatunnel.sh --config /data/seatunnel.streaming.conf -e local"]
    volumeMounts:
      - name: seatunnel-config
        mountPath: /data/seatunnel.streaming.conf
        subPath: seatunnel.streaming.conf
  volumes:
        - name: seatunnel-config
          configMap:
            name: seatunnel-config
            items:
            - key: seatunnel.streaming.conf
              path: seatunnel.streaming.conf
~                                                  

執行

kubectl apply -f seatunnel.yaml

檢視pod結果如下
file
file

版權宣告:本文為博主原創文章,遵循 CC 4.0 BY-SA 版權協議,轉載請附上原文出處連結和本宣告。

原文連結:https://blog.csdn.net/weixin_41854429/article/details/132619265

本文由 白鯨開源 提供釋出支援!

相關文章