{"id":17888101,"url":"https://github.com/fireflycons/terminator","last_synced_at":"2025-04-03T02:42:28.499Z","repository":{"id":96974371,"uuid":"602931256","full_name":"fireflycons/terminator","owner":"fireflycons","description":"Auto terminate pods in a Kubernetes cluster that just won't die.","archived":false,"fork":false,"pushed_at":"2023-02-22T05:39:42.000Z","size":61,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-02-08T16:44:08.854Z","etag":null,"topics":[],"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/fireflycons.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":"2023-02-17T08:53:06.000Z","updated_at":"2024-01-14T14:50:34.000Z","dependencies_parsed_at":null,"dependency_job_id":"6bff191d-d586-4962-b4b6-27ba3c2ba06b","html_url":"https://github.com/fireflycons/terminator","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/fireflycons%2Fterminator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fireflycons%2Fterminator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fireflycons%2Fterminator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fireflycons%2Fterminator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fireflycons","download_url":"https://codeload.github.com/fireflycons/terminator/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246927809,"owners_count":20856193,"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":[],"created_at":"2024-10-28T13:36:33.549Z","updated_at":"2025-04-03T02:42:28.479Z","avatar_url":"https://github.com/fireflycons.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# The Terminator\n\n[![Docker](https://img.shields.io/docker/v/fireflycons/terminator?style=plastic)](https://hub.docker.com/r/fireflycons/terminator)\n\n\nEver get the situation when you find some pods in your cluster just will not die? They've been stuck in the `Terminating` state for long past their grace period? This is for you!\n\nI've found that there are sometimes pods that get in this state following a full cluster shutdown and restart - by full shutdown I mean stopping the instances that the cluster is running on, then when the instances are restarted, some pods (in my case `nfs-subdir-external-provisioner`) are never cleaned up from the previous shutdown and rematerialize in a `Terminating` state, even though the containers that back the pods are long since gone.\n\nThis tool works by scanning all pods in the cluster (static pods excluded) every so often for pods where the `deletionTimestamp` is longer ago than the current time minus the grace period. These pods are then force-terminated.\n\nNote that you should attempt to find out why you have pods in these states, and use this tool as a last resort, i.e. there's no good reason why they shouldn't terminate.\n\n## Command line arguments\n\nAll the following are optional.\n\n```\nUsage: terminator\n\nFlags:\n  -h, --help                    Show context-sensitive help.\n  -d, --dry-run                 If set, do not delete anything.\n  -g, --grace-period=1h         Additional grace period added to that of the pod\n                                in Go duration syntax, e.g 2m, 1h etc.\n  -i, --interval=5m             Interval between scans of the cluster in Go\n                                duration syntax, e.g 2m, 1h etc.\n  -k, --kubeconfig=STRING       Specify a kubeconfig for authentication.\n                                If not set, then in cluster authentication is\n                                attempted.\n  -n, --namespaces=NAMESPACES,...\n                                If set, list of namespaces to limit scans to.\n                                If not set, all namespaces are scanned.\n  -p, --pods=PODS,...           If set, list of pod name prefixes. Pods whose\n                                names begin with these prefixes will only\n                                be considered. If not set, all pods will be\n                                considered.\n  -r, --no-remove-finalizers    If set, do not remove any finalizers before\n                                attempting delete.\n  -s, --startup-delay=15m       Time to wait between launching and first scan\n                                of the cluster in Go duration syntax, e.g 2m,\n                                1h etc.\n  -l, --log-level=\"info\"        Sets the loglevel. Valid levels are debug, info,\n                                warn, error.\n  -f, --log-format=\"logfmt\"     Sets the log format. Valid formats are json and\n                                logfmt.\n  -o, --log-output=\"stdout\"     Sets the log output. Valid outputs are stdout\n                                and stderr.\n```\n\n## Installation\n\nA helm chart is provided [here](./charts)\n\n\u003cdetails\u003e\n\u003csummary\u003eThe following values may be set. Expand to see:\u003c/summary\u003e\n\u003cbr/\u003e\n\n| Argument                   | Type   | Description                                                    | Default                |\n|----------------------------|--------|----------------------------------------------------------------|------------------------|\n| image.repository           | string | Repo to get image from                                         | fireflycons/terminator |\n| image.tag                  | string | Image tag. If unset, taken from chart's `appVersion`           | Unset                  |\n| image.pullPolicy           | string | Pull policy for the image                                      | IfNotPresent           |\n| args                       | list   | List of command arguments to pass to the container             | []                     |\n| imageCredentials           | object | Object to declare container repo credentials for private repos | {}                     |\n| imageCredentials.registry  | string | Private registry to authenticate with                          | unset                  |\n| imageCredentials.username  | string | Registry username                                              | unset                  |\n| imageCredentials.password  | string | Registry password                                              | unset                  |\n| serviceAccount.create      | bool   | Whether to create a service account for the pod                | true                   |\n| serviceAccount.Annotations | object | Any additional annotations to add to the SA                    | {}                     |\n| podAnnotations             | object | Any additional annotations to add to the pod                   | {}                     |\n| podSecurityContext         | object | Security context to add to the pod                             | {}                     |\n| resources.limits.cpu       | string | CPU limit for pod                                              | 50m                    |\n| resources.limits.memory    | string | Memory limit for pod                                           | 64Mi                   |\n| resources.requests.cpu     | string | CPU request for pod                                            | 50m                    |\n| resources.requests.memory  | string | Memory request for pod                                         | 64Mi                   |\n| nodeSelector               | object | Specific node selector for pod                                 | {}                     |\n| tolerations                | list   | Tolerations for pod                                            | []                     |\n| affinity                   | object | Affinity for pod                                               | {}                     |\n\n\u003c/details\u003e\n\n## Log output\n\nLogs are output as several key-value pairs to make ingestion into log analysers like ElasticSearch easier. The logs may be emitted as plain text (default) or JSON by setting `--log-format`\n\nMost messages are emitted at `info` level. When a pod is terminated, messages about the termination are emitted at `warn` level and exceptions at `error` level.\n\n\u003cdetails\u003e\n\u003csummary\u003eLog Fields\u003c/summary\u003e\n\nThe following log fields are always emitted\n\n| Key       | Value                                                  |\n|-----------|--------------------------------------------------------|\n| `level`   | Logging level (severity) of message.                   |\n| `ts`      | Timestamp in ISO-8601 format.                          |\n| `caller`  | Location in the code where the log message was raised. |\n| `message` | The message text.                                      |\n\nSome or all of the following fields may be included depending on context.\n\n| Key          | Value                                              |\n|--------------|----------------------------------------------------|\n| `namespace`  | Namespace in which the operation occurs.           |\n| `pod`        | Pod which is being operated on.                    |\n| `finalizers` | Lists any finalizers on pod where relevant.        |\n| `exception`  | Any specific exception detail if an error occurs.  |\n\n\u003c/details\u003e\n\n## Simple Test\n\n1. Install terminator in your cluster. Set `--interval`, `--startup-delay` and `--grace-period` to really small values so you don't have to wait too long.\n\n1. Create a pod with a dummy finalizer\n\n    ```yaml\n    apiVersion: v1\n    kind: Pod\n    metadata:\n      finalizers:\n      - kubernetes\n      labels:\n        run: testpod\n      name: testpod\n      namespace: default\n    spec:\n      containers:\n      - image: nginx:alpine\n        name: testpod\n    ```\n\n1. After it's come up, delete it\n\n    ```\n    kubectl delete pod -n default testpod\n    ```\n\n    It should be stuck terminating.\n\n1. Wait for terminator to do its next cluster scan. The pod should delete. Examine the terminator pod logs.\n\nAfter testing, ensure to set the intervals back to sensible or default values!\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffireflycons%2Fterminator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffireflycons%2Fterminator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffireflycons%2Fterminator/lists"}