open-cluster-management-io / ocm

Core components in the OCM project. Report here if you found any issues in OCM.
https://open-cluster-management.io
Apache License 2.0
737 stars 92 forks source link

Can I create work by using native K8s API? #12

Closed cvvz closed 1 year ago

cvvz commented 2 years ago

I want to create work like deployment by using K8s API but not a WorkManifest with template in it, just like what kubefedV2, karmada or clusternet does. Is it possible?

qiujian16 commented 2 years ago

I do not think kubefedv2, karmada and clusternet has a similar API to deploy workload? Do you ask an API that in higher level primitive which you can define "I want to create deployment in a set of clusters". Or do you want a way that you can directly call deployment API in a spoke cluster?

cvvz commented 2 years ago

Use karmada as an example, if I want to create deployment across multiple clusters. I can use the native deployment API of k8s in hub cluster, the components of karmada will do reconciling, and generate ResourceBindingSpec as a result, which is similar to the concept of work in work-api. Is it possible to use OCM the same way? That is, use k8s native API in hub cluster directly rather than use ManifestWork directly.

qiujian16 commented 2 years ago

oh, we do not do it in ocm core component. But it is possible to develop an extension to do that. There is a proposal by @yue9944882 https://github.com/open-cluster-management-io/enhancements/pull/31 that may be able to support this case.

We try to avoid normalizing the interface of the end user in ocm core part, since we see a bunch of different ways users can deliver workload (native way, gitops way, helm way etc.). Instead the ocm core component is trying to provide an interface that other more user oriented interfaces can easily plug in.

cvvz commented 2 years ago

Got it! Does it mean that I can create an add-on through addon-framework or a third-party system(i.e., higher primitive) writen by myself (as long as it can transform a native resource to manifestwork) to support my case?

qiujian16 commented 2 years ago

That is for sure!

yue9944882 commented 2 years ago

weeks ago i had a poc implementation of the enhancement above, now it's holding on the status-reporting feature by the work api from https://github.com/open-cluster-management-io/api/pull/108 b/c the advance workload distribution needs to actively reading the existence/status from the distributed resources. the new api proposed in the enhancement allows users to "import" an existing workload resource from the hub cluster as the template then replicate them to the selected managed clusters and the imported native workload will be automatically packed into a work api.

btw i am also thinking of another approach to convert native api to work -- by a custom kustomize generator plugin, the plugin should be packing all the resources under the kustomize folders to a single work resource.

github-actions[bot] commented 1 year ago

This issue is stale because it has been open for 120 days with no activity. After 14 days of inactivity, it will be closed. Remove the stable label to prevent this issue from being closed.