Skip to content

Commit

Permalink
fix(cmd): uninstall kube-public rolebindings
Browse files Browse the repository at this point in the history
Closes #3829
  • Loading branch information
squakez committed Apr 13, 2023
1 parent d5980c3 commit fdd30a6
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
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

0 comments on commit fdd30a6

Please sign in to comment.