{"id":13585041,"url":"https://github.com/dgzlopes/termination-handler","last_synced_at":"2025-03-23T22:33:07.472Z","repository":{"id":57474305,"uuid":"201414703","full_name":"dgzlopes/termination-handler","owner":"dgzlopes","description":"Handle termination notices on spot/preemptible instances.","archived":false,"fork":false,"pushed_at":"2020-07-20T20:02:40.000Z","size":46,"stargazers_count":10,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-18T08:54:04.890Z","etag":null,"topics":["aws","devops","docker","gcp","kubernetes","nomad","preemptible","python","spot","spot-instances","termination"],"latest_commit_sha":null,"homepage":"https://pypi.org/project/termination-handler/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dgzlopes.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-08-09T07:24:56.000Z","updated_at":"2023-10-18T10:46:27.000Z","dependencies_parsed_at":"2022-09-12T19:40:23.351Z","dependency_job_id":null,"html_url":"https://github.com/dgzlopes/termination-handler","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dgzlopes%2Ftermination-handler","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dgzlopes%2Ftermination-handler/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dgzlopes%2Ftermination-handler/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dgzlopes%2Ftermination-handler/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dgzlopes","download_url":"https://codeload.github.com/dgzlopes/termination-handler/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245179442,"owners_count":20573468,"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":["aws","devops","docker","gcp","kubernetes","nomad","preemptible","python","spot","spot-instances","termination"],"created_at":"2024-08-01T15:04:42.266Z","updated_at":"2025-03-23T22:33:07.195Z","avatar_url":"https://github.com/dgzlopes.png","language":"Python","readme":"# termination-handler\n[![PyPI](https://img.shields.io/pypi/v/cloud-detect.svg)](https://pypi.org/project/termination-handler/)\n[![PyPI - License](https://img.shields.io/pypi/l/cloud-detect.svg)](https://github.com/dgzlopes/termination-handler/blob/master/LICENSE.md)\n## About\n`termination-handler` handles termination notices on spot/preemptible instances.\n\nAs an example, if deployed on a Kubernetes cluster and a termination notice is issued by the cloud provider, `termination-handler` drains the node it is running on before the node is taken away by the cloud provider.\n\nInspired by [pusher/k8s-spot-termination-handler](https://github.com/pusher/k8s-spot-termination-handler) for AWS, `termination-handler` surges from the need to operate the same tooling in various distinct environments (providers, orchestrators...)\n\n## Features\n- Supports multiple cloud providers (AWS, GCP).\n- Supports multiple handlers (Kubernetes, Nomad, Slack).\n- Small and extensible.\n\n## Documentation\nTBD\n## Usage\n### Deploy to Kubernetes\n\nA K8s docker image is available at [`dgzlopes/termination-handler-k8s`](https://hub.docker.com/r/dgzlopes/termination-handler-k8s) and sample Kubernetes manifests are available in the [deploy/k8s](deploy/k8s) folder.\n\nTo deploy in clusters using RBAC, please apply all of the manifests (Daemonset, ClusterRole, ClusterRoleBinding and ServiceAccount) in the [deploy/k8s](deploy/k8s) folder but uncomment the `serviceAccountName` in the [Daemonset](deploy/k8s/daemonset.yaml).\n\n#### Requirements\n\nFor `termination-handler` to schedule correctly; you will need an identifying label on your spot/preemptible instances.\n\nWe add a label `node-role.kubernetes.io/spot-worker` to our spot/preemptible instances and hence this is the default value in the node selector of the [Daemonset](deploy/k8s/daemonset.yaml).\n```yaml\nnodeSelector:\n  \"node-role.kubernetes.io/spot-worker\": \"true\"\n```\nTo achieve this, add the following flag to your Kubelet:\n```\n--node-labels=\"node-role.kubernetes.io/spot-worker=true\"\n```\n\n#### Configuration\n\nTo define any custom parameters to the drain command you can use `DRAIN_PARAMETERS` environment property. If not defined, default parameters are `--grace-period=120 --force --ignore-daemonsets`.\n```yaml\nenv:\n  - name: DRAIN_PARAMETERS\n    value: '--grace-period=120 --force --ignore-daemonsets --delete-local-data'\n```\n### Deploy to Nomad\nA Nomad docker image is available at [`dgzlopes/termination-handler-nomad`](https://hub.docker.com/r/dgzlopes/termination-handler-nomad).\n\nTBD\n\n### Demo mode\n\nThe main way to use termination-handler is waiting for the termination notice from the cloud provider. However, termination-handler comes with a demo mode that is can simulate the notice. When deployed it will identify your cloud provider and run your handlers.\n\nTo activate termination-handler demo mode on Kubernetes, you can use `DEMO_TERMINATION_HANDLER` environment property.\n```yaml\nenv:\n  - name: DEMO_TERMINATION_HANDLER\n    value: True\n```\n\n### Other handlers\n#### Slack\nSends a notification message to a specific channel when a termination notice is issued.\n\n## How to contribute\n1. Check for open issues or open a fresh issue to start a discussion around a feature idea or a bug.\n2. Fork [the repository](https://github.com/dgzlopes/termination-handler) on GitHub to start making your changes to the master branch (or branch off of it).\n3. Write a test which shows that the bug was fixed or that the feature works as expected.\n4. Send a [pull request](https://help.github.com/en/articles/creating-a-pull-request-from-a-fork) and bug [me](https://github.com/dgzlopes) until it gets merged and published.\n\nSome things that would be great to have:\n- Support for Execution handler (certain command or task)\n- Support for notifications (Datadog..)\n- Option to omit selected cloud provider discovery.\n","funding_links":[],"categories":["Python"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdgzlopes%2Ftermination-handler","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdgzlopes%2Ftermination-handler","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdgzlopes%2Ftermination-handler/lists"}