Open ryanzhang-oss opened 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.
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.
@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.
More improvements
Our current implementation allows a
workloadDefinition
to directly reference anything with a GVK. This means one can also create aworkloadDefinition
that references adeployment
orstatefulSet
. Therefore,ManualScalarTrait
should check if it can directly apply to the workload when there is nochildResourceKind
.In addition,
ManualScalarTrait
should be able to apply to more than justDeployment
. Ideally, it can apply to any resources that have aspec.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.