incubator-streampark icon indicating copy to clipboard operation
incubator-streampark copied to clipboard

[Feature] k8s multi-cluster management, while supporting multi-cluster namespace management

Open MonsterChenzhuo opened this issue 3 years ago • 1 comments

Search before asking

  • [X] I had searched in the feature and found no similar feature requirement.

Description

k8s multi-cluster management, while supporting multi-cluster namespace management. By implementing the current issues, we can better manage our flink applications to run in that namespace on that k8s cluster. General scenario, test one cluster and production one cluster. We can switch to our production environment with one click in the test environment. Let your whole development, debugging, full lifecycle be done on streampark. All our connector configurations are unified and managed through variables. Test one set of configurations to produce one set of configurations. When you finish the testing phase and release it online, just click the button, the sql logic will not need to be modified at all, but the task will change from writing the test library table, to writing the production library table

Usage Scenario

通过实现当前这个issues可以起到一个更好的去管理我们flink作业效果,他能指定flink作业运行的k8s集群,以及自定义的去创建命名空间。 例如:一个标准场景,企业的k8s集群,通常是测试一套集群,生产一套集群,我们可以在测试环境中进行任务的编写、调试、压力测试、数据效验,当通过一系列的“考验”之后,在将其“搬移”到生产环境,这个搬移,大概率会带来sql的反复粘贴、修改,这样的操作进行下来,即麻烦同样也可能带来一些新的问题:少粘、误粘、修改连接器配置、误改。

通过当前这个issues所赋予的能力,我们可以完整的控制flink任务所提交的集群,在配合连接器通过变量统一控制方式[issue-1477],我们可以做到:通过功能按钮🔘一键的切换,将测试环境变为生产环境。使你的整个开发、调试、全生命周期都在streampark上完成。当我们所有的连接器配置都通过变量的形式统一管理,测试一套配置,生产一套配置。当你完成测试阶段,发布上线,只需点击按钮,sql的逻辑完全不需要进行修改,但是任务会从写测试库表,变为写生产库表。

实现逻辑

通过t_k8s_cluster来描述和存储k8s环境 内部要定义一个K8sManager的类, 通过查询、更新数据库存储来获取当前软件那套环境的k8sConfig

Cluster cluster = clusterMapper.queryByClusterCode(clusterCode);  // 查询数据库
String k8sConfig = ClusterConfUtils.getK8sConfig(cluster.getConfig());

通过

DefaultKubernetesClient client = getClient(k8sConfig);

动态去产生一个KubernetesClient 来替换历史的DefaultKubernetesClient【默认取的是宿主机k8sConfig】方法 图片 从而实现动态切换k8s集群

Related issues

1.namespace管理:包括按需创建:可以按照指定的内存大小、cpu核心数去创建命名空间,编辑。对标yarn的队列效果 2.k8s集群管理 3.手动、定时、自动 hpa集群或task扩缩容 4.手动、定时、自动 vpa对task的内存进行扩缩容

Are you willing to submit a PR?

  • [X] Yes I am willing to submit a PR!

Code of Conduct

MonsterChenzhuo avatar Oct 05 '22 15:10 MonsterChenzhuo

Very good proposal. But this feature will not be added in the current version(1.2.4), it can be planned in next versions.

wolfboys avatar Oct 07 '22 02:10 wolfboys