kubesphere-sigs / ks

ks is a tool that makes it be easy to work with KubeSphere.
MIT License
22 stars 16 forks source link

Feature: support to uninstall component #252

Closed mangoGoForward closed 1 year ago

mangoGoForward commented 2 years ago

Which issue(s) this PR fixes:

246

How to test:

ks uninstall --components logging,auditing

/cc @kubesphere-sigs/sig-devops

ks-ci-bot commented 2 years ago

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: mangoGoForward To complete the pull request process, please assign linuxsuren after the PR has been reviewed. You can assign the PR to them by writing /assign @linuxsuren in a comment when ready.

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files: - **[OWNERS](https://github.com/kubesphere-sigs/ks/blob/master/OWNERS)** Approvers can indicate their approval by writing `/approve` in a comment Approvers can cancel approval by writing `/approve cancel` in a comment
mangoGoForward commented 2 years ago

I have som problem with devops and servicemesh:

when use common.ExecCommand to run kubectl patch ** ,it throw Error from server: Invalid JSON Patch, If you has free time, please help me to figure out the problem.

mangoGoForward commented 2 years ago

/hold

LinuxSuRen commented 2 years ago

I have som problem with devops and servicemesh:

when use common.ExecCommand to run kubectl patch ** ,it throw Error from server: Invalid JSON Patch, If you has free time, please help me to figure out the problem.

I'm wondering if is that possible to use the k8s client instead.

mangoGoForward commented 2 years ago

/unhold

mangoGoForward commented 2 years ago

I have som problem with devops and servicemesh: when use common.ExecCommand to run kubectl patch ** ,it throw Error from server: Invalid JSON Patch, If you has free time, please help me to figure out the problem.

I'm wondering if is that possible to use the k8s client instead.

Solved

mangoGoForward commented 2 years ago

I didn't get any tips when no flags were given. But the flag --components is required. How about printing some information to let users know that.

[root@node1 ~]# ks uninstall
[root@node1 ~]#

For the command ks install xx, its responsibility is to create k8s or kubesphere instead of any components. We already have a command ks com enable devops to enable components. I'm wondering if we can have a command like this: ks com disable devops or ks com unintall devops. com means component.

Is that possible to know if a component exists? See my test case below. For me, this is not a block opinion. You can take it or not.

[root@node1 ~]# ks uninstall --components devops
release "devops" uninstalled
customresourcedefinition.apiextensions.k8s.io "devopsprojects.devops.kubesphere.io" deleted
customresourcedefinition.apiextensions.k8s.io "fakes.devops.kubesphere.io" deleted
customresourcedefinition.apiextensions.k8s.io "gitrepositories.devops.kubesphere.io" deleted
customresourcedefinition.apiextensions.k8s.io "pipelineruns.devops.kubesphere.io" deleted
customresourcedefinition.apiextensions.k8s.io "pipelines.devops.kubesphere.io" deleted
customresourcedefinition.apiextensions.k8s.io "s2ibinaries.devops.kubesphere.io" deleted
customresourcedefinition.apiextensions.k8s.io "s2ibuilders.devops.kubesphere.io" deleted
customresourcedefinition.apiextensions.k8s.io "s2ibuildertemplates.devops.kubesphere.io" deleted
customresourcedefinition.apiextensions.k8s.io "s2iruns.devops.kubesphere.io" deleted
customresourcedefinition.apiextensions.k8s.io "webhooks.devops.kubesphere.io" deleted
namespace "kubesphere-devops-system" deleted
[root@node1 ~]# ks uninstall --components devops
Error: uninstall: Release not loaded: devops: release: not found
Usage:
  ks uninstall [flags]

Examples:
ks uninstall --components devops

Flags:
      --components strings   Which components will uninstall
  -h, --help                 help for uninstall

Global Flags:
      --context string   Sets a context entry in kubeconfig

the server rejected our request due to an error in our request

Got it. And I noticed that the command of ks com enable has a flag toggle, if toggleis true, it will change clusterconfiguration, but do not remove related resource firstly. Now I want to use ks com unintall devops to refactor

mangoGoForward commented 2 years ago

Notification is installed in KubeSphere 3.2.1 by default, do we need support enable and uninstall component operator? @LinuxSuRen https://github.com/kubesphere-sigs/ks/blob/e6ef407317595056acc75e429bd68c5bc47cdadf/kubectl-plugin/common/components.go#L4-L9

LinuxSuRen commented 2 years ago

Notification is installed in KubeSphere 3.2.1 by default, do we need support enable and uninstall component operator?

I am not sure if it can be enable/disable. We can support it if it is true.

mangoGoForward commented 2 years ago

I am not sure if it can be enable/disable. We can support it if it is true.

As the uninstall component said, we not need support operation of install or uninstall, so i suggest to remove notification in function GetPluginAbleComponents

LinuxSuRen commented 2 years ago

so i suggest to remove notification in function GetPluginAbleComponents

Sure.

zhu733756 commented 2 years ago

For another implement, we can use the tools like istioctl to install/uninstall our helm charts. They use CRD related to the k8s resources, once we delete these installation CRD, the related k8s resources in the cluster will delete.

ks-ci-bot commented 1 year ago

@mangoGoForward: PR needs rebase.

Instructions for interacting with me using PR comments are available [here](https://git.k8s.io/community/contributors/guide/pull-requests.md). If you have questions or suggestions related to my behavior, please file an issue against the [kubernetes/test-infra](https://github.com/kubernetes/test-infra/issues/new?title=Prow%20issue:) repository.