Skip to content

Commit

Permalink
fix: preloading issue
Browse files Browse the repository at this point in the history
Signed-off-by: Neko Ayaka <[email protected]>
  • Loading branch information
nekomeowww committed Aug 23, 2024
1 parent 4491bef commit 6f2455a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion pkg/model/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ func EnsureDeploymentCreated(
},
Spec: corev1.PodSpec{
InitContainers: []corev1.Container{
NewOllamaPullerContainer(image, namespace, model.Spec.Resources),
NewOllamaPullerContainer(name, image, namespace, model.Spec.Resources),
},
Containers: []corev1.Container{
NewOllamaServerContainer(true, model.Spec.Resources),
Expand Down
10 changes: 7 additions & 3 deletions pkg/model/pod.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,17 @@ func NewOllamaServerContainer(readOnly bool, resources corev1.ResourceRequiremen
}
}

func NewOllamaPullerContainer(image string, serverLocatedNamespace string, resources corev1.ResourceRequirements) corev1.Container {
func NewOllamaPullerContainer(name string, image string, serverLocatedNamespace string, resources corev1.ResourceRequirements) corev1.Container {
return corev1.Container{
Name: "ollama-image-pull",
Image: OllamaBaseImage,
Command: []string{
"bash",
},
Args: []string{
"pull",
image,
"-c",
// TODO: This is a temporary solution, we need to find a better way to preload the models
fmt.Sprintf("apt install curl -y && ollama pull %s && curl http://ollama-models-store:11434/api/generate -d '{\"model\": \"%s\"}'"+image, name),
},
Env: []corev1.EnvVar{
{
Expand Down

0 comments on commit 6f2455a

Please sign in to comment.