Skip to content

Commit

Permalink
Fix UI RBAC (#1323)
Browse files Browse the repository at this point in the history
  • Loading branch information
edeNFed authored Jul 3, 2024
1 parent 8840cac commit dc7be8b
Showing 1 changed file with 55 additions and 0 deletions.
55 changes: 55 additions & 0 deletions cli/cmd/resources/ui.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,59 @@ func NewUIServiceAccount(ns string) *corev1.ServiceAccount {
}
}

func NewUIRole(ns string) *rbacv1.Role {
return &rbacv1.Role{
TypeMeta: metav1.TypeMeta{
Kind: "Role",
APIVersion: "rbac.authorization.k8s.io/v1",
},
ObjectMeta: metav1.ObjectMeta{
Name: "odigos-ui",
Namespace: ns,
},
Rules: []rbacv1.PolicyRule{
{
Verbs: []string{
"create",
"delete",
"get",
"update",
"watch",
},
APIGroups: []string{""},
Resources: []string{
"secrets",
},
},
},
}
}

func NewUIRoleBinding(ns string) *rbacv1.RoleBinding {
return &rbacv1.RoleBinding{
TypeMeta: metav1.TypeMeta{
Kind: "RoleBinding",
APIVersion: "rbac.authorization.k8s.io/v1",
},
ObjectMeta: metav1.ObjectMeta{
Name: "odigos-ui",
Namespace: ns,
},
Subjects: []rbacv1.Subject{
{
Kind: "ServiceAccount",
Name: UIServiceAccountName,
Namespace: ns,
},
},
RoleRef: rbacv1.RoleRef{
Kind: "Role",
Name: "odigos-ui",
APIGroup: "rbac.authorization.k8s.io",
},
}
}

func NewUIClusterRole() *rbacv1.ClusterRole {
return &rbacv1.ClusterRole{
TypeMeta: metav1.TypeMeta{
Expand Down Expand Up @@ -216,6 +269,8 @@ func NewUIService(ns string) *corev1.Service {
func (u *uiResourceManager) InstallFromScratch(ctx context.Context) error {
resources := []client.Object{
NewUIServiceAccount(u.ns),
NewUIRole(u.ns),
NewUIRoleBinding(u.ns),
NewUIClusterRole(),
NewUIClusterRoleBinding(u.ns),
NewUIDeployment(u.ns, u.config.OdigosVersion, u.config.ImagePrefix),
Expand Down

0 comments on commit dc7be8b

Please sign in to comment.