Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(cmd): uninstall kube-public rolebindings #4251

Merged
merged 2 commits into from
Apr 13, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions pkg/cmd/uninstall.go
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,12 @@ func (o *uninstallCmdOptions) uninstallNamespaceRoles(ctx context.Context, cmd *
return err
}
fmt.Fprintln(cmd.OutOrStdout(), "Camel K Role Bindings removed from namespace", o.Namespace)

KEP1755Namespace := "kube-public"
if err := o.uninstallKEP_1755RoleBindings(ctx, c, KEP1755Namespace); err != nil {
return err
}
fmt.Fprintln(cmd.OutOrStdout(), "Camel K Role Bindings removed from namespace", KEP1755Namespace)
}

if !o.SkipRoles {
Expand Down Expand Up @@ -347,6 +353,24 @@ func (o *uninstallCmdOptions) uninstallRoleBindings(ctx context.Context, c clien
return nil
}

func (o *uninstallCmdOptions) uninstallKEP_1755RoleBindings(ctx context.Context, c client.Client, namespace string) error {
api := c.RbacV1()

roleBindings, err := api.RoleBindings(namespace).List(ctx, defaultListOptions)
if err != nil {
return err
}

for _, roleBinding := range roleBindings.Items {
err := api.RoleBindings(namespace).Delete(ctx, roleBinding.Name, metav1.DeleteOptions{})
if err != nil {
return err
}
}

return nil
}

func (o *uninstallCmdOptions) uninstallClusterRoles(ctx context.Context, c client.Client) error {
api := c.RbacV1()

Expand Down
2 changes: 1 addition & 1 deletion pkg/install/operator.go
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ func OperatorOrCollect(ctx context.Context, cmd *cobra.Command, c client.Client,
}

if err = installNamespacedRoleBinding(ctx, c, collection, cfg.Namespace, "/rbac/operator-role-binding-local-registry.yaml"); err != nil {
fmt.Fprintln(cmd.ErrOrStderr(), "Warning: the operator won't be able to detect a local image registry via KEP-1755")
fmt.Fprintf(cmd.ErrOrStderr(), "Warning: the operator may not be able to detect a local image registry (%s)\n", err.Error())
}

if cfg.Monitoring.Enabled {
Expand Down