Skip to content
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

gRPC load balancing via Ambassador #390

Merged
merged 1 commit into from
Jan 15, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,5 @@ public class Constants {
public static final String ENGINE_SEPARATE_ANNOTATION = "seldon.io/engine-separate-pod";
public static final String REST_READ_TIMEOUT_ANNOTATION = "seldon.io/rest-read-timeout";
public static final String GRPC_READ_TIMEOUT_ANNOTATION = "seldon.io/grpc-read-timeout";
public static final String HEADLESS_SVC_ANNOTATION = "seldon.io/headless-svc";
}
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,7 @@ public SeldonDeployment defaulting(SeldonDeployment mlDep) {
SeldonDeployment.Builder mlBuilder = SeldonDeployment.newBuilder(mlDep);
String deploymentName = mlDep.getMetadata().getName();
final boolean separateEnginePod = SeldonDeploymentUtils.hasSeparateEnginePodAnnotation(mlDep);

final String namespace = (StringUtils.isEmpty(mlDep.getMetadata().getNamespace())) ? "default" : mlDep.getMetadata().getNamespace();

for(int pbIdx=0;pbIdx<mlDep.getSpec().getPredictorsCount();pbIdx++)
Expand Down Expand Up @@ -810,7 +811,8 @@ public DeploymentResources createResources(SeldonDeployment mlDep) throws Seldon
}
}

Service s = Service.newBuilder()
final boolean headlessSvc = SeldonDeploymentUtils.hasHeadlessSvcAnnotation(mlDep);
Service.Builder svcBuilder = Service.newBuilder()
.setMetadata(ObjectMeta.newBuilder()
.setName(serviceLabel)
.putLabels(LABEL_SELDON_APP, serviceLabel)
Expand All @@ -831,12 +833,15 @@ public DeploymentResources createResources(SeldonDeployment mlDep) throws Seldon
.setTargetPort(IntOrString.newBuilder().setIntVal(clusterManagerProperites.getEngineGrpcContainerPort()))
.setName("grpc")
)
.setType("ClusterIP")
.putSelector(SeldonDeploymentOperatorImpl.LABEL_SELDON_APP,serviceLabel)
)
.build();

services.add(s);
);
if (headlessSvc)
{
logger.info("Creating headless service for ",mlDep.getSpec().getName());
svcBuilder.getSpecBuilder().setClusterIP("None");
}

services.add(svcBuilder.build());



Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,4 +72,9 @@ public static boolean hasSeparateEnginePodAnnotation(SeldonDeployment mlDep)
return Boolean.parseBoolean(mlDep.getSpec().getAnnotationsOrDefault(Constants.ENGINE_SEPARATE_ANNOTATION, "false"));
}

public static boolean hasHeadlessSvcAnnotation(SeldonDeployment mlDep)
{
return Boolean.parseBoolean(mlDep.getSpec().getAnnotationsOrDefault(Constants.HEADLESS_SVC_ANNOTATION, "false"));
}

}
3 changes: 3 additions & 0 deletions docs/annotations.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ You can configure aspects of Seldon Core via annotations in the SeldonDeployment
* ```seldon.io/engine-separate-pod``` : Use a separate pod for the service orchestrator
* Locations : SeldonDeployment.spec.annotations
* [Example](../notebooks/resources/model_svcorch_sep.json)
* ```seldon.io/headless-svc``` : Run main endpoint as headless kubernetes service. This is required for gRPC load balancing via Ambassador.
* Locations : SeldonDeployment.spec.annotations
* [Example](../notebooks/resources/grpc_load_balancing_ambassador.json)

## API OAuth Gateway Annotations
The API OAuth Gateway, if used, can also have the following annotations:
Expand Down
52 changes: 52 additions & 0 deletions notebooks/resources/grpc_load_balancing_ambassador.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
{
"apiVersion": "machinelearning.seldon.io/v1alpha2",
"kind": "SeldonDeployment",
"metadata": {
"labels": {
"app": "seldon"
},
"name": "seldon-model"
},
"spec": {
"annotations": {
"seldon.io/headless-svc":"true"
},
"name": "test-deployment",
"oauth_key": "oauth-key",
"oauth_secret": "oauth-secret",
"predictors": [
{
"componentSpecs": [{
"spec": {
"containers": [
{
"image": "seldonio/mock_classifier_grpc:1.0",
"imagePullPolicy": "IfNotPresent",
"name": "classifier",
"resources": {
"requests": {
"memory": "1Mi"
}
}
}
],
"terminationGracePeriodSeconds": 1
}
}],
"graph": {
"children": [],
"name": "classifier",
"endpoint": {
"type" : "GRPC"
},
"type": "MODEL"
},
"name": "example",
"replicas": 4,
"labels": {
"version" : "v1"
}
}
]
}
}