Skip to content

Commit 5e80c4e

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

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
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 & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -605,7 +605,7 @@ func (k *KatibUIHandler) FetchTrialLogs(w http.ResponseWriter, r *http.Request)
605605
return
606606
}
607607

608-
user, err = IsAuthorized(consts.ActionTypeList, namespace, "pods", "", "", schema.GroupVersion{Group: "apps", Version: "v1"}, k.katibClient.GetClient(), r)
608+
user, err = IsAuthorized(consts.ActionTypeList, namespace, corev1.ResourcePods.String(), "", "", schema.GroupVersion{Group: "apps", Version: "v1"}, k.katibClient.GetClient(), r)
609609
if user == "" && err != nil {
610610
log.Printf("No user provided in kubeflow-userid header.")
611611
http.Error(w, err.Error(), http.StatusUnauthorized)
@@ -638,13 +638,13 @@ func (k *KatibUIHandler) FetchTrialLogs(w http.ResponseWriter, r *http.Request)
638638
return
639639
}
640640

641-
user, err = IsAuthorized(consts.ActionTypeGet, namespace, "pods", "log", podName, schema.GroupVersion{Group: "apps", Version: "v1"}, k.katibClient.GetClient(), r)
641+
user, err = IsAuthorized(consts.ActionTypeGet, namespace, corev1.ResourcePods.String(), "log", podName, corev1.SchemeGroupVersion, k.katibClient.GetClient(), r)
642642
if user == "" && err != nil {
643643
log.Printf("No user provided in kubeflow-userid header.")
644644
http.Error(w, err.Error(), http.StatusUnauthorized)
645645
return
646646
} 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)
647+
log.Printf("The user: %s is not authorized to get pod logs: %s in namespace: %s \n", user, podName, namespace)
648648
http.Error(w, err.Error(), http.StatusForbidden)
649649
return
650650
}

0 commit comments

Comments
 (0)