crossplane / addon-oam-kubernetes-local

Run OAM workloads on a Kubernetes cluster.
Apache License 2.0
21 stars 15 forks source link

Allow ManualScalarTrait to apply to workload directly and use duck typing #43

Open ryanzhang-oss opened 4 years ago

ryanzhang-oss commented 4 years ago

Our current implementation allows a workloadDefinition to directly reference anything with a GVK. This means one can also create a workloadDefinition that references a deployment or statefulSet. Therefore, ManualScalarTrait should check if it can directly apply to the workload when there is no childResourceKind.

In addition, ManualScalarTrait should be able to apply to more than just Deployment. Ideally, it can apply to any resources that have a spec.replicas field that controls the number of instances of the resource.

The tricky part is to know what the spec.replicas field actually means in different resources.

ryanzhang-oss commented 4 years ago

The first step can be that we just list a few known K8s native resources that have a spec.replicas field that controls the number of Pod instance.

ryanzhang-oss commented 4 years ago

After sync with @n3wScott, I realized that KNative duck type actually requires that same schema means the same across the resource space. We might need to consider restrictions like this in OAM but I am not sure if it's practical as OAM is totally open. Just to be clear, ManualScalarTrait already writes duck type style to scale the deployment so it doesn't require much change other than opening up the resources it can apply to.

resouer commented 4 years ago

@ryanzhang-oss I would +1 to explore opening up the resources a given trait can apply to. This sound align with appliesTo semantic of traits as well.

Another use case is the generic rollout trait/controller (Flagger based) EDAS is working on, as well as Service Binding which hopes to inject data into various workloads.

ryanzhang-oss commented 4 years ago

More improvements