runtime

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Aug 15, 2022 License: Apache-2.0 Imports: 27 Imported by: 0

Documentation

Index

Constants

View Source
const (
	S3EndpointKey = "s3-endpoint"
	S3UseHTTPSKey = "s3-usehttps"
	// env name
	S3EndpointURLEnv = "S3_ENDPOINT_URL"

	AccessKeyID = "ACCESS_KEY_ID"
	// env name
	AccessKeyIDEnv = "ACCESS_KEY_ID"

	SecretAccessKey = "SECRET_ACCESS_KEY"
	// env name
	SecretAccessKeyEnv = "SECRET_ACCESS_KEY"

	SecretAnnotationKey = "sedna.io/credential"
)
View Source
const (
	// DefaultBackOff is the default backoff period
	DefaultBackOff = 10 * time.Second
	// MaxBackOff is the max backoff period
	MaxBackOff = 360 * time.Second

	// TrainPodType is type of train pod
	TrainPodType = "train"
	// EvalPodType is type of eval pod
	EvalPodType = "eval"
	// InferencePodType is type of inference pod
	InferencePodType = "inference"

	// AnnotationsKeyPrefix defines prefix of key in annotations
	AnnotationsKeyPrefix = "sedna.io/"

	ModelHotUpdateHostPrefix      = "/var/lib/sedna/model-hot-update"
	ModelHotUpdateContainerPrefix = "/model-hot-update"
	ModelHotUpdateVolumeName      = "sedna-model-hot-update-volume"
	ModelHotUpdateConfigFile      = "model_config.json"
	ModelHotUpdateAnnotationsKey  = "sedna.io/model-hot-update-config"
)

Variables

This section is empty.

Functions

func CalcActiveDeploymentCount added in v0.4.2

func CalcActiveDeploymentCount(deployments []*appsv1.Deployment) int32

func CalcActivePodCount

func CalcActivePodCount(pods []*v1.Pod) int32

func ConvertK8SValidName

func ConvertK8SValidName(name string) string

ConvertK8SValidName converts to the k8s valid name

func ConvertMapToMetrics

func ConvertMapToMetrics(metric map[string]interface{}) []sednav1.Metric

ConvertMapToMetrics converts the metric map to list of resource Metric

func CreateDeploymentWithTemplate added in v0.4.2

func CreateDeploymentWithTemplate(client kubernetes.Interface, object CommonInterface, spec *appsv1.DeploymentSpec, workerParam *WorkerParam, port int32) (*appsv1.Deployment, error)

CreateDeploymentWithTemplate creates and returns a deployment object given a crd object, deployment template

func CreateEdgeMeshService added in v0.4.2

func CreateEdgeMeshService(kubeClient kubernetes.Interface, object CommonInterface, workerType string, servicePort int32) (string, error)

CreateEdgeMeshService creates a kubeedge edgemesh service for an object, and returns an edgemesh service URL. Since edgemesh can realize Cross-Edge-Cloud communication, the service can be created both on the cloud or edge side.

func CreateKubernetesService

func CreateKubernetesService(kubeClient kubernetes.Interface, object CommonInterface, workerType string, inputPort int32, inputIP string) (int32, error)

CreateKubernetesService creates a k8s service for an object given ip and port

func CreatePodWithTemplate

func CreatePodWithTemplate(client kubernetes.Interface, object CommonInterface, spec *v1.PodTemplateSpec, workerParam *WorkerParam) (*v1.Pod, error)

CreatePodWithTemplate creates and returns a pod object given a crd object, pod template, and workerParam

func GenerateSelector

func GenerateSelector(object CommonInterface) (labels.Selector, error)

GenerateSelector generates the selector of an object for worker

func GenerateWorkerSelector added in v0.4.2

func GenerateWorkerSelector(object CommonInterface, workerType string) (labels.Selector, error)

GenerateWorkerSelector generates the selector of an object for specific worker type

func GetBackoff

func GetBackoff(queue workqueue.RateLimitingInterface, key interface{}) time.Duration

GetBackoff calc the next wait time for the key

func GetModelHotUpdateConfigFile added in v0.4.0

func GetModelHotUpdateConfigFile(object CommonInterface, prefix string) string

func GetNodeIPByName

func GetNodeIPByName(kubeClient kubernetes.Interface, name string) (string, error)

GetNodeIPByName get node ip by node name

func InjectSecretAnnotations

func InjectSecretAnnotations(client kubernetes.Interface, obj CommonInterface, secretName string) (err error)

func InjectStorageInitializer

func InjectStorageInitializer(pod *v1.Pod, workerParam *WorkerParam)

InjectStorageInitializer injects these storage related volumes and envs into pod in-place

func InjectStorageInitializerDeployment added in v0.5.1

func InjectStorageInitializerDeployment(deployment *appsv1.Deployment, workerParam *WorkerParam)

InjectStorageInitializer injects these storage related volumes and envs into deployment in-place

