model

package
v0.10.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 14, 2025 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ImageStorePVCName         = "ollama-models-store-pvc"
	ImageStoreStatefulSetName = "ollama-models-store"
)
View Source
const (
	OllamaBaseImage = "ollama/ollama"
)

Variables

This section is empty.

Functions

func AppendIfNotFound added in v0.10.0

func AppendIfNotFound[T any](source []T, predicate func(item T) bool, newFn func() T) []T

func AssignOllamaPullerContainer added in v0.10.0

func AssignOllamaPullerContainer(name string, image string, serverLocatedNamespace string, resources corev1.ResourceRequirements, extraEnvFrom []corev1.EnvFromSource, extraEnv []corev1.EnvVar) func(container corev1.Container, _ int) corev1.Container

func AssignOllamaServerContainer added in v0.10.0

func AssignOllamaServerContainer(readOnly bool, resources corev1.ResourceRequirements, extraEnvFrom []corev1.EnvFromSource, extraEnv []corev1.EnvVar) func(container corev1.Container, _ int) corev1.Container

func AssignOrAppend added in v0.10.0

func AssignOrAppend[T any](source []T, predicate func(item T) bool, modifier func(item T, index int) T, newFn func() T) []T

func ClientFromContext added in v0.10.0

func ClientFromContext(ctx context.Context, key ...baseClientContextKey) client.Client

func EnsureDeploymentCreated

func EnsureDeploymentCreated(
	ctx context.Context,
	namespace string,
	name string,
	image string,
	replicas *int32,
	model *ollamav1.Model,
) (*appsv1.Deployment, error)

func EnsureImageStorePVCCreated

func EnsureImageStorePVCCreated(
	ctx context.Context,
	namespace string,
	storageClassName *string,
	pvcSource *corev1.PersistentVolumeClaimVolumeSource,
	pvSpec *ollamav1.ModelPersistentVolumeSpec,
) (*corev1.PersistentVolumeClaim, error)

func EnsureImageStoreServiceCreated

func EnsureImageStoreServiceCreated(
	ctx context.Context,
	namespace string,
	statefulSet *appsv1.StatefulSet,
) (*corev1.Service, error)

func EnsureImageStoreStatefulSetCreated

func EnsureImageStoreStatefulSetCreated(
	ctx context.Context,
	namespace string,
	model *ollamav1.Model,
) (*appsv1.StatefulSet, error)

func EnsureServiceCreated

func EnsureServiceCreated(
	ctx context.Context,
	namespace string,
	name string,
	deployment *appsv1.Deployment,
) (*corev1.Service, error)

func FindOllamaPullerContainer added in v0.10.0

func FindOllamaPullerContainer(container corev1.Container) bool

func FindOllamaServerContainer added in v0.10.0

func FindOllamaServerContainer(container corev1.Container) bool

func ImageStoreLabels added in v0.5.2

func ImageStoreLabels() map[string]string

func IsAvailable added in v0.2.0

func IsAvailable(ctx context.Context, ollamaModelResource ollamav1.Model) bool

func IsDeploymentReady

func IsDeploymentReady(
	ctx context.Context,
	namespace string,
	name string,
) (bool, error)

func IsImageStoreServiceReady

func IsImageStoreServiceReady(
	ctx context.Context,
	namespace string,
) (bool, error)

func IsImageStoreStatefulSetReady

func IsImageStoreStatefulSetReady(
	ctx context.Context,
	namespace string,
) (bool, error)

func IsProgressing added in v0.2.0

func IsProgressing(ctx context.Context, ollamaModelResource ollamav1.Model) bool

func IsServiceReady

func IsServiceReady(
	ctx context.Context,
	namespace string,
	name string,
) (bool, error)

func MergePodTemplate added in v0.10.0

func MergePodTemplate(
	ctx context.Context,
	namespace string,
	name string,
	image string,
	replicas *int32,
	model *ollamav1.Model,
) corev1.PodTemplateSpec

