{"id":21840275,"url":"https://github.com/zapier/preoomkiller-controller","last_synced_at":"2025-04-14T10:51:16.428Z","repository":{"id":43653583,"uuid":"241365152","full_name":"zapier/preoomkiller-controller","owner":"zapier","description":"Preoomkiller Controller evicts pods gracefully before they get OOMKilled by Kubernetes","archived":false,"fork":false,"pushed_at":"2021-09-18T17:33:32.000Z","size":17,"stargazers_count":24,"open_issues_count":3,"forks_count":6,"subscribers_count":16,"default_branch":"master","last_synced_at":"2025-03-28T00:04:50.778Z","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":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/zapier.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}},"created_at":"2020-02-18T13:16:28.000Z","updated_at":"2024-10-30T02:02:58.000Z","dependencies_parsed_at":"2022-08-30T01:40:35.430Z","dependency_job_id":null,"html_url":"https://github.com/zapier/preoomkiller-controller","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zapier%2Fpreoomkiller-controller","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zapier%2Fpreoomkiller-controller/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zapier%2Fpreoomkiller-controller/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zapier%2Fpreoomkiller-controller/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zapier","download_url":"https://codeload.github.com/zapier/preoomkiller-controller/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248868838,"owners_count":21174754,"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-11-27T21:25:28.693Z","updated_at":"2025-04-14T10:51:16.408Z","avatar_url":"https://github.com/zapier.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# preoomkiller-controller\n\nA controller to gracefully evict selected pods before they get **OOMKilled** by\n**Kubernetes**.\n\n# How it works?\n\n`preoomkiller-controller` watches (once every `60s` by default) memory usage\nmetrics for all pods matching label selector `preoomkiller-enabled=true`.\nPods can specify a **preoomkiller** `memory-threshold`, e.g., `512Mi`, `1Gi`, etc.\nvia an annotation `preoomkiller.alpha.k8s.zapier.com/memory-threshold`.\nWhen `preoomkiller-controller` finds that the pods' memory usage has crossed\nthe specified threshold, it starts trying to evict the pod, until it's evicted.\n\nThis operation is very safe, as it uses Kubernetes' pod **eviction** API to\nevict pods. Pod eviction API takes into account **PodDisruptionBudget** for\nthe pods and ensures that a specified minimum number of ready pods are always\navailable.\n\n# Usage\n\n## Deploy\n\n### Setup RBAC\n\n```\nkubectl -n kube-system create serviceaccount preoomkiller-controller\n\ncat \u003c\u003cEOF | kubectl apply -f -\nkind: ClusterRole\nmetadata:\n  name: preoomkiller-controller\nrules:\n- apiGroups:\n  - \"\"\n  resources:\n  - pods\n  verbs:\n  - get\n  - watch\n  - list\n- apiGroups:\n  - metrics.k8s.io\n  resources:\n  - pods\n  verbs:\n  - get\n  - list\n  - watch\n- apiGroups:\n  - \"\"\n  resources:\n  - pods/eviction\n  verbs:\n  - create\nEOF\n\nkubectl create clusterrolebinding preoomkiller-controller --clusterrole=preoomkiller-controller --serviceaccount=kube-system:preoomkiller-controller\n```\n\n### Deploy controller\n\n```\nkubectl -n kube-system run --image=zapier/preoomkiller-controller:latest --serviceaccount=preoomkiller-controller\n```\n\n### Add labels, annotations to pods\n\nYou can configure pods, deployments, statefulsets, daemonsets to add:\n\n- Pod label `preoomkiller-enabled: true`\n- Pod annotation: `preoomkiller.alpha.k8s.zapier.com/memory-threshold: 2Gi`\n\nFor example:\n\n```\napiVersion: v1\nkind: Pod\nmetadata:\n  name: annotations-demo\n  labels:\n    preoomkiller-enabled: true\n  annotations:\n    imageregistry: \"https://hub.docker.com/\"\n    preoomkiller.alpha.k8s.zapier.com/memory-threshold: 2Gi\nspec:\n  containers:\n  - name: nginx\n    image: nginx:1.7.9\n    ports:\n    - containerPort: 80\n ```\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzapier%2Fpreoomkiller-controller","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzapier%2Fpreoomkiller-controller","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzapier%2Fpreoomkiller-controller/lists"}