Skip to content

Commit 4afe976

Browse files
committed
Use corev1 for specifying resources, edit kf install RBAC
1 parent 365154b commit 4afe976

File tree

2 files changed

+15
-5
lines changed

2 files changed

+15
-5
lines changed

manifests/v1beta1/installs/katib-with-kubeflow/kubeflow-katib-roles.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,18 @@ rules:
3434
- deletecollection
3535
- patch
3636
- update
37+
- apiGroups:
38+
- ""
39+
resources:
40+
- pods
41+
verbs:
42+
- list
43+
- apiGroups:
44+
- ""
45+
resources:
46+
- pods/log
47+
verbs:
48+
- get
3749
---
3850
apiVersion: rbac.authorization.k8s.io/v1
3951
kind: ClusterRole

pkg/new-ui/v1beta1/backend.go

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,6 @@ import (
4545
"k8s.io/apimachinery/pkg/types"
4646
"k8s.io/client-go/kubernetes"
4747
"sigs.k8s.io/controller-runtime/pkg/client/config"
48-
49-
"k8s.io/apimachinery/pkg/runtime/schema"
5048
)
5149

5250
func NewKatibUIHandler(dbManagerAddr string) *KatibUIHandler {
@@ -605,7 +603,7 @@ func (k *KatibUIHandler) FetchTrialLogs(w http.ResponseWriter, r *http.Request)
605603
return
606604
}
607605

608-
user, err = IsAuthorized(consts.ActionTypeList, namespace, "pods", "", "", schema.GroupVersion{Group: "apps", Version: "v1"}, k.katibClient.GetClient(), r)
606+
user, err = IsAuthorized(consts.ActionTypeList, namespace, corev1.ResourcePods.String(), "", "", corev1.SchemeGroupVersion, k.katibClient.GetClient(), r)
609607
if user == "" && err != nil {
610608
log.Printf("No user provided in kubeflow-userid header.")
611609
http.Error(w, err.Error(), http.StatusUnauthorized)
@@ -638,13 +636,13 @@ func (k *KatibUIHandler) FetchTrialLogs(w http.ResponseWriter, r *http.Request)
638636
return
639637
}
640638

641-
user, err = IsAuthorized(consts.ActionTypeGet, namespace, "pods", "log", podName, schema.GroupVersion{Group: "apps", Version: "v1"}, k.katibClient.GetClient(), r)
639+
user, err = IsAuthorized(consts.ActionTypeGet, namespace, corev1.ResourcePods.String(), "log", podName, corev1.SchemeGroupVersion, k.katibClient.GetClient(), r)
642640
if user == "" && err != nil {
643641
log.Printf("No user provided in kubeflow-userid header.")
644642
http.Error(w, err.Error(), http.StatusUnauthorized)
645643
return
646644
} else if err != nil {
647-
log.Printf("The user: %s is not authorized to list pod logs: %s in namespace: %s \n", user, podName, namespace)
645+
log.Printf("The user: %s is not authorized to get pod logs: %s in namespace: %s \n", user, podName, namespace)
648646
http.Error(w, err.Error(), http.StatusForbidden)
649647
return
650648
}

0 commit comments

Comments
 (0)