版本:v1.8

flink-kubernetes-operator

Apache Flink (https://github.com/apache/flink-kubernetes-operator) 的 Kubernetes operator,它允许用户通过 kubectl 等原生 k8s 工具来管理 Flink 应用程序及其生命周期。

  1. vela addon enable flink-kubernetes-operator
  1. vela addon disable flink-kubernetes-operator

由于这个插件依赖于fluxcdcert-manager插件,所以会自动启用它们。执行下面的命令来检查它们的状态:

  1. $ vela ls -n vela-system
  2. APP COMPONENT TYPE TRAITS PHASE HEALTHY STATUS CREATED-TIME
  3. addon-cert-manager cert-manager helm running healthy Fetch repository successfully, Create helm release 2022-06-16 11:50:19 +0800 CST
  4. successfully
  5. addon-flink-kubernetes-operator flink-namespace raw running healthy 2022-06-16 11:50:20 +0800 CST
  6. └─ flink-operator helm running healthy Fetch repository successfully, Create helm release 2022-06-16 11:50:20 +0800 CST
  7. successfully
  8. addon-fluxcd flux-system-namespace raw running healthy 2022-06-16 11:47:07 +0800 CST
  9. └─ fluxcd-resources k8s-objects running healthy 2022-06-16 11:47:07 +0800 CST

通过显示flink-cluster组件的字段类型,让我们知道如何在一个应用程序中使用它们。 作为 flink 用户,你可以选择它们作为你的 flink 集群的设置参数。

  1. vela show flink-cluster
  2. # Properties
  3. +--------------+-------------+--------+----------+---------------------------------------------------------------+
  4. | NAME | DESCRIPTION | TYPE | REQUIRED | DEFAULT |
  5. +--------------+-------------+--------+----------+---------------------------------------------------------------+
  6. | name | | string | true | |
  7. | namespace | | string | true | |
  8. | nots | | string | true | 2 |
  9. | flinkVersion | | string | true | v1_14 |
  10. | image | | string | true | flink:latest |
  11. | jarURI | | string | true | local:///opt/flink/examples/streaming/StateMachineExample.jar |
  12. | parallelism | | int | true | 2 |
  13. | upgradeMode | | string | true | stateless |
  14. | replicas | | int | true | 1 |
  15. | jmcpu | | int | true | 1 |
  16. | jmmem | | string | true | 1024m |
  17. | tmcpu | | int | true | 1 |
  18. | tmmem | | string | true | 1024m |
  19. +--------------+-------------+--------+----------+---------------------------------------------------------------+

首先请确保你的集群已经存在命名空间flink-home

然后部署下面的应用:

  1. cat <<EOF | vela up -f -
  2. apiVersion: core.oam.dev/v1beta1
  3. kind: Application
  4. metadata:
  5. name: flink-app-v1
  6. spec:
  7. components:
  8. - name: my-flink-component
  9. type: flink-cluster
  10. properties:
  11. name: my-flink-cluster
  12. namespace: flink-home
  13. EOF

检查相关资源的状态:

  1. vela status flink-app-v1
  2. About:
  3. Name: flink-app-v1
  4. Created at: 2022-04-22 17:33:51 +0800 CST
  5. Status: running
  6. Workflow:
  7. mode: DAG
  8. finished: true
  9. Suspend: false
  10. Terminated: false
  11. Steps
  12. - id:n6na24x6dr
  13. name:my-flink-component
  14. type:apply-component
  15. phase:succeeded
  16. message:
  17. Services:
  18. - Name: my-flink-component
  19. Cluster: local Namespace: default
  20. Type: flink-cluster
  21. Healthy
  22. No trait applied

你会看到你的第一个 flink-cluster 应用已经处于运行状态了。

Last updated on 2023年5月6日 by Tianxin Dong