-
Notifications
You must be signed in to change notification settings - Fork 63
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
✨ Support uninstall built-in addon #435
✨ Support uninstall built-in addon #435
Conversation
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: qiujian16 The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
/assign @mikeshng @JustinKuli |
d0e5bfe
to
5fe3ba4
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall looks good! I've mentioned one important caveat around the PlacementRule CRD that will require an update.
I've also proposed adding an addon deployment map (though it'd result in refactoring some of the code).
"addon/policy/propagator_serviceaccount.yaml", | ||
"addon/policy/clustermanagementaddon_configpolicy.yaml", | ||
"addon/policy/clustermanagementaddon_policyframework.yaml", | ||
"addon/appmgr/crd_placementrule.yaml", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PlacementRule CRD is a special case that needs to be handled and should only be cleaned up if both addons are uninstalled.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does policy still have a hard deps on placementRule, or we just do not create this crd when installing?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Currently the governance-policy-propagator controller won't start properly unless the PlacementRule CRD exists.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated, will no delete any crd right now during uninstall.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FYI: In the next OCM release, Policy no longer has a dependency on PlacementRule, so addon CRD cleanup can proceed in clusteradm
.
var ( | ||
PolicyFrameworkConfigFiles = []string{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I really like this new configuration file. What would you think of creating a struct
and a map above it that also has the addon name as a key so that the install/uninstall doesn't need to specify names, something like:
var addonDeployments = map[string]AddonDeployment{
"governance-policy-framework": {
ConfigFiles: PolicyFrameworkConfigFiles,
DeploymentFiles: PolicyFrameworkDeploymentFiles,
},
"application-manager": {
ConfigFiles: AppManagerConfigFiles,
DeploymentFiles: AppManagerDeploymentFiles,
},
}
type AddonDeployment struct {
ConfigFiles []string
DeploymentFiles []string
}
5fe3ba4
to
bca81d6
Compare
Signed-off-by: Jian Qiu <[email protected]>
0d7590c
to
00a17fd
Compare
pkg/cmd/uninstall/cmd.go
Outdated
genericclioptionsclusteradm "open-cluster-management.io/clusteradm/pkg/genericclioptions" | ||
) | ||
|
||
// NewCmd provides a cobra command wrapping NewCmdImportCluster |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what does the NewCmdImportCluster
mean here?
when I run
|
pkg/cmd/uninstall/cmd.go
Outdated
import ( | ||
"github.com/spf13/cobra" | ||
"k8s.io/cli-runtime/pkg/genericclioptions" | ||
hubaddon "open-cluster-management.io/clusteradm/pkg/cmd/install/hubaddon" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hubaddon "open-cluster-management.io/clusteradm/pkg/cmd/install/hubaddon" | |
hubaddon "open-cluster-management.io/clusteradm/pkg/cmd/uninstall/hubaddon" |
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@qiujian16 I think this must be fixed.
pkg/cmd/uninstall/hubaddon/cmd.go
Outdated
|
||
var example = ` | ||
# Uninstall built-in add-ons from the hub cluster | ||
%[1]s install hub-addon --names application-manager |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
%[1]s install hub-addon --names application-manager | |
%[1]s uninstall hub-addon --names application-manager |
pkg/cmd/uninstall/hubaddon/cmd.go
Outdated
var example = ` | ||
# Uninstall built-in add-ons from the hub cluster | ||
%[1]s install hub-addon --names application-manager | ||
%[1]s install hub-addon --names governance-policy-framework |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
%[1]s install hub-addon --names governance-policy-framework | |
%[1]s uninstall hub-addon --names governance-policy-framework |
pkg/cmd/uninstall/hubaddon/cmd.go
Outdated
|
||
cmd := &cobra.Command{ | ||
Use: "hub-addon", | ||
Short: "install hub-addon", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Short: "install hub-addon", | |
Short: "uninstall hub-addon", |
pkg/cmd/uninstall/hubaddon/cmd.go
Outdated
cmd := &cobra.Command{ | ||
Use: "hub-addon", | ||
Short: "install hub-addon", | ||
Long: "Install specific built-in add-on(s) to the hub cluster", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Long: "Install specific built-in add-on(s) to the hub cluster", | |
Long: "Uninstall specific built-in add-on(s) to the hub cluster", |
pkg/cmd/uninstall/hubaddon/cmd.go
Outdated
}, | ||
} | ||
|
||
cmd.Flags().StringVar(&o.names, "names", "", "Names of the built-in add-on to install (comma separated). The built-in add-ons are: application-manager, governance-policy-framework") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cmd.Flags().StringVar(&o.names, "names", "", "Names of the built-in add-on to install (comma separated). The built-in add-ons are: application-manager, governance-policy-framework") | |
cmd.Flags().StringVar(&o.names, "names", "", "Names of the built-in add-on to uninstall (comma separated). The built-in add-ons are: application-manager, governance-policy-framework") |
pkg/cmd/uninstall/hubaddon/cmd.go
Outdated
} | ||
|
||
cmd.Flags().StringVar(&o.names, "names", "", "Names of the built-in add-on to install (comma separated). The built-in add-ons are: application-manager, governance-policy-framework") | ||
cmd.Flags().StringVar(&o.values.Namespace, "namespace", "open-cluster-management", "Namespace of the built-in add-on to install. Defaults to open-cluster-management") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cmd.Flags().StringVar(&o.values.Namespace, "namespace", "open-cluster-management", "Namespace of the built-in add-on to install. Defaults to open-cluster-management") | |
cmd.Flags().StringVar(&o.values.Namespace, "namespace", "open-cluster-management", "Namespace of the built-in add-on to uninstall. Defaults to open-cluster-management") |
I think we need to do more tests on the new uninstall command.
|
return fmt.Errorf("invalid add-on name %s", n) | ||
} | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we can set a default latest
bundleversion here to fix #435 (comment)
versionBundle, err := version.GetVersionBundle("latest") | |
if err != nil { | |
return err | |
} | |
o.values.BundleVersion = versionBundle |
00a17fd
to
8d0b0b2
Compare
Signed-off-by: Jian Qiu <[email protected]>
8d0b0b2
to
2b68b14
Compare
LGTM |
/lgtm |
/unhold |
261c92a
into
open-cluster-management-io:main
Summary
Related issue(s)
Fixes #339