Skip to content

Commit

Permalink
Viewer CRD controller running under namespace (#1562)
Browse files Browse the repository at this point in the history
* Viewer CRD controller running under namespace

* Change docker file and add manifest deployment yaml to support the new flag namespace

* Change docker file to support new flag namespace for viewer crd controller

* Modify kustomization.yaml and namespaced-install.yaml

* Change file name from ml-pipeline-viewer-crd-deployment to ml-pipeline-viewer-crd-deployment-patch

* Fix typo

* Remove some duplicate configs in namespaced-install
  • Loading branch information
jingzhang36 authored and k8s-ci-robot committed Jul 3, 2019
1 parent f64782c commit b957a98
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 2 deletions.
3 changes: 2 additions & 1 deletion backend/Dockerfile.viewercontroller
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,6 @@ COPY --from=builder /src/github.com/kubeflow/pipelines/third_party/license.txt /
RUN chmod +x /bin/controller

ENV MAX_NUM_VIEWERS "50"
ENV NAMESPACE "kubeflow"

CMD /bin/controller -alsologtostderr=true -max_num_viewers=${MAX_NUM_VIEWERS}
CMD /bin/controller -alsologtostderr=true -max_num_viewers=${MAX_NUM_VIEWERS} --namespace=${NAMESPACE}
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",
"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
2 changes: 2 additions & 0 deletions manifests/namespaced-install.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -759,6 +759,8 @@ spec:
- env:
- name: MAX_NUM_VIEWERS
value: "50"
- name: NAMESPACE
value: kubeflow
image: gcr.io/ml-pipeline/viewer-crd-controller:0.1.23
imagePullPolicy: Always
name: ml-pipeline-viewer-crd
Expand Down
1 change: 1 addition & 0 deletions manifests/namespaced-install/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ patchesStrategicMerge:
- workflow-controller-configmap.yaml
- ml-pipeline-persistenceagent-deployment-patch.yaml
- ml-pipeline-scheduledworkflow-deployment-patch.yaml
- ml-pipeline-viewer-crd-deployment-patch.yaml
- ml-pipeline-ui-deployment-patch.yaml

vars:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
apiVersion: apps/v1beta2
kind: Deployment
metadata:
name: ml-pipeline-viewer-crd
spec:
template:
spec:
containers:
- name: ml-pipeline-viewer-crd
env:
- name: NAMESPACE
value: $(NAMESPACE)

0 comments on commit b957a98

Please sign in to comment.