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

katib should be able to be deployed in any namespace #324

Merged
merged 1 commit into from
Jan 15, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
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
4 changes: 2 additions & 2 deletions cmd/metricscollector/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ import (
"flag"
"log"

"github.com/kubeflow/katib/pkg"
api "github.com/kubeflow/katib/pkg/api"
"github.com/kubeflow/katib/pkg/manager/metricscollector"

Expand All @@ -54,11 +53,12 @@ var trialID = flag.String("t", "", "Trial ID")
var workerID = flag.String("w", "", "Worker ID")
var workerKind = flag.String("k", "", "Worker Kind")
var namespace = flag.String("n", "", "NameSpace")
var managerSerivce = flag.String("m", "", "Vizier Manager service")

func main() {
flag.Parse()
log.Printf("Study ID: %s, Trial ID: %s, Worker ID: %s, Worker Kind: %s", *studyID, *trialID, *workerID, *workerKind)
conn, err := grpc.Dial(pkg.ManagerAddr, grpc.WithInsecure())
conn, err := grpc.Dial(*managerSerivce, grpc.WithInsecure())
if err != nil {
log.Fatalf("could not connect: %v", err)
}
Expand Down
2 changes: 2 additions & 0 deletions manifests/studyjobcontroller/metricsControllerConfigMap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,6 @@ data:
- "{{.WorkerKind}}"
- "-n"
- "{{.NameSpace}}"
- "-m"
- "{{.ManagerSerivce}}"
restartPolicy: Never
5 changes: 5 additions & 0 deletions manifests/studyjobcontroller/studyjobcontroller.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,8 @@ spec:
- name: studyjob-controller
image: katib/studyjob-controller
imagePullPolicy: Always
env:
- name: VIZIER_CORE_NAMESPACE
valueFrom:
fieldRef:
fieldPath: metadata.namespace
2 changes: 2 additions & 0 deletions pkg/controller/studyjob/manifest_parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (

katibapi "github.com/kubeflow/katib/pkg/api"
katibv1alpha1 "github.com/kubeflow/katib/pkg/api/operators/apis/studyjob/v1alpha1"
"github.com/kubeflow/katib/pkg"
"github.com/kubeflow/katib/pkg/manager/studyjobclient"

"k8s.io/apimachinery/pkg/util/uuid"
Expand Down Expand Up @@ -147,6 +148,7 @@ func getMetricsCollectorManifest(studyID string, trialID string, workerID string
"WorkerID": workerID,
"WorkerKind": workerKind,
"NameSpace": namespace,
"ManagerSerivce": pkg.GetManagerAddr(),
}
mctp := "defaultMetricsCollectorTemplate.yaml"
if mcs != nil {
Expand Down
26 changes: 25 additions & 1 deletion pkg/types.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,29 @@
package pkg

import (
"os"
)

const (
ManagerAddr = "vizier-core.kubeflow:6789"
VizierServiceIPEnvName = "VIZIER_CORE_PORT_6789_TCP_ADDR"
VizierServicePortEnvName = "VIZIER_CORE_PORT_6789_TCP_PORT"
VizierServiceNamespaceEnvName = "VIZIER_CORE_NAMESPACE"
VizierService = "vizier-core"
VizierPort = "6789"
ManagerAddr = VizierService + ":" + VizierPort
)

func GetManagerAddr() string {
ns := os.Getenv(VizierServiceNamespaceEnvName)
if len(ns) == 0 {
addr := os.Getenv(VizierServiceIPEnvName)
port := os.Getenv(VizierServicePortEnvName)
if len(addr) > 0 && len(port) > 0 {
return addr + ":" + port
} else {
return ManagerAddr
}
} else {
return VizierService + "." + ns + ":"+ VizierPort
}
}