{"id":16950722,"url":"https://github.com/rajatjindal/kubectl-evict-pod","last_synced_at":"2026-02-19T05:04:16.586Z","repository":{"id":37515387,"uuid":"214657606","full_name":"rajatjindal/kubectl-evict-pod","owner":"rajatjindal","description":"This plugin evicts the given pod and is useful for testing pod disruption budget rules","archived":false,"fork":false,"pushed_at":"2024-08-13T17:07:30.000Z","size":11342,"stargazers_count":71,"open_issues_count":8,"forks_count":16,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-02-07T14:09:08.070Z","etag":null,"topics":["evict-pod","kubectl","kubectl-plugins"],"latest_commit_sha":null,"homepage":null,"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/rajatjindal.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":"FUNDING.yml","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},"funding":{"github":["rajatjindal"]}},"created_at":"2019-10-12T14:06:47.000Z","updated_at":"2024-12-13T08:08:48.000Z","dependencies_parsed_at":"2024-10-26T21:19:41.923Z","dependency_job_id":"61c611ec-2ff1-4d11-a947-6b4d795e5e80","html_url":"https://github.com/rajatjindal/kubectl-evict-pod","commit_stats":null,"previous_names":[],"tags_count":15,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rajatjindal%2Fkubectl-evict-pod","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rajatjindal%2Fkubectl-evict-pod/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rajatjindal%2Fkubectl-evict-pod/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rajatjindal%2Fkubectl-evict-pod/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rajatjindal","download_url":"https://codeload.github.com/rajatjindal/kubectl-evict-pod/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":238857199,"owners_count":19542373,"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":["evict-pod","kubectl","kubectl-plugins"],"created_at":"2024-10-13T21:58:23.422Z","updated_at":"2026-02-19T05:04:16.579Z","avatar_url":"https://github.com/rajatjindal.png","language":"Go","funding_links":["https://github.com/sponsors/rajatjindal"],"categories":[],"sub_categories":[],"readme":"# kubectl-evict-pod\n\nThis plugin evicts pods:\n- for testing pod disruption budget rules\n- safely restarting applications\n\n## Usage\n\n- evict single pod: `kubectl evict-pod \u003cpod-name\u003e -n \u003cnamespace\u003e`\n- evict multiple pods: `kubectl evict-pod -n \u003cnamespace\u003e -l app=foo`\n- evict all pods: `kubectl evict-pod -n \u003cnamespace\u003e --all`\n- evict multiple pods until every one is gone: `kubectl evict-pod -n \u003cnamespace\u003e -l app=foo --retry`\n- show options: `kubectl evict-pod -h`\n\n## Install\n\n```\nkubectl krew install evict-pod\n```\n\n## Testing\n\n### Pod evicted successfully scenario\n\n```bash\n# before running the evict-pod command\n$ kubectl get pods -n kube-system\nNAME                               READY   STATUS    RESTARTS   AGE\ncoredns-fb8b8dccf-6wvj6            1/1     Running   0          10m\ncoredns-fb8b8dccf-826fh            1/1     Running   0          11m\n\n# now lets evict 1 coredns pod\n$ ./kubectl-evict-pod coredns-fb8b8dccf-6wvj6 -n kube-system\nINFO[0000] pod \"coredns-fb8b8dccf-6wvj6\" in namespace kube-system evicted successfully \n\n# the pod has been evicted successfully\n$ kubectl get pods -n kube-system\nNAME                               READY   STATUS    RESTARTS   AGE\ncoredns-fb8b8dccf-7ngmk            1/1     Running   0          42s\ncoredns-fb8b8dccf-826fh            1/1     Running   0          11m\n```\n\n### Pod eviction prevented by pod disruption budget\n\n- create the pod disruption budget using following spec\n```yaml\napiVersion: policy/v1beta1\nkind: PodDisruptionBudget\nmetadata:\n  name: coredns-pdb\nspec:\n  minAvailable: 2\n  selector:\n    matchLabels:\n      k8s-app: kube-dns\n```\n\n- apply the pod disruption budget to the cluster\n\n```bash\n# lets apply the pod disruption budget\n$ kubectl apply -f pdb.yaml -n kube-system\npoddisruptionbudget.policy/coredns-pdb created\n```\n\n- Now lets try to evict the pods again\n\n```bash\n# get existing pods\n$ kubectl get pods -n kube-system\nNAME                               READY   STATUS    RESTARTS   AGE\ncoredns-fb8b8dccf-7ngmk            1/1     Running   0          10m\ncoredns-fb8b8dccf-826fh            1/1     Running   0          11m\n\n# now lets try to evict the pod again\n$ ./kubectl-evict-pod coredns-fb8b8dccf-826fh -n kube-system\nError: Cannot evict pod as it would violate the pod\\'s disruption budget.\nexit status 1\n\n# observe pods continue to run\n$ kubectl get pods -n kube-system\nNAME                               READY   STATUS    RESTARTS   AGE\ncoredns-fb8b8dccf-7ngmk            1/1     Running   0          10m\ncoredns-fb8b8dccf-826fh            1/1     Running   0          11m\n```\n\n## Development\n\nUpdate the code and use `go run . \u003cargs\u003e` to test.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frajatjindal%2Fkubectl-evict-pod","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frajatjindal%2Fkubectl-evict-pod","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frajatjindal%2Fkubectl-evict-pod/lists"}