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

Add seldon ksonnet integration #268

Merged
merged 2 commits into from
Feb 20, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Next Next commit
add seldon ksonnet
  • Loading branch information
ukclivecox committed Feb 19, 2018
commit 113920ac8d0e89e0e379d313cfccb1b3dee23d9f
96 changes: 96 additions & 0 deletions kubeflow/seldon/core.libsonnet
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
local k = import 'k.libsonnet';
local deployment = k.extensions.v1beta1.deployment;
local container = k.apps.v1beta1.deployment.mixin.spec.template.spec.containersType;
local service = k.core.v1.service.mixin;
local serviceAccountMixin = k.core.v1.serviceAccount.mixin;
local clusterRoleBindingMixin = k.rbac.v1beta1.clusterRoleBinding.mixin;
local clusterRoleBinding = k.rbac.v1beta1.clusterRoleBinding;
local serviceAccount = k.core.v1.serviceAccount;
local baseApife = import 'json/apife-deployment.json';
local apifeService = import 'json/apife-service.json';
local operatorDeployment = import 'json/operator-deployment.json';
local redisDeployment = import 'json/redis-deployment.json';
local redisService = import 'json/redis-service.json';
local rbacServiceAccount = import 'json/rbac-service-account.json';
local rbacClusterRoleBinding = import 'json/rbac-cluster-binding.json';
local crdDefn = import 'crd.libsonnet';

{
parts(namespace):: {

apife(apifeImage,withRbac)::

local c = baseApife.spec.template.spec.containers[0] +
container.withImage(apifeImage) +
container.withImagePullPolicy("IfNotPresent");

local apiFeBase =
baseApife +
deployment.mixin.metadata.withNamespace(namespace) +
deployment.mixin.spec.template.spec.withContainers([c]);

if withRbac == "true" then
apiFeBase +
deployment.mixin.spec.template.spec.withServiceAccountName("seldon")
else
apiFeBase,


apifeService(serviceType)::

apifeService +
service.metadata.withNamespace(namespace) +
service.spec.withType(serviceType),

deploymentOperator(engineImage, clusterManagerImage, springOpts, javaOpts, withRbac):
local env = [
{ name: "JAVA_OPTS", value: javaOpts },
{ name: "SPRING_OPTS", value: springOpts },
{ name: "ENGINE_CONTAINER_IMAGE_AND_VERSION", value: engineImage },
];

local c = operatorDeployment.spec.template.spec.containers[0] +
container.withImage(clusterManagerImage) +
container.withEnvMixin(env) +
container.withImagePullPolicy("IfNotPresent");

local depOp = operatorDeployment +
deployment.mixin.metadata.withNamespace(namespace) +
deployment.mixin.spec.template.spec.withContainers([c]);

if withRbac == "true" then
depOp +
deployment.mixin.spec.template.spec.withServiceAccountName("seldon")
else
depOp,

redisDeployment():

redisDeployment +
deployment.mixin.metadata.withNamespace(namespace),

redisService():

redisService +
service.metadata.withNamespace(namespace),

rbacServiceAccount():

rbacServiceAccount +
serviceAccountMixin.metadata.withNamespace(namespace),

rbacClusterRoleBinding():

local subject = rbacClusterRoleBinding.subjects[0] +
{"namespace":namespace};

rbacClusterRoleBinding +
clusterRoleBindingMixin.metadata.withNamespace(namespace) +
clusterRoleBinding.withSubjects([subject]),

crd():

crdDefn.crd(),

}, // parts
}
254 changes: 254 additions & 0 deletions kubeflow/seldon/crd.libsonnet

Large diffs are not rendered by default.

52 changes: 52 additions & 0 deletions kubeflow/seldon/json/apife-deployment.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
{
"apiVersion": "extensions/v1beta1",
"kind": "Deployment",
"metadata": {
"name": "seldon-apiserver"
},
"spec": {
"replicas": 1,
"template": {
"metadata": {
"annotations": {
"prometheus.io/path": "/prometheus",
"prometheus.io/port": "8080",
"prometheus.io/scrape": "true"
},
"labels": {
"app": "seldon-apiserver-container-app",
"version": "1"
}
},
"spec": {
"containers": [
{
"env": [
{
"name": "SELDON_ENGINE_KAFKA_SERVER",
"value": "kafka:9092"
},
{
"name": "SELDON_CLUSTER_MANAGER_REDIS_HOST",
"value": "redis"
}
],
"image": "seldonio/apife:{{ .Values.apife.image.tag }}",
"imagePullPolicy": "{{ .Values.apife.image.pull_policy }}",
"name": "seldon-apiserver-container",
"ports": [
{
"containerPort": 8080,
"protocol": "TCP"
},
{
"containerPort": 5000,
"protocol": "TCP"
}
]
}
]
}
}
}
}
34 changes: 34 additions & 0 deletions kubeflow/seldon/json/apife-service.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"apiVersion": "v1",
"kind": "Service",
"metadata": {
"labels": {
"app": "seldon-apiserver-container-app"
},
"name": "seldon-apiserver"
},
"spec": {
"ports": [
{
"name": "http",
"port": 8080,
"protocol": "TCP",
"targetPort": 8080
},
{
"name": "grpc",
"port": 5000,
"protocol": "TCP",
"targetPort": 5000
}
],
"selector": {
"app": "seldon-apiserver-container-app"
},
"sessionAffinity": "None",
"type": "{{ .Values.apife_service_type }}"
},
"status": {
"loadBalancer": {}
}
}
73 changes: 73 additions & 0 deletions kubeflow/seldon/json/operator-deployment.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
{
"kind": "Deployment",
"apiVersion": "apps/v1beta1",
"metadata": {
"name": "seldon-cluster-manager",
"creationTimestamp": null,
"labels": {
"app": "seldon-cluster-manager-server"
}
},
"spec": {
"replicas": 1,
"selector": {
"matchLabels": {
"app": "seldon-cluster-manager-server"
}
},
"template": {
"metadata": {
"creationTimestamp": null,
"labels": {
"app": "seldon-cluster-manager-server"
}
},
"spec": {
"containers": [
{
"name": "seldon-cluster-manager-container",
"image": "seldonio/cluster-manager:1234",
"ports": [
{
"containerPort": 8080,
"protocol": "TCP"
}
],
"env": [
{
"name": "SELDON_CLUSTER_MANAGER_REDIS_HOST",
"value": "redis"
},
{
"name": "SELDON_CLUSTER_MANAGER_POD_NAMESPACE",
"valueFrom": {
"fieldRef": {
"apiVersion": "v1",
"fieldPath": "metadata.namespace"
}
}
}
],
"resources": {},
"terminationMessagePath": "/dev/termination-log",
"terminationMessagePolicy": "File",
"imagePullPolicy": "IfNotPresent"
}
],
"restartPolicy": "Always",
"terminationGracePeriodSeconds": 30,
"dnsPolicy": "ClusterFirst",
"securityContext": {},
"schedulerName": "default-scheduler"
}
},
"strategy": {
"type": "RollingUpdate",
"rollingUpdate": {
"maxUnavailable": 1,
"maxSurge": 1
}
}
},
"status": {}
}
Loading