Skip to content

Commit 1d09c42

Browse files
authored
feat(controller): watch run.yaml configmap for updates (#68)
Updates the operator's controller to watch for the changes to the ConfigMap specified in the LlamaStackDistribution CR. Closes: #12 --------- Signed-off-by: Doug Edgar <dedgar@redhat.com>
1 parent 23867eb commit 1d09c42

13 files changed

+887
-67
lines changed

README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,16 @@ spec:
7070
```
7171
3. Verify the server pod is running in the user defined namespace.
7272

73+
### Using a ConfigMap for run.yaml configuration
74+
75+
A ConfigMap can be used to store run.yaml configuration for each LlamaStackDistribution.
76+
Updates to the ConfigMap will restart the Pod to load the new data.
77+
78+
Example to create a run.yaml ConfigMap, and a LlamaStackDistribution that references it:
79+
```
80+
kubectl apply -f config/samples/example-with-configmap.yaml
81+
```
82+
7383
## Developer Guide
7484

7585
### Prerequisites

api/v1alpha1/llamastackdistribution_types.go

Lines changed: 13 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/v1alpha1/zz_generated.deepcopy.go

Lines changed: 20 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

config/crd/bases/llamastack.io_llamastackdistributions.yaml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1999,6 +1999,21 @@ spec:
19991999
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
20002000
x-kubernetes-int-or-string: true
20012001
type: object
2002+
userConfig:
2003+
description: UserConfig defines the user configuration for the
2004+
llama-stack server
2005+
properties:
2006+
configMapName:
2007+
description: ConfigMapName is the name of the ConfigMap containing
2008+
user configuration
2009+
type: string
2010+
configMapNamespace:
2011+
description: ConfigMapNamespace is the namespace of the ConfigMap
2012+
(defaults to the same namespace as the CR)
2013+
type: string
2014+
required:
2015+
- configMapName
2016+
type: object
20022017
required:
20032018
- distribution
20042019
type: object
@@ -2150,6 +2165,9 @@ spec:
21502165
required:
21512166
- spec
21522167
type: object
2168+
selectableFields:
2169+
- jsonPath: .spec.server.userConfig.configMapName
2170+
- jsonPath: .spec.server.userConfig.configMapNamespace
21532171
served: true
21542172
storage: true
21552173
subresources:

config/rbac/role.yaml

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,25 @@ rules:
88
- ""
99
resources:
1010
- configmaps
11+
verbs:
12+
- '*'
13+
- apiGroups:
14+
- ""
15+
resources:
1116
- deployments
12-
- persistentvolumeclaims
1317
- persistentvolumes
1418
- pods
1519
- pods/exec
1620
- pods/log
1721
verbs:
1822
- '*'
23+
- apiGroups:
24+
- ""
25+
resources:
26+
- persistentvolumeclaims
27+
- services
28+
verbs:
29+
- '*'
1930
- apiGroups:
2031
- ""
2132
resources:
@@ -30,15 +41,14 @@ rules:
3041
- update
3142
- watch
3243
- apiGroups:
33-
- ""
44+
- apps
3445
resources:
35-
- services
46+
- deployments
3647
verbs:
3748
- '*'
3849
- apiGroups:
3950
- apps
4051
resources:
41-
- deployments
4252
- deployments/finalizers
4353
verbs:
4454
- '*'
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
apiVersion: v1
2+
kind: ConfigMap
3+
metadata:
4+
name: llama-stack-config
5+
data:
6+
run.yaml: |
7+
# Llama Stack Configuration
8+
version: '2'
9+
image_name: ollama
10+
apis:
11+
- inference
12+
providers:
13+
inference:
14+
- provider_id: ollama
15+
provider_type: "remote::ollama"
16+
config:
17+
url: "http://ollama-server-service.ollama-dist.svc.cluster.local:11434"
18+
models:
19+
- model_id: "llama3.2:1b"
20+
provider_id: ollama
21+
model_type: llm
22+
server:
23+
port: 8321
24+
---
25+
apiVersion: llamastack.io/v1alpha1
26+
kind: LlamaStackDistribution
27+
metadata:
28+
name: llamastack-with-config
29+
spec:
30+
replicas: 1
31+
server:
32+
distribution:
33+
name: ollama
34+
containerSpec:
35+
port: 8321
36+
env:
37+
- name: INFERENCE_MODEL
38+
value: "llama3.2:1b"
39+
- name: OLLAMA_URL
40+
value: "http://ollama-server-service.ollama-dist.svc.cluster.local:11434"
41+
userConfig:
42+
configMapName: llama-stack-config
43+
# configMapNamespace: "" # Optional - defaults to the same namespace as the CR

0 commit comments

Comments
 (0)