Skip to content

Commit

Permalink
Add some examples of flame pool configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
sleipnir committed Dec 15, 2023
1 parent 1314ae5 commit 3e365f8
Show file tree
Hide file tree
Showing 3 changed files with 124 additions and 35 deletions.
80 changes: 77 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ end
You need to enable Flame in Kubernetes as well. See the example below:

```yaml
# my-application.yaml
---
apiVersion: apps/v1
kind: Deployment
Expand All @@ -55,8 +56,8 @@ spec:
flame.org/otp-app: "my_app_release_name"
spec:
containers:
- image: eigr/spawn-operator:1.1.1
name: spawn-operator
- image: eigr/flame-parent-example:1.1.1
name: flame-parent-example
resources:
limits:
cpu: 200m
Expand Down Expand Up @@ -91,4 +92,77 @@ Now you can start scaling your applications with [Flame](https://github.com/phoe
## Configuration
TODO
TODO
### 1. Flame Runner Pool
The Flame k8s Controller gives you the possibility to configure different runner profiles. These profiles will be used when creating PODs to run Runners in Kubernetes.
To configure a new Runner Pool, simply define the following yaml file and apply it to the Kubernetes cluster.
```yaml
# my-runner.yaml
---
apiVersion: flame.org/v1
kind: FlamePool
metadata:
name: my-runner-pool
namespace: default
spec:
podTemplate:
spec: # This is a pod template specification. See https://kubernetes.io/docs/concepts/workloads/pods/#pod-templates
containers:
- env:
- name: MY_VAR
value: "my-value"
resources:
limits:
cpu: 200m
memory: 1Gi
requests:
cpu: 200m
memory: 2Gi
volumeMounts:
- mountPath: /app/.cache/bakeware/
name: bakeware-cache
volumes:
- name: bakeware-cache
emptyDir: {}
```
Then:
```sh
kubectl apply -f my-runner.yaml
```

Once this is done, simply add the annotation `flame.org/pool-config-ref` to your Deployment file. Example:

```yaml
# my-application.yaml
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: flame-parent-example
namespace: default
spec:
replicas: 1
selector:
matchLabels:
app: flame-parent-example
template:
metadata:
annotations:
flame.org/enabled: "true"
flame.org/pool-config-ref: "my-runner-pool"
spec:
containers:
- image: eigr/flame-parent-example:1.1.1
...
```

You can also list all Runner pools configured on the system with the command:

```sh
kubectl --all-namespaces get pools
```
Original file line number Diff line number Diff line change
Expand Up @@ -10,38 +10,37 @@ defmodule FlameK8sController.Handler.FlamePoolHandler do
spec:
podTemplate:
spec:
containers:
- env:
- name: PHX_SERVER
value: "false"
- name: MIX_ENV
value: prod
- name: POD_NAME
valueFrom:
fieldRef:
fieldPath: metadata.name
- name: POD_NAMESPACE
valueFrom:
fieldRef:
fieldPath: metadata.namespace
- name: POD_IP
valueFrom:
fieldRef:
fieldPath: status.podIP
name: spawn-operator
resources:
limits:
cpu: 200m
memory: 200Mi
requests:
cpu: 200m
memory: 200Mi
volumeMounts:
- mountPath: /app/.cache/bakeware/
name: bakeware-cache
volumes:
- name: bakeware-cache
emptyDir: {}
containers:
- env:
- name: PHX_SERVER
value: "false"
- name: MIX_ENV
value: prod
- name: POD_NAME
valueFrom:
fieldRef:
fieldPath: metadata.name
- name: POD_NAMESPACE
valueFrom:
fieldRef:
fieldPath: metadata.namespace
- name: POD_IP
valueFrom:
fieldRef:
fieldPath: status.podIP
resources:
limits:
cpu: 200m
memory: 200Mi
requests:
cpu: 200m
memory: 200Mi
volumeMounts:
- mountPath: /app/.cache/bakeware/
name: bakeware-cache
volumes:
- name: bakeware-cache
emptyDir: {}
"""
@behaviour Pluggable

Expand Down
16 changes: 16 additions & 0 deletions flame_k8s_controller/lib/flame_k8s_controller/operator.ex
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ defmodule FlameK8sController.Operator do
%{
query: K8s.Client.watch("flame.org/v1", "FlameRunner", namespace: watching_namespace),
controller: FlameK8sController.Controller.FlameRunner
},
%{
query: K8s.Client.watch("flame.org/v1", "FlamePool", namespace: watching_namespace),
controller: FlameK8sController.Controller.FlamePool
}
]
end
Expand All @@ -39,6 +43,18 @@ defmodule FlameK8sController.Operator do
group: "flame.org",
scope: :Namespaced,
versions: [FlameK8sController.Versions.Api.V1.FlameRunner]
),
Bonny.API.CRD.new!(
names:
Bonny.API.CRD.kind_to_names("FlamePool", [
"framepool",
"framepools",
"pool",
"pools"
]),
group: "flame.org",
scope: :Namespaced,
versions: [FlameK8sController.Versions.Api.V1.FlameRunner]
)
]
end
Expand Down

0 comments on commit 3e365f8

Please sign in to comment.