1.将seatunnel上传至服务器上。我之前已经解压并执行过install-plugin.sh,这里为了方便,我直接用的执行过install-plugin.sh脚本之后的seatunnel做演示。
执行过install-plugin后的lib目录包含如下
在这里插入图片描述

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

2.构建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 .

3.查看镜像


docker images

如下所示镜像
在这里插入图片描述

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

minikube image load seatunnel:2.3.3
minikube image ls 

查看镜像
在这里插入图片描述

6.创建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 {}
}

7.创建configmap

kubectl create cm seatunnel-config \
--from-file=seatunnel.streaming.conf=seatunnel.streaming.conf

8.创建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结果如下

在这里插入图片描述

在这里插入图片描述

Logo

K8S/Kubernetes社区为您提供最前沿的新闻资讯和知识内容

更多推荐