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

Refactor flux uninstall command #891

Merged
merged 3 commits into from
Feb 12, 2021
Merged

Refactor flux uninstall command #891

merged 3 commits into from
Feb 12, 2021

Conversation

stefanprodan
Copy link
Member

@stefanprodan stefanprodan commented Feb 9, 2021

This is a complete rewrite of flux uninstall in Go without any shell-execs to kubectl.

The uninstall command performs the following operations:

  • deletes Flux components (deployments and services)
  • deletes Flux network policies
  • deletes Flux RBAC (service accounts, cluster roles and cluster role bindings)
  • removes the Kubernetes finalizers from Flux custom resources in all namespaces
  • deletes Flux custom resource definitions and custom resources from all namespaces
  • deletes the namespace where Flux was installed if --keep-namespace=false

Breaking changes:

  • the uninstall command will no longer remove any Kubernetes objects or Helm releases that were reconciled on the cluster by Flux
  • the crds and resources arguments were removed

Example:

$ flux uninstall --namespace=flux-system
Are you sure you want to delete Flux and its custom resource definitions?: y
► deleting components in flux-system namespace
✔ Deployment/flux-system/helm-controller deleted
✔ Deployment/flux-system/image-automation-controller deleted
✔ Deployment/flux-system/image-reflector-controller deleted
✔ Deployment/flux-system/kustomize-controller deleted
✔ Deployment/flux-system/notification-controller deleted
✔ Deployment/flux-system/source-controller deleted
✔ Service/flux-system/notification-controller deleted
✔ Service/flux-system/source-controller deleted
✔ Service/flux-system/webhook-receiver deleted
✔ NetworkPolicy/flux-system/allow-scraping deleted
✔ NetworkPolicy/flux-system/allow-webhooks deleted
✔ NetworkPolicy/flux-system/deny-ingress deleted
✔ ServiceAccount/flux-system/helm-controller deleted
✔ ServiceAccount/flux-system/image-automation-controller deleted
✔ ServiceAccount/flux-system/image-reflector-controller deleted
✔ ServiceAccount/flux-system/kustomize-controller deleted
✔ ServiceAccount/flux-system/notification-controller deleted
✔ ServiceAccount/flux-system/source-controller deleted
✔ ClusterRole/crd-controller-flux-system deleted
✔ ClusterRoleBinding/cluster-reconciler-flux-system deleted
✔ ClusterRoleBinding/crd-controller-flux-system deleted
► deleting toolkit.fluxcd.io finalizers in all namespaces
✔ GitRepository/test/podinfo finalizers deleted
✔ HelmRepository/flux-system/podinfo finalizers deleted
✔ HelmChart/flux-system/default-podinfo finalizers deleted
✔ Kustomization/test/podinfo finalizers deleted
✔ HelmRelease/default/podinfo finalizers deleted
► deleting toolkit.fluxcd.io custom resource definitions
✔ CustomResourceDefinition/alerts.notification.toolkit.fluxcd.io deleted
✔ CustomResourceDefinition/buckets.source.toolkit.fluxcd.io deleted
✔ CustomResourceDefinition/gitrepositories.source.toolkit.fluxcd.io deleted
✔ CustomResourceDefinition/helmcharts.source.toolkit.fluxcd.io deleted
✔ CustomResourceDefinition/helmreleases.helm.toolkit.fluxcd.io deleted
✔ CustomResourceDefinition/helmrepositories.source.toolkit.fluxcd.io deleted
✔ CustomResourceDefinition/imagepolicies.image.toolkit.fluxcd.io deleted
✔ CustomResourceDefinition/imagerepositories.image.toolkit.fluxcd.io deleted
✔ CustomResourceDefinition/imageupdateautomations.image.toolkit.fluxcd.io deleted
✔ CustomResourceDefinition/kustomizations.kustomize.toolkit.fluxcd.io deleted
✔ CustomResourceDefinition/providers.notification.toolkit.fluxcd.io deleted
✔ CustomResourceDefinition/receivers.notification.toolkit.fluxcd.io deleted
✔ Namespace/flux-system deleted
✔ uninstall finished

Fix: #811
Fix: #632

@stefanprodan stefanprodan added enhancement New feature or request area/UX area/install Install and uninstall related issues and pull requests labels Feb 9, 2021
@stefanprodan stefanprodan requested a review from hiddeco February 9, 2021 10:24
Copy link
Member

@hiddeco hiddeco left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any specific reason the --dry-run flag was removed? As judging by the code, it would not be impossible to keep this feature.

@stefanprodan stefanprodan requested a review from hiddeco February 9, 2021 12:38
Copy link
Member

@hiddeco hiddeco left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome job @stefanprodan 💯 🥇

One tiny nit on the (already existing) description of the --dry-run flag, otherwise LGTM 👍

cmd/flux/uninstall.go Outdated Show resolved Hide resolved
@stefanprodan stefanprodan force-pushed the refac-uninstall branch 2 times, most recently from 01a541e to b975014 Compare February 9, 2021 13:06
@stefanprodan stefanprodan added the hold Issues and pull requests put on hold label Feb 9, 2021
@stefanprodan
Copy link
Member Author

This should be merged right before flux2 v0.8 release, to avoid confusion around uninstall docs.

@stefanprodan stefanprodan force-pushed the refac-uninstall branch 3 times, most recently from a0a819d to caff61f Compare February 12, 2021 09:45
- deletes Flux components (deployments and services)
- deletes Flux RBAC (service accounts, cluster roles and cluster role bindings)
- removes the Kubernetes finalizers from Flux custom resources
- deletes Flux custom resource definitions and custom resources
- deletes the namespace where Flux was installed
- preserves the Kubernetes objects and Helm releases that were reconciled on the cluster by Flux

Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
Signed-off-by: Stefan Prodan <stefan.prodan@gmail.com>
@stefanprodan stefanprodan removed the hold Issues and pull requests put on hold label Feb 12, 2021
@stefanprodan stefanprodan merged commit a2887f5 into main Feb 12, 2021
@stefanprodan stefanprodan deleted the refac-uninstall branch February 12, 2021 12:44
ybelleguic pushed a commit to ybelleguic/flux2 that referenced this pull request Jan 9, 2023
CI: Set Public ECR region to us-east-1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/install Install and uninstall related issues and pull requests enhancement New feature or request
Projects
None yet
2 participants