Add a component to run TensorBoard. (#110)

* Add a component to run TensorBoard.

* Autoformate jsonnet file.

* * Set a default of "" for logDir; there's not a really good default location
  because it will depend on where the data is stored.
This commit is contained in:
Jeremy Lewi 2018-04-29 20:34:16 -07:00 committed by k8s-ci-robot
parent e12231bae3
commit afdd4c544e
2 changed files with 96 additions and 0 deletions

View File

@ -46,6 +46,13 @@
},
tensor2tensor: {
namespace: "null",
},
tensorboard: {
image: "tensorflow/tensorflow:1.7.0",
// logDir needs to be overwritten based on where the data is
// actually stored.
logDir: "",
name: "gh",
},
tfjob: {
namespace: "null",

View File

@ -0,0 +1,89 @@
local env = std.extVar("__ksonnet/environments");
local params = std.extVar("__ksonnet/params").components.tensorboard;
local k = import "k.libsonnet";
local name = params.name;
local namespace = env.namespace;
local service = {
apiVersion: "v1",
kind: "Service",
metadata: {
name: name + "-tb",
namespace: env.namespace,
annotations: {
"getambassador.io/config":
std.join("\n", [
"---",
"apiVersion: ambassador/v0",
"kind: Mapping",
"name: " + name + "_mapping",
"prefix: /tensorboard/" + name + "/",
"rewrite: /",
"service: " + name + "-tb." + namespace,
]),
}, //annotations
},
spec: {
ports: [
{
name: "http",
port: 80,
targetPort: 80,
},
],
selector: {
app: "tensorboard",
"tb-job": name,
},
},
};
local deployment = {
apiVersion: "apps/v1beta1",
kind: "Deployment",
metadata: {
name: name + "-tb",
namespace: env.namespace,
},
spec: {
replicas: 1,
template: {
metadata: {
labels: {
app: "tensorboard",
"tb-job": name,
},
name: name,
namespace: namespace,
},
spec: {
containers: [
{
command: [
"/usr/local/bin/tensorboard",
"--logdir=" + params.logDir,
"--port=80",
],
image: params.image,
name: "tensorboard",
ports: [
{
containerPort: 80,
},
],
// "livenessProbe": {
// "httpGet": {
// "path": "/",
// "port": 80
// },
// "initialDelaySeconds": 15,
// "periodSeconds": 3
// }
},
],
},
},
},
};
std.prune(k.core.v1.list.new([service, deployment]))