Skip to content

Commit

Permalink
Adds new service config for tf-operator (kubeflow#3408)
Browse files Browse the repository at this point in the history
* Adds new service config for tf-operator
Moves port config to tf-operator service instead of deployment
Moves Prometheus config to service as well

* Adds service file for test
Removes enablePrometheus flag

* Removes status field from tf-operator service ks test

* Spec ports from string to number
  • Loading branch information
krishnadurai authored and k8s-ci-robot committed Jun 6, 2019
1 parent 8f4bade commit 32e4190
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 24 deletions.
45 changes: 33 additions & 12 deletions kubeflow/tf-training/tests/tf-job_test.jsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -110,21 +110,9 @@ std.assertEqual(
namespace: "test-kf-001",
},
spec: {
ports: [
{
name: "monitoring-port",
port: "8443",
targetPort: "8443"
}
],
replicas: 1,
template: {
metadata: {
annotations: {
"prometheus.io/path": "/metrics",
"prometheus.io/port": "8443",
"prometheus.io/scrape": "true"
},
labels: {
name: "tf-job-operator",
},
Expand Down Expand Up @@ -181,6 +169,39 @@ std.assertEqual(
}
) &&

std.assertEqual(
tfjobv1.tfJobService,
{
apiVersion: 'v1',
kind: 'Service',
metadata: {
annotations: {
'prometheus.io/scrape': 'true',
'prometheus.io/path': '/metrics',
'prometheus.io/port': '8443',
},
labels: {
app: 'tf-job-operator',
},
name: 'tf-job-operator',
namespace: 'test-kf-001',
},
spec: {
ports: [
{
name: 'monitoring-port',
port: 8443,
targetPort: 8443,
},
],
selector: {
name: 'tf-job-operator',
},
type: 'ClusterIP',
},
}
) &&

std.assertEqual(
tfjobv1.tfUiDeployment,
{
Expand Down
44 changes: 32 additions & 12 deletions kubeflow/tf-training/tf-job-operator.libsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -157,23 +157,11 @@
},
spec: {
replicas: 1,
ports: [
{
name: "monitoring-port",
port: params.monitoringPort,
targetPort: params.monitoringPort,
},
],
template: {
metadata: {
labels: {
name: "tf-job-operator",
},
annotations: {
"prometheus.io/scrape": 'true',
"prometheus.io/path": "/metrics",
"prometheus.io/port": params.monitoringPort,
},
},
spec: {
containers: [
Expand All @@ -194,6 +182,37 @@
},
tfJobDeployment:: tfJobDeployment,

local tfJobService = {
apiVersion: "v1",
kind: "Service",
metadata: {
labels: {
app: "tf-job-operator",
},
name: params.name,
namespace: params.namespace,
annotations: {
"prometheus.io/scrape": "true",
"prometheus.io/path": "/metrics",
"prometheus.io/port": params.monitoringPort,
},
},
spec: {
ports: [
{
name: "monitoring-port",
port: std.parseInt(params.monitoringPort),
targetPort: std.parseInt(params.monitoringPort)
}
],
selector: {
name: "tf-job-operator",
},
type: "ClusterIP",
},
}, // tfJobService
tfJobService:: tfJobService,

local tfConfigMap = {
apiVersion: "v1",
data: {
Expand Down Expand Up @@ -571,6 +590,7 @@
all:: [
self.tfJobCrd,
self.tfJobDeployment,
self.tfJobService,
self.tfConfigMap,
self.tfServiceAccount,
self.tfOperatorRole,
Expand Down

0 comments on commit 32e4190

Please sign in to comment.