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

Feature Request: delete namespace when bundle is deleted #1564

Closed
mattups opened this issue Jun 1, 2023 · 3 comments
Closed

Feature Request: delete namespace when bundle is deleted #1564

mattups opened this issue Jun 1, 2023 · 3 comments

Comments

@mattups
Copy link

mattups commented Jun 1, 2023

Is your feature request related to a problem?

Hi all, it would be awesome if there was a way to cleanup also the namespace where a bundle was deployed.
I see in the past there was a prune option for the GitRepo which is not available anymore.
keepResources = false instead deletes the actual resources but preserves the namespace where the resources were deployed to.

Maybe I'm missing something from the docs?

Otherwise it would be great to have the possibility to cleanup the namespace as well.

Solution you'd like

An option to delete also the namespace when a bundle is deleted.

Alternatives you've considered

Manually cleanup namespaces after deleting bundles.

Anything else?

No response

@rancherbot rancherbot added this to Fleet Jun 1, 2023
@github-project-automation github-project-automation bot moved this to 🆕 New in Fleet Jun 1, 2023
@rubhanazeem rubhanazeem self-assigned this Apr 4, 2024
@rubhanazeem rubhanazeem moved this from 🆕 New to 🏗 In progress in Fleet Apr 4, 2024
@rubhanazeem rubhanazeem moved this from 🏗 In progress to 👀 In review in Fleet Apr 26, 2024
@rubhanazeem rubhanazeem moved this from 👀 In review to Needs QA review in Fleet May 7, 2024
@rubhanazeem
Copy link
Contributor

rubhanazeem commented May 7, 2024

Followups before we close this issue:

QA Testing Considerations:

  1. Add a new option in gitrepo.yaml. specs.deleteNamespace: true
  2. This should delete the targetNamespace when gitrepo is deleted.
  3. When specs.deleteNamespace: false, targetNamespace should persist after deleting the gitRepo resource.

@mmartin24
Copy link
Collaborator

Testing enviroment:

Rancher version: v2.9-3d6ceeefb63c812c41090f271140a30bb2edf9ae-head
K3s version: v1.28.8+k3s1


Scenario 1: Test namespace deletion using fleet.yaml with defaultNamespace defined and later editing file to add deleteNamespace: true and targetNamespace: my-custom-namespace

  • Used this repo with defaultNamespace defined: https://github.com/mmartin24/test-fleet-fork

  • Branch: bundles-delete-namespaces
    Basically it contains:
    fleet.yaml

    defaultNamespace: my-custom-namespace

    deployment.yaml

    apiVersion: apps/v1
    kind: Deployment
    metadata:
      creationTimestamp: null
      labels:
        app: fleet-nginx
        env: devel
      name: fleet-nginx
    spec:
      replicas: 2
      selector:
        matchLabels:
          app: fleet-nginx
      template:
        metadata:
          creationTimestamp: null
          labels:
            app: fleet-nginx
        spec:
          containers:
          - image: nginx:alpine
            name: nginx
            ports:
            - containerPort: 80
  • Edit yaml and added deleteNamespace: true and targetNamespace: my-custom-namespace under spec: level

  • Created working app

  • Delete the app

I confirmed that namespace my-custom-namespace has been deleted.


Scenario 2 : Test namespace deletion directly from gitrepo-example using fleet.yaml with defaultNamespace defined and later editing file to add deleteNamespace: true and targetNamespace: my-custom-namespace

In this case, when I try to directly upload a gitrepo from continuous delivery it seems not to take place at all:

kind: GitRepo
apiVersion: fleet.cattle.io/v1alpha1
metadata:
  name: my-gitrepo
spec:
  targetNamespace: my-custom-namespace
  repo: https://github.com/rancher/fleet-test-data
  deleteNamespace: true
  paths:
  - helm-verify

I am not sure if this is expected behaviour.


Aside from his, while testing this item I found some edit malfunctioning from Rancher. Ie: indentations problems on paths right prior gitrepo creation as shown here:
image

I will spin an issue for this if it is not there already

@mmartin24
Copy link
Collaborator

About Scenario 2 before, it turned out there was an error on my file. Here, we are performing a nested GitRepo on ui, so 2 Gitrepos are created and one must be set to a namespace (in this case one of them linked to fleet-local), one named as we wish (test in this case) and another one named my-gitrepo as specified in the yaml file:

kind: GitRepo
apiVersion: fleet.cattle.io/v1alpha1
metadata:
  name: my-gitrepo
  namespace: fleet-local
spec:
  targetNamespace: my-custom-namespace
  repo: https://github.com/rancher/fleet-test-data
  deleteNamespace: true
  paths:
  - helm-verify

So basically the ui will look like this
image

Once the parent main gitRepo is deleted, I confirmed the namespace is deleted as well.
Further testing details can be found in https://app.qase.io/case/FLEET-131

So it seems working ok in 2.9, Clossing issue.

@github-project-automation github-project-automation bot moved this from Needs QA review to ✅ Done in Fleet Jun 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Development

No branches or pull requests

7 participants