func MergeSecretEnvs

func MergeSecretEnvs(nowE, newE []v1.EnvVar, overwrite bool) []v1.EnvVar

MergeSecretEnvs merges two EnvVar list

func PrepareHostPath added in v0.5.1

func PrepareHostPath(workerParam *WorkerParam) ([]v1.Volume, []v1.VolumeMount, []v1.VolumeMount)

func PrepareInitContainer added in v0.5.1

func PrepareInitContainer(workerParam *WorkerParam) ([]v1.Volume, []v1.VolumeMount, *v1.Container)

func PrepareSecret added in v0.5.1

func PrepareSecret(workerParam *WorkerParam) []v1.EnvVar

func PrepareStorage added in v0.5.1

func PrepareStorage(workerParam *WorkerParam)

func RetryUpdateStatus

func RetryUpdateStatus(name, namespace string, updateStatusFunc func() error) error

RetryUpdateStatus simply retries to call the status update func

Types

type BaseControllerI

type BaseControllerI interface {
	Run(stopCh <-chan struct{})
}

BaseControllerI defines the interface of an controller

type CommonInterface

type CommonInterface interface {
	metav1.Object
	schema.ObjectKind
	k8sruntime.Object
}

CommonInterface describes the commom interface of CRs

type ControllerContext

type ControllerContext struct {
	Config *config.ControllerConfig

	KubeClient          kubernetes.Interface
	KubeInformerFactory kubeinformers.SharedInformerFactory

	SednaClient          sednaclientset.Interface
	SednaInformerFactory sednainformers.SharedInformerFactory
}

ControllerContext defines the context that all feature controller share and belong to

type DownstreamSendFunc

type DownstreamSendFunc = func(nodeName string, eventType watch.EventType, obj interface{}) error

DownstreamSendFunc is the send function for feature controllers to sync the resource updates(spec and status) to LC

type FeatureControllerI

type FeatureControllerI interface {
	BaseControllerI

	// SetDownstreamSendFunc sets up the downstream send function in the feature controller
	SetDownstreamSendFunc(f DownstreamSendFunc) error

	// SetUpstreamHandler sets up the upstream handler function for the feature controller
	SetUpstreamHandler(add UpstreamHandlerAddFunc) error
}

FeatureControllerI defines the interface of an AI Feature controller

type Model

type Model struct {
	Format  string                 `json:"format"`
	URL     string                 `json:"url"`
	Devices []string               `json:"device_soc_versions,omitempty"`
	Metrics map[string]interface{} `json:"metrics,omitempty"`
}

func (*Model) GetURL

func (m *Model) GetURL() string

type ModelHotUpdate added in v0.4.0

type ModelHotUpdate struct {
	Enable            bool
	PollPeriodSeconds int64
}

type MountURL

type MountURL struct {
	// URL is the url of dataset/model
	URL string

	// Indirect indicates the url is indirect, need to parse its content and download all,
	// and is used in dataset which has index url.
	//
	// when Indirect = true, URL could be in host path filesystem.
	// default: false
	Indirect bool

	// DownloadByInitializer indicates whether the url need to be download by initializer.
	DownloadByInitializer bool

	// IsDir indicates that url is directory
	IsDir bool

	// if true, only mounts when url is hostpath
	EnableIfHostPath bool

	// the container path
	ContainerPath string

	// indicates the path this url will be mounted into container.
	// can be ContainerPath or its parent dir
	MountPath string

	// for host path, we just need to mount without downloading
	HostPath string

	// for download
	DownloadSrcURL string
	DownloadDstDir string

	// if true, then no mount
	Disable bool

	// the relevant secret
	Secret     *v1.Secret
	SecretEnvs []v1.EnvVar
	// contains filtered or unexported fields
}

func (*MountURL) Parse

func (m *MountURL) Parse()

type UpstreamHandler

type UpstreamHandler = func(namespace, name, operation string, content []byte) error

UpstreamHandler is the function definition for handling the upstream updates, i.e. resource updates(mainly status) from LC(running at edge)

type UpstreamHandlerAddFunc

type UpstreamHandlerAddFunc = func(kind string, updateHandler UpstreamHandler) error

UpstreamHandlerAddFunc defines the upstream controller register function for adding handler

type WorkerMount

type WorkerMount struct {
	Name string
	// the url to be mounted
	URL *MountURL

	// for some cases, there are more than one url to be mounted
	URLs []MountURL

	// envName indicates the environment key of the mounts injected to the worker
	EnvName string
}

type WorkerParam

type WorkerParam struct {
	Mounts []WorkerMount

	Env        map[string]string
	WorkerType string

	// if true, force to use hostNetwork
	HostNetwork bool

	ModelHotUpdate ModelHotUpdate

	RestartPolicy v1.RestartPolicy

	DNSPolicy v1.DNSPolicy
}

WorkerParam describes the system-defined parameters of worker

Jump to

Keyboard shortcuts

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