K8s PVC 资源使用

K8s PVC 资源使用说明

当前版本 StreamX Flink-K8s 任务对 PVC 资源(挂载 checkpoint/savepoint/logs 等文件资源)的支持基于 pod-template。

Native-Kubernetes Session 由创建 Session Cluster 时控制,这里不再赘述。Native-Kubernetes Application 支持在 StreamX 页面上直接编写 pod-templatejm-pod-templatetm-pod-template 配置。

以下是一个简要的示例,假设已经提前创建 flink-checkpointflink-savepoint 两个 PVC :

k8s pvc

pod-template 配置文本如下:

  1. apiVersion: v1
  2. kind: Pod
  3. metadata:
  4. name: pod-template
  5. spec:
  6. containers:
  7. - name: flink-main-container
  8. volumeMounts:
  9. - name: checkpoint-pvc
  10. mountPath: /opt/flink/checkpoints
  11. - name: savepoint-pvc
  12. mountPath: /opt/flink/savepoints
  13. volumes:
  14. - name: checkpoint-pvc
  15. persistentVolumeClaim:
  16. claimName: flink-checkpoint
  17. - name: savepoint-pvc
  18. persistentVolumeClaim:
  19. claimName: flink-savepoint

由于使用了 rockdb-backend,该依赖可以由 3 种方式提供:

  1. 提供的 Flink Base Docker Image 已经包含该依赖(用户自行解决依赖冲突);

  2. 在 StreamX 本地 Workspace/jars 目录下放置 flink-statebackend-rocksdb_xx.jar 依赖;

  3. 在 StreamX Dependency 配置中加入 rockdb-backend 依赖(此时 StreamX 会自动解决依赖冲突):

    rocksdb dependency

在随后版本中,我们会提供一种优雅的 pod-template 配置自动生成的方式,来简化 k8s-pvc 挂载这一过程 : )