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

Viewer CRD controller running under namespace #1562

Merged
merged 8 commits into from
Jul 3, 2019
1 change: 1 addition & 0 deletions backend/src/crd/controller/viewer/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ go_library(
"@io_k8s_client_go//tools/clientcmd:go_default_library",
"@io_k8s_sigs_controller_runtime//pkg/builder:go_default_library",
"@io_k8s_sigs_controller_runtime//pkg/client:go_default_library",
"@io_k8s_sigs_controller_runtime//pkg/manager:go_default_library",
],
)

Expand Down
12 changes: 11 additions & 1 deletion backend/src/crd/controller/viewer/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import (
"k8s.io/client-go/tools/clientcmd"
"sigs.k8s.io/controller-runtime/pkg/builder"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/manager"

_ "k8s.io/client-go/plugin/pkg/client/auth/gcp" // Needed for GCP authentication.
)
Expand All @@ -42,6 +43,9 @@ var (
maxNumViewers = flag.Int("max_num_viewers", 50,
"Maximum number of viewer instances allowed within "+
"the cluster before the controller starts deleting the oldest one.")
namespace = flag.String("namespace", "kubeflow",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

@jingzhang36 jingzhang36 Jul 1, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done. And the default namespace is set to be "kubeflow".

"Namespace within which CRD controller is running. Default is "+
"kubeflow.")
)

func main() {
Expand All @@ -67,7 +71,13 @@ func main() {

// Create a controller that is in charge of Viewer types, and also responds to
// changes to any deployment and services that is owned by any Viewer instance.
mgr, err := builder.SimpleController().
mgr, err := manager.New(cfg, manager.Options{Namespace: *namespace})
if err != nil {
log.Fatal(err)
}

_, err = builder.SimpleController().
WithManager(mgr).
ForType(&viewerV1beta1.Viewer{}).
Owns(&appsv1.Deployment{}).
Owns(&corev1.Service{}).
Expand Down