{"id":21929179,"url":"https://github.com/achetronic/nsmurder","last_synced_at":"2025-04-19T17:51:52.434Z","repository":{"id":63295457,"uuid":"498483740","full_name":"achetronic/nsmurder","owner":"achetronic","description":"A CLI to assassinate Kubernetes namespaces","archived":false,"fork":false,"pushed_at":"2024-12-31T18:49:52.000Z","size":18010,"stargazers_count":21,"open_issues_count":1,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-03-29T11:11:23.983Z","etag":null,"topics":["cli","golang","kubernetes"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/achetronic.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-05-31T20:13:36.000Z","updated_at":"2025-03-20T21:24:07.000Z","dependencies_parsed_at":"2024-11-28T22:40:12.643Z","dependency_job_id":null,"html_url":"https://github.com/achetronic/nsmurder","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/achetronic%2Fnsmurder","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/achetronic%2Fnsmurder/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/achetronic%2Fnsmurder/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/achetronic%2Fnsmurder/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/achetronic","download_url":"https://codeload.github.com/achetronic/nsmurder/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249753088,"owners_count":21320664,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cli","golang","kubernetes"],"created_at":"2024-11-28T22:29:56.951Z","updated_at":"2025-04-19T17:51:52.411Z","avatar_url":"https://github.com/achetronic.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Nsmurder\n\n![GitHub go.mod Go version (subdirectory of monorepo)](https://img.shields.io/github/go-mod/go-version/achetronic/nsmurder)\n![GitHub](https://img.shields.io/github/license/achetronic/nsmurder)\n\n![YouTube Channel Subscribers](https://img.shields.io/youtube/channel/subscribers/UCeSb3yfsPNNVr13YsYNvCAw?label=achetronic\u0026link=http%3A%2F%2Fyoutube.com%2Fachetronic)\n![GitHub followers](https://img.shields.io/github/followers/achetronic?label=achetronic\u0026link=http%3A%2F%2Fgithub.com%2Fachetronic)\n![X (formerly Twitter) Follow](https://img.shields.io/twitter/follow/achetronic?style=flat\u0026logo=twitter\u0026link=https%3A%2F%2Ftwitter.com%2Fachetronic)\n\n## Description\n\nA CLI to assassinate Kubernetes namespaces following different strategies without mercy\n\n## Motivation\n\nSome companies manage Kubernetes clusters dynamically using pipelines.\nOne of the problems of this approach is not on creation time, but on destruction.\n\nKubernetes' distributions, like EKS or GKE, can create cloud resources in the provider,\nsuch as DNS registries, LoadBalancers or Volumes dynamically, when creating Ingress,\nService or PVC resources.\n\nThe reason for this is that they are attached to the provider that is running it\n(under the hoods). This is convenient for the customers, but need a cleaning\nprocess when destroying a cluster, in order not to leave orphan resources\ncreated on the cloud (which means money)\n\nThinking about this problem and best practise, we created this CLI as a single\nbinary, which can be integrated on the pipelines to do the cleaning trick.\n\n## Strategies\n\nThe process followed to assassinate namespaces is described in the following steps:\n\n\u003e There is a time between steps that can be configured using the flag `--duration-between-strategies`\n\n1. Schedule namespace deletion for all the namespaces introduced by using the flags.\n   This step is intended to identify which ones are stuck in `Terminating` state later.\n\n2. Get a list with every resource type that can be created into a namespace.\n   Then loop over namespaces which are in `Terminating` status.\n   For each namespace, delete all resources inside to clean it.\n\n3. Loop over namespaces which are still in `Terminating` state and remove their finalizers\n\n## Flags\n\nThere are several flags that can be configured to change the behaviour of the\napplication. They are described in the following table:\n\n| Name                            | Description                                           |     Default      | Example                               |\n|:--------------------------------|:------------------------------------------------------|:----------------:|:--------------------------------------|\n| `--include-all`                 | Include all the namespaces. This override `--include` |     `false`      | `--include-all`                       |\n| `--include`                     | Include one namespace to be deleted                   |        -         | `--include default`                   |\n| `--ignore`                      | Ignore deletion of one namespace                      |        -         | `--ignore kube-system`                |\n| `--duration-between-strategies` | Duration between strategies perform                   |       `1m`       | `--duration-between-strategies \"30s\"` |\n| `--kubeconfig`                  | Path to the kubeconfig file                           | `~/.kube/config` | `--kubeconfig \"~/.kube/config\"`       |\n| `--help`                        | Show this help message                                |        -         | -                                     |\n\n## Examples\n\nTo delete all the namespaces, ignoring some of them, execute the command as follows:\n\n```sh\nnsmurder --include-all \\\n         --ignore \"kube-system,kube-public,external-dns,calico-system\" \\\n         --duration-between-strategies \"5m\" \\\n         --kubeconfig \"~/.kube/config\"\n```\n\nTo delete only some namespaces, execute it as in the following example:\n\n```sh\nnsmurder --include \"app-develop,app-staging,app-production\" \\\n         --ignore \"kube-system,kube-public,external-dns,calico-system\" \\\n         --duration-between-strategies \"50s\" \\\n         --kubeconfig \"~/.kube/config\"\n```\n\n\u003e ATTENTION:\n\u003e If you execute this CLI, and have other namespaces in terminating state, they will be processed too.\n\u003e The reason for this is that the project pretends to do the best job when is part of a cleaning pipeline, etc.\n\n## How to collaborate\n\nWe are open to external collaborations for this project: improvements, bugfixes, whatever.\n\nFor doing it, open an issue to discuss the need of the changes, then:\n\n- Fork the repository\n- Make your changes to the code\n- Open a PR and wait for review\n\nThe code will be reviewed and tested (always)\n\n\u003e We are developers and hate bad code. For that reason we ask you the highest quality\n\u003e on each line of code to improve this project on each iteration.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fachetronic%2Fnsmurder","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fachetronic%2Fnsmurder","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fachetronic%2Fnsmurder/lists"}