{"id":16701620,"url":"https://github.com/mruoss/flame_k8s_backend","last_synced_at":"2025-05-16T19:08:03.020Z","repository":{"id":211638016,"uuid":"729635057","full_name":"mruoss/flame_k8s_backend","owner":"mruoss","description":"A FLAME Backend for Kubernetes. ","archived":false,"fork":false,"pushed_at":"2025-05-10T01:32:28.000Z","size":177,"stargazers_count":113,"open_issues_count":2,"forks_count":7,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-05-10T02:31:16.324Z","etag":null,"topics":["elixir","flame","kubernetes"],"latest_commit_sha":null,"homepage":"","language":"Elixir","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/mruoss.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE.md","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,"zenodo":null},"funding":{"github":["mruoss"]}},"created_at":"2023-12-09T21:12:14.000Z","updated_at":"2025-05-10T01:32:23.000Z","dependencies_parsed_at":"2024-04-12T16:37:10.853Z","dependency_job_id":"9d8d2653-444f-49bc-b770-dc5275ef45d8","html_url":"https://github.com/mruoss/flame_k8s_backend","commit_stats":null,"previous_names":["mruoss/flame_k8s_backend"],"tags_count":20,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mruoss%2Fflame_k8s_backend","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mruoss%2Fflame_k8s_backend/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mruoss%2Fflame_k8s_backend/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mruoss%2Fflame_k8s_backend/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mruoss","download_url":"https://codeload.github.com/mruoss/flame_k8s_backend/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254592395,"owners_count":22097013,"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":["elixir","flame","kubernetes"],"created_at":"2024-10-12T18:44:53.218Z","updated_at":"2025-05-16T19:08:02.994Z","avatar_url":"https://github.com/mruoss.png","language":"Elixir","funding_links":["https://github.com/sponsors/mruoss"],"categories":[],"sub_categories":[],"readme":"# FLAMEK8sBackend\n\nA [FLAME](https://github.com/phoenixframework/flame/tree/main) Backend for\nKubernetes. Manages pods as runners in the cluster the app is running in.\n\n[![Module Version](https://img.shields.io/hexpm/v/flame_k8s_backend.svg)](https://hex.pm/packages/flame_k8s_backend)\n[![Last Updated](https://img.shields.io/github/last-commit/mruoss/flame_k8s_backend.svg)](https://github.com/mruoss/flame_k8s_backend/commits/main)\n\n[![Hex Docs](https://img.shields.io/badge/hex-docs-lightgreen.svg)](https://hexdocs.pm/flame_k8s_backend/)\n[![Total Download](https://img.shields.io/hexpm/dt/flame_k8s_backend.svg)](https://hex.pm/packages/flame_k8s_backend)\n[![License](https://img.shields.io/hexpm/l/flame_k8s_backend.svg)](https://github.com/mruoss/flame_k8s_backend/blob/main/LICENSE)\n\nThe current implementation is very basic and more like a proof of concept.\nMore configuration options (resources, etc.) will follow.\n\n## Installation\n\n```elixir\ndef deps do\n  [\n    {:flame_k8s_backend, \"~\u003e 0.5.0\"}\n  ]\nend\n```\n\n## Usage\n\nConfigure the flame backend in our configuration or application setup:\n\n```elixir\n  # application.ex\n  children = [\n    {FLAME.Pool,\n      name: MyApp.SamplePool,\n      backend: FLAMEK8sBackend,\n      min: 0,\n      max: 10,\n      max_concurrency: 5,\n      idle_shutdown_after: 30_000,\n      log: :debug}\n  ]\n```\n\n## Prerequisites\n\n### Env Variables\n\nIn order for the runners to be able to join the cluster, you need to configure\na few environment variables on your pod/deployment:\n\nThe `POD_NAME` and `POD_NAMESPACE` are used by the backend to get informations\nfrom your pod and use them for the runner pods (e.g. env variables).\n\n```yaml\napiVersion: apps/v1\nkind: Deployment\nspec:\n  selector:\n    matchLabels:\n      app: myapp\n  template:\n    spec:\n      containers:\n        - env:\n            - name: POD_NAME\n              valueFrom:\n                fieldRef:\n                  apiVersion: v1\n                  fieldPath: metadata.name\n            - name: POD_NAMESPACE\n              valueFrom:\n                fieldRef:\n                  apiVersion: v1\n                  fieldPath: metadata.namespace\n```\n\n### RBAC\n\nYour application needs run as a service account with permissions to manage\npods:\n\n```yaml\n---\napiVersion: v1\nkind: ServiceAccount\nmetadata:\n  name: myapp\n  namespace: app-namespace\n---\napiVersion: rbac.authorization.k8s.io/v1\nkind: Role\nmetadata:\n  namespace: app-namespace\n  name: pod-mgr\nrules:\n  - apiGroups: [\"\"]\n    resources: [\"pods\"]\n    verbs: [\"create\", \"get\", \"list\", \"delete\", \"patch\"]\n---\napiVersion: rbac.authorization.k8s.io/v1\nkind: RoleBinding\nmetadata:\n  name: myapp-pod-mgr\n  namespace: app-namespace\nsubjects:\n  - kind: ServiceAccount\n    name: myapp\n    namespace: app-namespace\nroleRef:\n  kind: Role\n  name: pod-mgr\n  apiGroup: rbac.authorization.k8s.io\n---\napiVersion: apps/v1\nkind: Deployment\nspec:\n  template:\n    spec:\n      serviceAccountName: my-app\n```\n\n### Clustering\n\nYour application needs to be able to form a cluster with your runners. Define\n`POD_IP`, `RELEASE_DISTRIBUTION` and `RELEASE_NODE` environment variables on\nyour pods as follows:\n\n```yaml\napiVersion: apps/v1\nkind: Deployment\nspec:\n  template:\n    spec:\n      containers:\n        - env:\n            - name: POD_IP\n              valueFrom:\n                fieldRef:\n                  apiVersion: v1\n                  fieldPath: status.podIP\n            - name: RELEASE_DISTRIBUTION\n              value: name\n            - name: RELEASE_NODE\n              value: my_app@$(POD_IP)\n```\n\n## How it works\n\nThe FLAME Kubernetes backend first queries the Kubernetes API server to extract\ninformation from the running Pod like the container image, resource requests and\nlimits, environment variables etc. This information is then used to build the\nmanifest for the runner pod. The backend then sends the resulting manifest to\nthe API server in order to spin up a runner pod.\n\n## Troubleshooting\n\n### My runner Pod disappears / gets killed after only a few seconds\n\nIf your parent is part of a Deployment, make sure your FLAME runner Pod doesn't\ncontain the labels you used as selectors (i.e. `.spec.selector` on your\nDeployment). Otherwise the replica controller sees your FLAME runner as an\nadditional Pod to the Deployment's ReplicaSet and \"downscales\" the deployment to\nthe desired replica count (i.e. snipes your runner Pod).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmruoss%2Fflame_k8s_backend","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmruoss%2Fflame_k8s_backend","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmruoss%2Fflame_k8s_backend/lists"}