Skip to content

Commit

Permalink
Seldon ksonnet refactor (kubeflow#1752)
Browse files Browse the repository at this point in the history
* Update seldon ksonnet so almost same as seldon-core repo

* update README for ksonnet json construction for seldon

* Updated seldon prototypes

* reformat jsonnet
  • Loading branch information
ukclivecox authored and k8s-ci-robot committed Oct 12, 2018
1 parent dc12b86 commit bef7458
Show file tree
Hide file tree
Showing 13 changed files with 381 additions and 77 deletions.
53 changes: 48 additions & 5 deletions kubeflow/seldon/core.libsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,12 @@ local getRedisService(x) = std.endsWith(x.metadata.name, "redis") && x.kind == "
local getServiceAccount(x) = x.kind == "ServiceAccount";
local getClusterRole(x) = x.kind == "ClusterRole";
local getClusterRoleBinding(x) = x.kind == "ClusterRoleBinding";
local getRoleBinding(x) = x.kind == "RoleBinding";
local getRole(x) = x.kind == "Role";
local getRoleBinding(x) = x.kind == "RoleBinding" && x.roleRef.name == "seldon-local";
local getAmbassadorRoleBinding(x) = x.kind == "RoleBinding" && x.roleRef.name == "ambassador";
local getSeldonRole(x) = x.metadata.name == "seldon-local" && x.kind == "Role";
local getAmbassadorRole(x) = x.metadata.name == "ambassador" && x.kind == "Role";
local getAmbassadorDeployment(x) = std.endsWith(x.metadata.name, "ambassador") && x.kind == "Deployment";
local getAmbassadorService(x) = std.endsWith(x.metadata.name, "ambassador") && x.kind == "Service";
local getEnvNotRedis(x) = x.name != "SELDON_CLUSTER_MANAGER_REDIS_HOST";

{
Expand All @@ -32,7 +36,7 @@ local getEnvNotRedis(x) = x.name != "SELDON_CLUSTER_MANAGER_REDIS_HOST";
local seldonTemplate = if std.startsWith(seldonVersion, "0.1") then seldonTemplate1 else seldonTemplate2;

{
apife(apifeImage, withRbac)::
apife(apifeImage, withRbac, grpcMaxMessageSize)::

local baseApife = std.filter(getApifeDeployment, seldonTemplate.items)[0];

Expand Down Expand Up @@ -61,10 +65,13 @@ local getEnvNotRedis(x) = x.name != "SELDON_CLUSTER_MANAGER_REDIS_HOST";
deployment.mixin.metadata.withLabelsMixin(labels) +
deployment.mixin.spec.template.spec.withContainers([c]);

local extraAnnotations = { "seldon.io/grpc-max-message-size": grpcMaxMessageSize };

// Ensure labels copied to enclosed parts
local apiFeBase = apiFeBase1 +
deployment.mixin.spec.selector.withMatchLabels(apiFeBase1.metadata.labels) +
deployment.mixin.spec.template.metadata.withLabels(apiFeBase1.metadata.labels);
deployment.mixin.spec.template.metadata.withLabels(apiFeBase1.metadata.labels) +
deployment.mixin.spec.template.metadata.withAnnotationsMixin(extraAnnotations);


if withRbac == "true" then
Expand Down Expand Up @@ -177,7 +184,15 @@ local getEnvNotRedis(x) = x.name != "SELDON_CLUSTER_MANAGER_REDIS_HOST";

rbacRole():

local role = std.filter(getRole, seldonTemplate.items)[0];
local role = std.filter(getSeldonRole, seldonTemplate.items)[0];

role +
roleMixin.metadata.withNamespace(namespace),


rbacAmbassadorRole():

local role = std.filter(getAmbassadorRole, seldonTemplate.items)[0];

role +
roleMixin.metadata.withNamespace(namespace),
Expand Down Expand Up @@ -205,6 +220,34 @@ local getEnvNotRedis(x) = x.name != "SELDON_CLUSTER_MANAGER_REDIS_HOST";
roleBindingMixin.metadata.withNamespace(namespace) +
roleBinding.withSubjects([subject]),

rbacAmbassadorRoleBinding():

local rbacRoleBinding = std.filter(getAmbassadorRoleBinding, seldonTemplate.items)[0];

local subject = rbacRoleBinding.subjects[0]
{ namespace: namespace };

rbacRoleBinding +
roleBindingMixin.metadata.withNamespace(namespace) +
roleBinding.withSubjects([subject]),

ambassadorDeployment():

local ambassadorDeployment = std.filter(getAmbassadorDeployment, seldonTemplate.items)[0];

ambassadorDeployment +
deployment.mixin.metadata.withName(name + "-ambassador") +
deployment.mixin.metadata.withNamespace(namespace),


ambassadorService():

local ambassadorService = std.filter(getAmbassadorService, seldonTemplate.items)[0];

ambassadorService +
service.metadata.withName(name + "-ambassador") +
service.metadata.withNamespace(namespace),

crd():

if std.startsWith(seldonVersion, "0.1") then crdDefn.crd1() else crdDefn.crd2(),
Expand Down
4 changes: 2 additions & 2 deletions kubeflow/seldon/json/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ The template_0.2.json is generated using:

```
git clone --branch release-0.2 git@github.com:SeldonIO/seldon-core.git seldon-core-release-0.2
helm template seldon-core-release-0.2/helm-charts/seldon-core > template_0.2.yaml
helm template --set ambassador.enabled=true seldon-core-release-0.2/helm-charts/seldon-core > template_0.2.yaml
kubectl convert -f template_0.2.yaml -o json > template_0.2.json
rm template_0.2.yaml
```
Expand All @@ -13,7 +13,7 @@ The template_0.1.json is generated using:

```
git clone --branch release-0.1 git@github.com:SeldonIO/seldon-core.git seldon-core-release-0.1
helm template seldon-core-release-0.1/helm-charts/seldon-core > template_0.1.yaml
helm template --set ambassador.enabled=true seldon-core-release-0.1/helm-charts/seldon-core > template_0.1.yaml
kubectl convert -f template_0.1.yaml -o json > template_0.1.json
rm template_0.1.yaml
```
16 changes: 7 additions & 9 deletions kubeflow/seldon/json/template_0.1.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
"apiVersion": "v1",
"metadata": {
"name": "seldon",
"namespace": "kubeflow-seldon",
"creationTimestamp": null
}
},
Expand All @@ -17,14 +16,13 @@
"apiVersion": "rbac.authorization.k8s.io/v1",
"metadata": {
"name": "seldon",
"namespace": "kubeflow-seldon",
"creationTimestamp": null
},
"subjects": [
{
"kind": "ServiceAccount",
"name": "seldon",
"namespace": "kubeflow-seldon"
"namespace": "seldon"
}
],
"roleRef": {
Expand All @@ -38,7 +36,6 @@
"apiVersion": "apps/v1",
"metadata": {
"name": "seldon-cluster-manager",
"namespace": "kubeflow-seldon",
"creationTimestamp": null,
"labels": {
"app": "seldon-cluster-manager-server"
Expand Down Expand Up @@ -115,7 +112,8 @@
"maxUnavailable": 1,
"maxSurge": 1
}
}
},
"progressDeadlineSeconds": 2147483647
},
"status": {}
},
Expand All @@ -124,7 +122,6 @@
"apiVersion": "apps/v1",
"metadata": {
"name": "redis",
"namespace": "kubeflow-seldon",
"creationTimestamp": null,
"labels": {
"app": "redis-app"
Expand Down Expand Up @@ -174,7 +171,8 @@
"maxUnavailable": 1,
"maxSurge": 1
}
}
},
"progressDeadlineSeconds": 2147483647
},
"status": {}
},
Expand Down Expand Up @@ -208,7 +206,6 @@
"apiVersion": "apps/v1",
"metadata": {
"name": "seldon-apiserver",
"namespace": "kubeflow-seldon",
"creationTimestamp": null,
"labels": {
"app": "seldon-apiserver-container-app",
Expand Down Expand Up @@ -291,7 +288,8 @@
"maxUnavailable": 1,
"maxSurge": 1
}
}
},
"progressDeadlineSeconds": 2147483647
},
"status": {}
},
Expand Down
Loading

0 comments on commit bef7458

Please sign in to comment.