-
Notifications
You must be signed in to change notification settings - Fork 79
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[WIP] feat(serving): light weighted traffic control for inference #184
base: master
Are you sure you want to change the base?
Conversation
1f6a65f
to
99e0999
Compare
Codecov Report
@@ Coverage Diff @@
## master #184 +/- ##
==========================================
+ Coverage 21.74% 22.62% +0.88%
==========================================
Files 73 75 +2
Lines 4374 4557 +183
==========================================
+ Hits 951 1031 +80
- Misses 3292 3392 +100
- Partials 131 134 +3
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
99e0999
to
90a926b
Compare
Signed-off-by: ccchenjiahuan <[email protected]> feat(serving): add kubedl serving modifications Signed-off-by: ccchenjiahuan <[email protected]>
90a926b
to
1bdb54e
Compare
// 3) If inference serves multiple model version simultaneously and canary policy has been set, | ||
//// 4) If inference serves multiple model version simultaneously and canary policy has been set, | ||
//// serving traffic will be distributed with different ratio and routes to backend service. | ||
//if len(inference.Spec.Predictors) > 1 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove if it is not needed anymore?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok
Namespace: inf.Namespace, | ||
}, | ||
Spec: networkingv1beta1.IngressSpec{ | ||
Rules: []networkingv1beta1.IngressRule{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what's the entry host name of this ingress?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we may not need host name? The default is *, we distinguish the traffic by path
return nil | ||
} | ||
|
||
func (tc TrafficControl) ServeHTTP(w http.ResponseWriter, r *http.Request, next caddyhttp.Handler) error { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is receiver(tc
) of ServeHTTP
method intend to be a non-pointer receiver?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, l wrote this plugin according to https://caddyserver.com/docs/extending-caddy
@@ -0,0 +1,135 @@ | |||
package istio_less_ingress_controller |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks good at first glance, and it will be nicer if you add more comments :)
} | ||
|
||
// parseCaddyfile unmarshals tokens from h into a new Middleware. | ||
func parseCaddyfile(h httpcaddyfile.Helper) (caddyhttp.MiddlewareHandler, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it seems actually a no-op?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, nothing is done right now, but keep it so that there are some parameters could be added later.
type ingressCache struct { | ||
mutex sync.Mutex | ||
|
||
hostToIngressEntry map[string][]ingressEntry |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hostToIngressEntry
caches all potential hosts in-cluster and maps to a list of imgress entries (each for a predcitor), so the istio-less ingress controller seems to be a cluster scope deployment? however, each Inference
service creates it, it is expected?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I listed this point in the todo list above, it needs to be configured to watch specific ingresses related to each predcitor
@@ -335,6 +430,72 @@ func (ir *InferenceReconciler) syncServiceForInference(inf *servingv1alpha1.Infe | |||
return nil | |||
} | |||
|
|||
// syncIstioLessIngressGateway sync the istio-less ingress gateway for inference service. | |||
func (ir *InferenceReconciler) syncIstioLessIngressGateway(inf *servingv1alpha1.Inference) error { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's better to renam to caddyIngressGateway
return err | ||
} | ||
svcExists := true | ||
if err != nil && errors.IsNotFound(err) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
these two if conditions can be combined into a single if errr != nil { xxx } block
return ir.client.Create(context.Background(), &gateway) | ||
} | ||
|
||
if !reflect.DeepEqual(gateway.Spec, gatewayInCluster.Spec) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should not reset the spec every time, in case we need to manually change something.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don’t quite understand your meaning here, the trigger condition here is manually changing the spec
igExists := true | ||
igName := genPredictorName(inf, predictor) | ||
err := ir.client.Get(context.Background(), types.NamespacedName{Namespace: inf.Namespace, Name: igName}, &igInCluster) | ||
if err != nil && !errors.IsNotFound(err) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
similarly, these two if conditions can be combined into a single if err != nil {xxx}. block
@@ -22,6 +22,12 @@ import ( | |||
"github.com/alibaba/kubedl/apis/serving/v1alpha1" | |||
) | |||
|
|||
const ( | |||
CANARY_WEIGHT = "kubedl.kubernetes.io/canary-weight" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
name it kubedl.io to be consistent
// |---request---> VirtualService | ||
// |--- 90% ---> Deploy-Of-Model-A.1 | ||
// |--- 10% ---> Deploy-Of-Model-B.1 | ||
func (ir *InferenceReconciler) syncPredictorTrafficDistribution(inf *servingv1alpha1.Inference, index int, predictor *servingv1alpha1.PredictorSpec) error { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we make it pluggable such that both istio and caddy based traffic control can be configured. @SimonCqk
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, I think that would be better, it may require a global configuration
package istio_less_ingress_controller | ||
|
||
const ( | ||
CANARY_WEIGHT = "kubedl.kubernetes.io/canary-weight" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this const is duplicated in utils.go. this file can be removed
k8s.io/apimachinery v0.20.7 | ||
k8s.io/client-go v0.20.7 | ||
k8s.io/klog v1.0.0 | ||
k8s.io/utils v0.0.0-20210820185131-d34e5cb4466e // indirect |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we shouldn't have another go.mod file in a sub package ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually I think it better to be placed under a separate repo. but anyway if it is placed under the kubedl, l think it's ok because this service is more like a plugin, it should not pollute the main go.mod
|
||
go 1.15 | ||
|
||
require ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should the traffic_control package located under pkg/, instead of the root? @SimonCqk
@@ -110,7 +113,13 @@ func (ir *InferenceReconciler) Reconcile(req ctrl.Request) (ctrl.Result, error) | |||
return ctrl.Result{}, err | |||
} | |||
|
|||
// 2) Sync each predictor to deploy containers mounted with specific model. | |||
// 2) Sync istio-less ingress gateway | |||
if err = ir.syncIstioLessIngressGateway(&inference); err != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
don't call "istio-less" , call it caddyIngress to be explicit, and also the docker image name
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok
Ⅰ. Describe what this PR does
Functions currently implemented:
I have done some tests on the ingress gateway part, but haven't got a chance to test the changes with kubedl, I think we can review the gateway part first.
Functions currently known but not yet implemented:
II. Does this pull request fix one issue?
resolves #160