背景
服务器配置
| 节点 | 内网IP | 公网IP | 配置 |
|---|---|---|---|
| ds-2 | 10.80.239.78 | 8C16G | |
| ds-8 | 10.80.239.84 | 8C16G | |
| ds-9 | 10.80.239.85 | 8C16G | |
| ds-10 | 10.80.239.86 | 8C16G | |
| ds-11 | 10.80.239.87 | 8C16G |
软件版本
| 软件 | 版本 |
|---|---|
| centos | 7.6 |
| docker | 20.10.7 |
| docker-compose | 2.2.3 |
| kubelet | 1.20.9 |
| kubeadm | 1.20.9 |
| kubectl | 1.20.9 |
| harbor | 2.6.0 |
| helm | 3.5.4 |
| seatunnel |
镜像版本
| 镜像 | 版本 |
|---|---|
| k8s.gcr.io/kube-apiserver | 1.20.9 |
| k8s.gcr.io/kube-controller-manager | 1.20.9 |
| k8s.gcr.io/kube-scheduler | 1.20.9 |
| k8s.gcr.io/kube-proxy | 1.20.9 |
| k8s.gcr.io/pause | 3.2 |
| k8s.gcr.io/etcd | 3.4.13-0 |
| k8s.gcr.io/coredns | 1.7.0 |
创建初始文件夹
#/Users/keyboardone/同步空间/softwaremkdir -p /opt/softwarecd /opt/software/k8s/chmod 755 /opt/software/k8s/*.sh
前置工作
安装docker
安装k8s
安装helm
安装seatunnel
参考官网:https://seatunnel.apache.org/docs/2.1.1/start/kubernetes
seatunnel版本:2.1.1
下载镜像
编辑Dockerfile
vi Dockerfile
FROM flink:1.13ENV SEATUNNEL_VERSION="2.1.0"RUN wget https://archive.apache.org/dist/incubator/seatunnel/${SEATUNNEL_VERSION}/apache-seatunnel-incubating-${SEATUNNEL_VERSION}-bin.tar.gzRUN tar -xzvf apache-seatunnel-incubating-${SEATUNNEL_VERSION}-bin.tar.gzRUN mkdir -p $FLINK_HOME/usrlibRUN cp apache-seatunnel-incubating-${SEATUNNEL_VERSION}/lib/seatunnel-core-flink.jar $FLINK_HOME/usrlib/seatunnel-core-flink.jarRUN rm -fr apache-seatunnel-incubating-${SEATUNNEL_VERSION}*
构建
docker build -t seatunnel:2.1.0-flink-1.13 -f Dockerfile .
加载镜像到minikube
minikube image load seatunnel:2.1.0-flink-1.13
k8s安装cert文件
#下载wget https://github.com/jetstack/cert-manager/releases/download/v1.7.1/cert-manager.yaml#部署kubectl create -f cert-manager.yaml
helm安装Flink Kubernetes Operator
helm repo add flink-operator-repo https://downloads.apache.org/flink/flink-kubernetes-operator-0.1.0/helm install flink-kubernetes-operator flink-operator-repo/flink-kubernetes-operator
验证
验证pod进程
#alias kubectl="minikube kubectl --"kubectl get pod -A
验证seatunnel应用
构造虚拟数据流
vi flink.streaming.conf#新增如下内容env {execution.parallelism = 1}source {FakeSourceStream {result_table_name = "fake"field_name = "name,age"}}transform {sql {sql = "select name,age from fake"}}sink {ConsoleSink {}}
拷贝配置文件到nfs目录下
编写seatunnel的yaml部署文件
vi seatunnel-flink.yaml
新增如下内容
apiVersion: flink.apache.org/v1alpha1kind: FlinkDeploymentmetadata:namespace: defaultname: seatunnel-flink-streaming-examplespec:#image: seatunnel:2.1.0-flink-1.13image: ren:8088/keyboardone/seatunnel:2.1.0-flink-1.13flinkVersion: v1_14flinkConfiguration:taskmanager.numberOfTaskSlots: "2"serviceAccount: flinkjobManager:replicas: 1resource:memory: "2048m"cpu: 1taskManager:resource:memory: "2048m"cpu: 2podTemplate:spec:containers:- name: flink-main-containervolumeMounts:- mountPath: /dataname: config-volumevolumes:- name: config-volumehostPath:path: "/nfs/data"type: Directoryjob:jarURI: local:///opt/flink/usrlib/seatunnel-core-flink.jarentryClass: org.apache.seatunnel.SeatunnelFlinkargs: ["--config", "/data/flink.streaming.conf"]parallelism: 2upgradeMode: stateless
执行部署
kubectl apply -f seatunnel-flink.yaml
验证
验证服务
kubectl get svc
查看日志
kubectl logs -f deploy/seatunnel-flink-streaming-example
暴露端口
kubectl port-forward svc/seatunnel-flink-streaming-example-rest 8081
Now the Flink Dashboard is accessible at localhost:8081.
打印日志
kubectl logs \-l 'app in (seatunnel-flink-streaming-example), component in (taskmanager)' \--tail=-1 \-f
删除部署
kubectl delete -f seatunnel-flink.yaml
