Skip to content

Commit

Permalink
viewer controller is now namespaced so no need for cluster role (#1623)
Browse files Browse the repository at this point in the history
* viewer controller is now namespaced so no need for cluster role

* our default namespaced install (kubeflow namespace) can also use Role instead of ClusterRole
  • Loading branch information
jingzhang36 authored and k8s-ci-robot committed Jul 16, 2019
1 parent 1793c6b commit 784c4f1
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 9 deletions.
6 changes: 3 additions & 3 deletions backend/src/crd/controller/viewer/reconciler/reconciler.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ func (r *Reconciler) Reconcile(req reconcile.Request) (reconcile.Result, error)
}

// Check and maybe delete the oldest viewer before creating the next one.
if err := r.maybeDeleteOldestViewer(view.Spec.Type); err != nil {
if err := r.maybeDeleteOldestViewer(view.Spec.Type, view.Namespace); err != nil {
// Couldn't delete. Requeue.
return reconcile.Result{Requeue: true}, err
}
Expand Down Expand Up @@ -254,10 +254,10 @@ func serviceFrom(v *viewerV1beta1.Viewer, deploymentName string) *corev1.Service
}
}

func (r *Reconciler) maybeDeleteOldestViewer(t viewerV1beta1.ViewerType) error {
func (r *Reconciler) maybeDeleteOldestViewer(t viewerV1beta1.ViewerType, namespace string) error {
list := &viewerV1beta1.ViewerList{}

if err := r.Client.List(context.Background(), &client.ListOptions{}, list); err != nil {
if err := r.Client.List(context.Background(), &client.ListOptions{Namespace: namespace}, list); err != nil {
return fmt.Errorf("failed to list viewers: %v", err)
}

Expand Down
2 changes: 1 addition & 1 deletion manifests/base/pipeline/ml-pipeline-viewer-crd-role.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
apiVersion: rbac.authorization.k8s.io/v1beta1
kind: ClusterRole
kind: Role
metadata:
name: ml-pipeline-viewer-controller-role
rules:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
apiVersion: rbac.authorization.k8s.io/v1beta1
kind: ClusterRoleBinding
kind: RoleBinding
metadata:
name: ml-pipeline-viewer-crd-binding
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
kind: Role
name: ml-pipeline-viewer-controller-role
subjects:
- kind: ServiceAccount
Expand Down
8 changes: 5 additions & 3 deletions manifests/namespaced-install.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -360,9 +360,10 @@ rules:
- '*'
---
apiVersion: rbac.authorization.k8s.io/v1beta1
kind: ClusterRole
kind: Role
metadata:
name: ml-pipeline-viewer-controller-role
namespace: kubeflow
rules:
- apiGroups:
- '*'
Expand Down Expand Up @@ -495,12 +496,13 @@ subjects:
namespace: kubeflow
---
apiVersion: rbac.authorization.k8s.io/v1beta1
kind: ClusterRoleBinding
kind: RoleBinding
metadata:
name: ml-pipeline-viewer-crd-binding
namespace: kubeflow
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
kind: Role
name: ml-pipeline-viewer-controller-role
subjects:
- kind: ServiceAccount
Expand Down

0 comments on commit 784c4f1

Please sign in to comment.