{"id":15348207,"url":"https://github.com/ironcore864/eks-node-drain","last_synced_at":"2026-07-21T18:35:58.334Z","repository":{"id":73865847,"uuid":"316240032","full_name":"IronCore864/eks-node-drain","owner":"IronCore864","description":null,"archived":false,"fork":false,"pushed_at":"2020-11-26T13:31:25.000Z","size":2,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-10-10T08:04:00.878Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/IronCore864.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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":"2020-11-26T13:31:09.000Z","updated_at":"2020-11-26T13:31:28.000Z","dependencies_parsed_at":"2023-09-21T10:03:52.021Z","dependency_job_id":null,"html_url":"https://github.com/IronCore864/eks-node-drain","commit_stats":{"total_commits":1,"total_committers":1,"mean_commits":1.0,"dds":0.0,"last_synced_commit":"e9b1f303227f058a8d6b55e6bb17c296eeb6470a"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/IronCore864/eks-node-drain","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/IronCore864%2Feks-node-drain","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/IronCore864%2Feks-node-drain/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/IronCore864%2Feks-node-drain/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/IronCore864%2Feks-node-drain/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/IronCore864","download_url":"https://codeload.github.com/IronCore864/eks-node-drain/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/IronCore864%2Feks-node-drain/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":35734232,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-07-20T02:08:10.276Z","status":"online","status_checked_at":"2026-07-21T02:00:06.728Z","response_time":109,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":[],"created_at":"2024-10-01T11:45:21.868Z","updated_at":"2026-07-21T18:35:58.311Z","avatar_url":"https://github.com/IronCore864.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# A Python3 Script to Drain an EKS node\n\n## Purpose\n\nTo upgrade the worker node AMI version, First you need to update the AMI ID in the auto scaling group / launch template, then you want to move your workload to new version of nodes.\n\nDraining a node manually, then wait for all evicted pods are created, and check all affected deployments manually is tedious. You need to run a lots of kubectl command, get nodes, get pods, get deployments, etc, to check the result.\n\nThis script is automated to drain a node safely.\n\n## How it Works\n\n1. Get all running pods of the node to be drained;\n2. Get all deployments those pods belong to (meaning those deployments will be affected during draining and need to be checked after drained);\n3. Drain the node using `kubectl drain`;\n4. Try 3 times with 10 seconds interval to make sure all those affected deployments have desired number of pods after node is drained.\n\n## Prerequisites\n\nEKS:\n- PodDisruptionBudget is defined (otherwise one deployment might lose multiple pods during node draining process)\n- Cluster autoscaler is enabled (otherwise if there are not enough resources, the drain will stuck forever)\n\nLocal:\n- python3\n\n## Dependencies\n\n```shell script\npip install -r requirements.txt\n```\n\n## Usage\n\n```shell script\n(venv) tiexin@Tiexins-MacBook-Pro ~/eks-node-drain $ python main.py \nusage: main.py [-h] [--dry-run] node\nmain.py: error: the following arguments are required: node\n```\n\n### Example - Dry Run:\n```shell script\npython main.py ip-44-135-6-147.eu-central-1.compute.internal --dry-run \n```\nThis only shows you what pods will be evicted and which deployments are affected.\n\n### Example - Drain Node:\n```shell script\npython main.py ip-44-135-6-147.eu-central-1.compute.internal \n```\n\n## Todo\n\nA wrapper shell script that loops over all nodes with this script.\n\nAfter draining the node, you need to deleting the node from EKS and deleting the EC2 instance.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fironcore864%2Feks-node-drain","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fironcore864%2Feks-node-drain","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fironcore864%2Feks-node-drain/lists"}