forked from kubeflow/kubeflow
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Roll out model with istio (kubeflow#1823)
* roll out model with istio * fix test * fix test * fix test * fix test
- Loading branch information
1 parent
4957419
commit f6f46ac
Showing
6 changed files
with
134 additions
and
68 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// @apiVersion 0.1 | ||
// @name io.ksonnet.pkg.tf-serving-service | ||
// @description TensorFlow serving | ||
// @shortDescription A TensorFlow serving model | ||
// @param name string Name to give to each of the components | ||
// @optionalParam serviceType string ClusterIP The k8s service type for tf serving. | ||
// @optionalParam modelName string null The model name | ||
// @optionalParam trafficRule string v1:100 The traffic rule, in the format of version:percentage,version:percentage,.. | ||
// @optionalParam injectIstio string false Whether to inject istio sidecar; should be true or false. | ||
|
||
local k = import "k.libsonnet"; | ||
local tfservingService = import "kubeflow/tf-serving/tf-serving-service-template.libsonnet"; | ||
local util = import "kubeflow/tf-serving/util.libsonnet"; | ||
|
||
local base = tfservingService.new(env, params); | ||
util.list( | ||
[ | ||
base.tfService, | ||
] + if util.toBool(params.injectIstio) then [base.virtualService] else [], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
{ | ||
local k = import "k.libsonnet", | ||
local util = import "kubeflow/tf-serving/util.libsonnet", | ||
new(_env, _params):: { | ||
local params = _env + _params, | ||
local namespace = params.namespace, | ||
local name = params.name, | ||
local modelName = | ||
if params.modelName == "null" then | ||
params.name | ||
else | ||
params.modelName, | ||
|
||
local tfService = { | ||
apiVersion: "v1", | ||
kind: "Service", | ||
metadata: { | ||
labels: { | ||
app: modelName, | ||
}, | ||
name: name, | ||
namespace: namespace, | ||
annotations: { | ||
"getambassador.io/config": | ||
std.join("\n", [ | ||
"---", | ||
"apiVersion: ambassador/v0", | ||
"kind: Mapping", | ||
"name: tfserving-predict-mapping-" + modelName, | ||
"prefix: /tfserving/models/" + modelName, | ||
"rewrite: /v1/models/" + modelName + ":predict", | ||
"method: POST", | ||
"service: " + name + "." + namespace + ":8500", | ||
"---", | ||
"apiVersion: ambassador/v0", | ||
"kind: Mapping", | ||
"name: tfserving-predict-mapping-" + modelName + "-get", | ||
"prefix: /tfserving/models/" + modelName, | ||
"rewrite: /v1/models/" + modelName, | ||
"method: GET", | ||
"service: " + name + "." + namespace + ":8500", | ||
]), | ||
}, //annotations | ||
}, | ||
spec: { | ||
ports: [ | ||
{ | ||
name: "grpc-tf-serving", | ||
port: 9000, | ||
targetPort: 9000, | ||
}, | ||
{ | ||
name: "http-tf-serving", | ||
port: 8500, | ||
targetPort: 8500, | ||
}, | ||
], | ||
selector: { | ||
app: modelName, | ||
}, | ||
type: params.serviceType, | ||
}, | ||
}, // tfService | ||
tfService:: tfService, | ||
|
||
local versionWeights = std.split(params.trafficRule, ","), | ||
local virtualService = { | ||
apiVersion: "networking.istio.io/v1alpha3", | ||
kind: "VirtualService", | ||
metadata: { | ||
name: name, | ||
namespace: namespace, | ||
}, | ||
spec: { | ||
hosts: [ | ||
name, | ||
], | ||
http: [ | ||
{ | ||
route: [ | ||
{ | ||
destination: { | ||
host: name, | ||
subset: std.split(versionWeight, ":")[0], | ||
}, | ||
weight: std.parseInt(std.split(versionWeight, ":")[1]), | ||
} | ||
for versionWeight in versionWeights | ||
], | ||
}, | ||
], | ||
}, | ||
}, | ||
virtualService:: virtualService, | ||
}, // new | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters