diff --git a/pkg/model/model.go b/pkg/model/model.go index 398af1a..49859cc 100644 --- a/pkg/model/model.go +++ b/pkg/model/model.go @@ -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), diff --git a/pkg/model/pod.go b/pkg/model/pod.go index fa9be1e..af5bcc0 100644 --- a/pkg/model/pod.go +++ b/pkg/model/pod.go @@ -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{ {