func ModelAnnotations added in v0.5.0

func ModelAnnotations(name string, imageStore bool) map[string]string

func ModelAppName

func ModelAppName(name string) string

func ModelLabels added in v0.5.0

func ModelLabels(name string) map[string]string

func ModelServiceName added in v0.10.2

func ModelServiceName(name string) string

func NewClientContextKey added in v0.10.0

func NewClientContextKey(key string) baseClientContextKey

func NewOllamaPullerContainer

func NewOllamaPullerContainer(name string, image string, serverLocatedNamespace string, resources corev1.ResourceRequirements, extraEnvFrom []corev1.EnvFromSource, extraEnv []corev1.EnvVar) corev1.Container

func NewOllamaServerContainer

func NewOllamaServerContainer(readOnly bool, resources corev1.ResourceRequirements, extraEnvFrom []corev1.EnvFromSource, extraEnv []corev1.EnvVar) corev1.Container

func NewServiceForModel added in v0.4.0

func NewServiceForModel(namespace, name string, deployment *appsv1.Deployment, serviceType corev1.ServiceType) *corev1.Service

func NewWrappedRecorderContextKey added in v0.10.0

func NewWrappedRecorderContextKey(key string) baseWrapperRecorderContextKey

func SetAvailable added in v0.2.0

func SetAvailable(
	ctx context.Context,
	ollamaModelResource *ollamav1.Model,
) (bool, error)

func SetProgressing added in v0.2.0

func SetProgressing(
	ctx context.Context,
	c client.Client,
	ollamaModelResource ollamav1.Model,
) (bool, error)

func SetReplicas added in v0.2.0

func SetReplicas(
	ctx context.Context,
	ollamaModelResource *ollamav1.Model,
	replicas int32,
	readyReplicas int32,
	availableReplicas int32,
	unavailableReplicas int32,
) (bool, error)

func ShouldSetReplicas added in v0.2.0

func ShouldSetReplicas(
	ctx context.Context,
	ollamaModelResource *ollamav1.Model,
	replicas int32,
	readyReplicas int32,
	availableReplicas int32,
	unavailableReplicas int32,
) bool

func UniqEnvVar added in v0.10.0

func UniqEnvVar(env []corev1.EnvVar) []corev1.EnvVar

func UpdateDeployment

func UpdateDeployment(
	ctx context.Context,
	model *ollamav1.Model,
) (bool, error)

func WithClient added in v0.10.0

func WithClient(ctx context.Context, client client.Client, key ...baseClientContextKey) context.Context

func WithWrappedRecorder added in v0.10.0

func WithWrappedRecorder[T runtime.Object](ctx context.Context, recorder *WrappedRecorder[T], key ...baseWrapperRecorderContextKey) context.Context

Types

type WrappedRecorder

type WrappedRecorder[T runtime.Object] struct {
	// contains filtered or unexported fields
}

func NewWrappedRecorder

func NewWrappedRecorder[T runtime.Object](recorder record.EventRecorder, object T) *WrappedRecorder[T]

func WrappedRecorderFromContext added in v0.10.0

func WrappedRecorderFromContext[T runtime.Object](ctx context.Context, key ...baseWrapperRecorderContextKey) *WrappedRecorder[T]

func (*WrappedRecorder[T]) AnnotatedEventf

func (r *WrappedRecorder[T]) AnnotatedEventf(annotations map[string]string, eventType, reason, messageFmt string, args ...any)

AnnotatedEventf is just like eventf, but with annotations attached

func (*WrappedRecorder[T]) Event

func (r *WrappedRecorder[T]) Event(eventType, reason, message string)

func (*WrappedRecorder[T]) Eventf

func (r *WrappedRecorder[T]) Eventf(eventType, reason, messageFmt string, args ...any)

Eventf is just like Event, but with Sprintf for the message field.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL