controller

package
v0.0.0-...-a8c4e42 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2024 License: Apache-2.0 Imports: 32 Imported by: 0

Documentation

Index

Constants

View Source
const (
	/*** Operator Settings ***/
	// OLSConfigName is the name of the OLSConfig Custom Resource
	OLSConfigName = "cluster"

	/*** application server configuration file ***/
	// OLSConfigName is the name of the OLSConfig configmap
	OLSConfigCmName = "olsconfig"
	// RedisCAConfigMap is the name of the OLS redis server TLS ca certificate configmap
	RedisCAConfigMap = "openshift-service-ca.crt"
	// RedisCAVolume is the name of the OLS redis TLS ca certificate volume name
	RedisCAVolume = "cm-olsredisca"
	// OLSNamespaceDefault is the default namespace for OLS
	OLSNamespaceDefault = "openshift-lightspeed"
	// OLSAppServerServiceAccountName is the name of service account running the application server
	OLSAppServerServiceAccountName = "lightspeed-app-server"
	// OLSAppServerSARRoleName is the name of the SAR role for the service account running the application server
	OLSAppServerSARRoleName = OLSAppServerServiceAccountName + "-sar-role"
	// OLSAppServerSARRoleBindingName is the name of the SAR role binding for the service account running the application server
	OLSAppServerSARRoleBindingName = OLSAppServerSARRoleName + "-binding"
	// OLSAppServerDeploymentName is the name of the OLS application server deployment
	OLSAppServerDeploymentName = "lightspeed-app-server"
	// RedisDeploymentName is the name of OLS application redis deployment
	RedisDeploymentName = "lightspeed-redis-server"
	// APIKeyMountRoot is the directory hosting the API key file in the container
	APIKeyMountRoot = "/etc/apikeys" // #nosec G101
	// CredentialsMountRoot is the directory hosting the credential files in the container
	CredentialsMountRoot = "/etc/credentials"
	// OLSAppCertsMountRoot is the directory hosting the cert files in the container
	OLSAppCertsMountRoot = "/etc/certs"
	// LLMApiTokenFileName is the name of the file containing the API token to access LLM in the secret referenced by the OLSConfig
	LLMApiTokenFileName = "apitoken"
	// OLSComponentPasswordFileName is the generic name of the password file for each of its components
	OLSComponentPasswordFileName = "password"
	// OLSConfigFilename is the name of the application server configuration file
	OLSConfigFilename = "olsconfig.yaml"
	// RedisSecretKeyName is the name of the key holding redis server secret
	RedisSecretKeyName = "password"
	// Image of the OLS application server
	// todo: image vesion should synchronize with the release version of the lightspeed-service-api image.
	OLSAppServerImageDefault = "quay.io/openshift/lightspeed-service-api:latest"
	// AppServerServiceMonitorName is the name of the service monitor for the OLS application server
	AppServerServiceMonitorName = "lightspeed-app-server-monitor"
	// AppServerPrometheusRuleName is the name of the prometheus rules for the OLS application server
	AppServerPrometheusRuleName = "lightspeed-app-server-prometheus-rule"
	// AppServerMetricsPath is the path of the metrics endpoint of the OLS application server
	AppServerMetricsPath = "/metrics"

	// Image of the OLS application redis server
	//RedisServerImageDefault = "quay.io/openshift/lightspeed-service-redis:latest"
	// OLSConfigHashKey is the key of the hash value of the OLSConfig configmap
	OLSConfigHashKey = "hash/olsconfig"
	// LLMProviderHashKey is the key of the hash value of OLS LLM provider credentials consolidated
	// #nosec G101
	LLMProviderHashKey = "hash/llmprovider"
	// RedisConfigHashKey is the key of the hash value of the OLS's redis config
	RedisConfigHashKey = "hash/olsredisconfig"
	// RedisSecretHashKey is the key of the hash value of OLS Redis secret
	// #nosec G101
	RedisSecretHashKey = "hash/redis-secret"
	// RedisServiceName is the name of OLS application redis server service
	RedisServiceName = "lightspeed-redis-server"
	// RedisSecretName is the name of OLS application redis secret
	RedisSecretName = "lightspeed-redis-secret"
	// OLSAppRedisCertsName is the name of the OLS application redis certs secret
	RedisCertsSecretName = "lightspeed-redis-certs"
	// OLSAppServerContainerPort is the port number of the lightspeed-service-api container exposes
	OLSAppServerContainerPort = 8443
	// OLSAppServerServicePort is the port number for OLS application server service.
	OLSAppServerServicePort = 8443
	// OLSAppServerServiceName is the name of the OLS application server service
	OLSAppServerServiceName = "lightspeed-app-server"
	// OLSCertsSecretName is the name of the TLS secret for OLS.
	OLSCertsSecretName = "lightspeed-tls" // #nosec G101
	// RedisServicePort is the port number of the OLS redis server service
	RedisServicePort = 6379
	// RedisMaxMemory is the max memory of the OLS redis cache
	RedisMaxMemory = "1024mb"
	// RedisMaxMemoryPolicy is the max memory policy of the OLS redis cache
	RedisMaxMemoryPolicy = "allkeys-lru"
	// OLSDefaultCacheType is the default cache type for OLS
	OLSDefaultCacheType = "redis"
	// Annotation key for serving certificate secret name
	// #nosec G101
	ServingCertSecretAnnotationKey = "service.beta.openshift.io/serving-cert-secret-name"
	/*** state cache keys ***/
	OLSConfigHashStateCacheKey   = "olsconfigmap-hash"
	LLMProviderHashStateCacheKey = "llmprovider-hash"
	RedisConfigHashStateCacheKey = "olsredisconfig-hash"
	// #nosec G101
	RedisSecretHashStateCacheKey = "olsredissecret-hash"

	/*** console UI plugin ***/
	// ConsoleUIConfigMapName is the name of the console UI nginx configmap
	ConsoleUIConfigMapName = "lightspeed-console-plugin"
	// ConsoleUIServiceCertSecretName is the name of the console UI service certificate secret
	ConsoleUIServiceCertSecretName = "lightspeed-console-plugin-cert"
	// ConsoleUIServiceName is the name of the console UI service
	ConsoleUIServiceName = "lightspeed-console-plugin"
	// ConsoleUIDeploymentName is the name of the console UI deployment
	ConsoleUIDeploymentName = "lightspeed-console-plugin"
	// ConsoleUIImage is the image of the console UI plugin
	ConsoleUIImageDefault = "quay.io/openshift/lightspeed-console-plugin:latest"
	// ConsoleUIHTTPSPort is the port number of the console UI service
	ConsoleUIHTTPSPort = 9443
	// ConsoleUIPluginName is the name of the console UI plugin
	ConsoleUIPluginName = "lightspeed-console-plugin"
	// ConsoleUIPluginDisplayName is the display name of the console UI plugin
	ConsoleUIPluginDisplayName = "Lightspeed Console"
	// ConsoleCRName is the name of the console custom resource
	ConsoleCRName = "cluster"
	// ConsoleProxyAlias is the alias of the console proxy
	// The console backend exposes following proxy endpoint: /api/proxy/plugin/<plugin-name>/<proxy-alias>/<request-path>?<optional-query-parameters>
	ConsoleProxyAlias = "ols"

	/*** watchers ***/
	WatcherAnnotationKey = "ols.openshift.io/watcher"
)
View Source
const (
	ErrCreateAPIConfigmap              = "failed to create OLS configmap"
	ErrCreateAPIDeployment             = "failed to create OLS deployment"
	ErrCreateAPIService                = "failed to create OLS service"
	ErrCreateAPIServiceAccount         = "failed to create OLS service account"
	ErrCreateConsolePlugin             = "failed to create Console Plugin"
	ErrCreateConsolePluginConfigMap    = "failed to create Console Plugin configmap"
	ErrCreateConsolePluginDeployment   = "failed to create Console Plugin deployment"
	ErrCreateConsolePluginService      = "failed to create Console Plugin service"
	ErrCreateSARClusterRole            = "failed to create SAR cluster role"
	ErrCreateSARClusterRoleBinding     = "failed to create SAR cluster role binding"
	ErrCreateServiceMonitor            = "failed to create ServiceMonitor"
	ErrCreatePrometheusRule            = "failed to create PrometheusRule"
	ErrDeleteConsolePlugin             = "failed to delete Console Plugin"
	ErrGenerateAPIConfigmap            = "failed to generate OLS configmap"
	ErrGenerateAPIDeployment           = "failed to generate OLS deployment"
	ErrGenerateAPIService              = "failed to generate OLS service"
	ErrGenerateAPIServiceAccount       = "failed to generate OLS service account"
	ErrGenerateConsolePlugin           = "failed to generate Console Plugin"
	ErrGenerateConsolePluginConfigMap  = "failed to generate Console Plugin configmap"
	ErrGenerateConsolePluginDeployment = "failed to generate Console Plugin deployment"
	ErrGenerateConsolePluginService    = "failed to generate Console Plugin service"
	ErrGenerateHash                    = "failed to generate hash for the existing OLS configmap"
	ErrGenerateSARClusterRole          = "failed to generate SAR cluster role"
	ErrGenerateSARClusterRoleBinding   = "failed to generate SAR cluster role binding"
	ErrGenerateServiceMonitor          = "failed to generate ServiceMonitor"
	ErrGeneratePrometheusRule          = "failed to generate PrometheusRule"
	ErrGetAPIConfigmap                 = "failed to get OLS configmap"
	ErrGetAPIDeployment                = "failed to get OLS deployment"
	ErrGetAPIService                   = "failed to get OLS service"
	ErrGetAPIServiceAccount            = "failed to get OLS service account"
	ErrGetConsole                      = "failed to get Console"
	ErrGetConsolePlugin                = "failed to get Console Plugin"
	ErrGetConsolePluginConfigMap       = "failed to get Console Plugin configmap"
	ErrGetConsolePluginDeployment      = "failed to get Console Plugin deployment"
	ErrGetConsolePluginService         = "failed to get Console Plugin service"
	ErrGetSARClusterRole               = "failed to get SAR cluster role"
	ErrGetSARClusterRoleBinding        = "failed to get SAR cluster role binding"
	ErrGetServiceMonitor               = "failed to get ServiceMonitor"
	ErrGetPrometheusRule               = "failed to get PrometheusRule"
	ErrUpdateAPIConfigmap              = "failed to update OLS configmap"
	ErrUpdateAPIDeployment             = "failed to update OLS deployment"
	ErrUpdateAPIService                = "failed to update OLS service"
	ErrUpdateConsole                   = "failed to update Console"
	ErrUpdateConsolePlugin             = "failed to update Console Plugin"
	ErrUpdateConsolePluginConfigMap    = "failed to update Console Plugin configmap"
	ErrUpdateConsolePluginDeployment   = "failed to update Console Plugin deployment"
	ErrUpdateConsolePluginService      = "failed to update Console Plugin service"
	ErrUpdateCRStatusCondition         = "failed to update OLSConfig CR status condition"
	ErrUpdateServiceMonitor            = "failed to update ServiceMonitor"
	ErrUpdatePrometheusRule            = "failed to update PrometheusRule"
)

Variables

This section is empty.

Functions

func SetDefaults_Deployment

func SetDefaults_Deployment(obj *appsv1.Deployment)

This is copied from https://github.com/kubernetes/kubernetes/blob/v1.29.2/pkg/apis/apps/v1/defaults.go#L38 to avoid importing the whole k8s.io/kubernetes package. SetDefaults_Deployment sets additional defaults compared to its counterpart in extensions. These addons are: - MaxUnavailable during rolling update set to 25% (1 in extensions) - MaxSurge value during rolling update set to 25% (1 in extensions) - RevisionHistoryLimit set to 10 (not set in extensions) - ProgressDeadlineSeconds set to 600s (not set in extensions)

Types

type AppSrvConfigFile

type AppSrvConfigFile struct {
	LLMProviders []ProviderConfig `json:"llm_providers"`
	OLSConfig    OLSConfig        `json:"ols_config,omitempty"`
	DevConfig    DevConfig        `json:"dev_config,omitempty"`
}

** application server configuration file ** root of the app server configuration file

type ConversationCacheConfig

type ConversationCacheConfig struct {
	// Type of cache to use. Default: "redis"
	Type string `json:"type" default:"redis"`
	// TODO: Update DB
	// Redis cache configuration
	//Redis RedisCacheConfig `json:"redis,omitempty"`
	// Memory cache configuration
	Memory MemoryCacheConfig `json:"memory,omitempty"`
}

type DeleteFunc

type DeleteFunc func(context.Context) error

type DeleteTask

type DeleteTask struct {
	Name string
	Task DeleteFunc
}

type DevConfig

type DevConfig struct {
	// User Authorization enable/disable
	DisableAuth bool `json:"disable_auth" default:"false"`
}

type LoggingConfig

type LoggingConfig struct {
	// Application log level
	AppLogLevel string `json:"app_log_level" default:"info"`
	// Library log level
	LibLogLevel string `json:"lib_log_level" default:"warning"`
	// Uvicorn log level
	UvicornLogLevel string `json:"uvicorn_log_level" default:"info"`
}

type MemoryCacheConfig

type MemoryCacheConfig struct {
	// Maximum number of cache entries. Default: "1000"
	MaxEntries int `json:"max_entries,omitempty" default:"1000"`
}

type ModelConfig

type ModelConfig struct {
	// Model name
	Name string `json:"name"`
	// Model API URL
	URL string `json:"url,omitempty"`
}

ModelSpec defines the desired state of in-memory cache.

type OLSConfig

type OLSConfig struct {
	// Default model for usage
	DefaultModel string `json:"default_model,omitempty"`
	// Default provider for usage
	DefaultProvider string `json:"default_provider,omitempty"`
	// Logging config
	Logging LoggingConfig `json:"logging_config,omitempty"`
	// Conversation cache
	ConversationCache ConversationCacheConfig `json:"conversation_cache,omitempty"`
	// TLS configuration
	TLSConfig TLSConfig `json:"tls_config,omitempty"`
	// Query filters
	QueryFilters []QueryFilters `json:"query_filters,omitempty"`
	// Reference content for RAG
	ReferenceContent ReferenceContent `json:"reference_content,omitempty"`
	// User data collection configuration
	UserDataCollection UserDataCollectionConfig `json:"user_data_collection,omitempty"`
}

type OLSConfigReconciler

type OLSConfigReconciler struct {
	client.Client
	Scheme *runtime.Scheme

	Options OLSConfigReconcilerOptions
	// contains filtered or unexported fields
}

OLSConfigReconciler reconciles a OLSConfig object

func (*OLSConfigReconciler) Reconcile

func (r *OLSConfigReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error)

For more details, check Reconcile and its Result here: - https://pkg.go.dev/sigs.k8s.io/controller-runtime@v0.15.0/pkg/reconcile

func (*OLSConfigReconciler) SetupWithManager

func (r *OLSConfigReconciler) SetupWithManager(mgr ctrl.Manager) error

SetupWithManager sets up the controller with the Manager.

type OLSConfigReconcilerOptions

type OLSConfigReconcilerOptions struct {
	LightspeedServiceImage      string
	LightspeedServiceRedisImage string
	ConsoleUIImage              string
	Namespace                   string
}

type ProviderConfig

type ProviderConfig struct {
	// Provider name
	Name string `json:"name"`
	// Provider API URL
	URL string `json:"url,omitempty"`
	// Path to the file containing API provider credentials in the app server container.
	// default to "bam_api_key.txt"
	CredentialsPath string `json:"credentials_path" default:"bam_api_key.txt"`
	// List of models from the provider
	Models []ModelConfig `json:"models,omitempty"`
	// Provider type
	Type string `json:"type,omitempty"`
	// Azure deployment name
	AzureDeploymentName string `json:"deployment_name,omitempty"`
	// Watsonx Project ID
	WatsonProjectID string `json:"project_id,omitempty"`
}

type QueryFilters

type QueryFilters struct {
	// Filter name.
	Name string `json:"name,omitempty"`
	// Filter pattern.
	Pattern string `json:"pattern,omitempty"`
	// Replacement for the matched pattern.
	ReplaceWith string `json:"replace_with,omitempty"`
}

type ReconcileFunc

type ReconcileFunc func(context.Context, *olsv1alpha1.OLSConfig) error

** controller inernal **

type ReconcileTask

type ReconcileTask struct {
	Name string
	Task ReconcileFunc
}

type RedisCacheConfig

type RedisCacheConfig struct {
	// Redis host
	Host string `json:"host,omitempty" default:"lightspeed-redis-server.openshift-lightspeed.svc"`
	// Redis port
	Port int `json:"port,omitempty" default:"6379"`
	// Redis maxmemory
	MaxMemory *intstr.IntOrString `json:"max_memory,omitempty" default:"1024mb"`
	// Redis maxmemory policy
	MaxMemoryPolicy string `json:"max_memory_policy,omitempty" default:"allkeys-lru"`
	// Path to the file containing redis credentials in the app server container.
	PasswordPath string `json:"password_path,omitempty"`
	// Redis CA certificate path
	CACertPath string `json:"ca_cert_path,omitempty"`
}

type ReferenceContent

type ReferenceContent struct {
	// Path to the file containing the product docs index in the app server container.
	ProductDocsIndexPath string `json:"product_docs_index_path,omitempty"`
	// Name of the index to load.
	ProductDocsIndexId string `json:"product_docs_index_id,omitempty"`
	// Path to the file containing the product docs embeddings model in the app server container.
	EmbeddingsModelPath string `json:"embeddings_model_path,omitempty"`
}

type TLSConfig

type TLSConfig struct {
	TLSCertificatePath string `json:"tls_certificate_path,omitempty"`
	TLSKeyPath         string `json:"tls_key_path,omitempty"`
}

type UserDataCollectionConfig

type UserDataCollectionConfig struct {
	FeedbackDisabled    bool   `json:"feedback_disabled" default:"false"`
	FeedbackStorage     string `json:"feedback_storage,omitempty"`
	TranscriptsDisabled bool   `json:"transcripts_disabled" default:"false"`
	TranscriptsStorage  string `json:"transcripts_storage,omitempty"`
}

Jump to

Keyboard shortcuts

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