runtime

package
v0.0.0-...-005948e Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	CloudAppKind        = "CloudApp"
	CloudAppReleaseKind = "CloudAppRelease"

	AppRepoObjName = "app_repo"
	AppObjName     = "app"
)
View Source
const (
	CloudGroup       = "cloud-copilot.operator.io"
	CloudVersion     = "v1alpha1"
	DefaultNamespace = "default"

	WaitTimeout = 10 * time.Minute
)
View Source
const (
	CloudClusterKind = "CloudCluster"
)
View Source
const (
	CloudProjectKind = "CloudProject"
)
View Source
const (
	CloudServiceKind = "CloudService"
)
View Source
const (
	CloudWorkflowKind = "CloudWorkflow"
)
View Source
const (
	CloudWorkspaceKind = "CloudWorkspace"
)

Variables

Functions

func CreateResource

func CreateResource(ctx context.Context, client dynamic.Interface, resource *unstructured.Unstructured) error

func CreateYAMLFile

func CreateYAMLFile(ctx context.Context, dynamicClient *dynamic.DynamicClient, namespace, resource, filePath string) error

func DeleteResource

func DeleteResource(ctx context.Context, client dynamic.Interface, resource *unstructured.Unstructured) error

func DescribeResource

func DescribeResource(ctx context.Context, client *kubernetes.Clientset, namespace, resourceName string) (string, error)

kubectl describe resource -n namespace

func EventsInfo

func EventsInfo(ctx context.Context, client *kubernetes.Clientset, namespace, kind, name string) (string, error)

func GetKubeClient

func GetKubeClient(KubeConfigPaths ...string) (clientset *kubernetes.Clientset, err error)

func GetKubeDynamicClient

func GetKubeDynamicClient(KubeConfigPaths ...string) (*dynamic.DynamicClient, error)

func GetObjResrouce

func GetObjResrouce(ctx context.Context, obj *unstructured.Unstructured, successStatus, failedStatus int32) (*unstructured.Unstructured, error)

func GetSpec

func GetSpec(obj *unstructured.Unstructured, out any) error

Convert the spec of an unstructured object to a specified struct

func GetStatus

func GetStatus(obj *unstructured.Unstructured) (status any, err error)

func Logs

func Logs(ctx context.Context, client *kubernetes.Clientset, namespace, podName string) (string, error)

kubectl logs -n namespace podName

func NewAppRuntime

func NewAppRuntime(logger log.Logger) biz.AppRuntime

func NewClusterRuntime

func NewClusterRuntime(logger log.Logger) biz.ClusterRuntime

func NewProjectRuntime

func NewProjectRuntime(logger log.Logger) biz.ProjectRuntime

func NewServiceRuntime

func NewServiceRuntime(logger log.Logger) biz.ServiceRuntime

func NewUnstructured

func NewUnstructured(kindName string) *unstructured.Unstructured

func NewUnstructuredWithGenerateName

func NewUnstructuredWithGenerateName(kindName, namePrefix string) *unstructured.Unstructured

func NewWorkflowRuntime

func NewWorkflowRuntime(logger log.Logger) biz.WorkflowRuntime

func NewWorkspaceRuntime

func NewWorkspaceRuntime(logger log.Logger) biz.WorkspaceRuntime

func ParseYAML

func ParseYAML(filename string) (*unstructured.UnstructuredList, error)

func PodInfo

func PodInfo(ctx context.Context, client *kubernetes.Clientset, namespace, podName string) (string, error)

kubectl describe resource -n namespace

func PodLogs

func PodLogs(ctx context.Context, client *kubernetes.Clientset, namespace, podName, containerName string) (string, error)

kubectl logs -n namespace podName

func ResourceInfo

func ResourceInfo(ctx context.Context, client dynamic.Interface, namespace, name string, gvr schema.GroupVersionResource) (string, error)

ResourceInfo

func SetSpec

func SetSpec(obj *unstructured.Unstructured, spec any)

func SetSpecField

func SetSpecField(obj *unstructured.Unstructured, fieldPath string, value any) error

SetSpecField(obj, "template.metadata.labels.app", "myapp")

func UpdateResource

func UpdateResource(ctx context.Context, client dynamic.Interface, resource *unstructured.Unstructured) error

func WaitForCRDStatus

func WaitForCRDStatus(ctx context.Context, dynamicClient *dynamic.DynamicClient, res *unstructured.Unstructured, timeout time.Duration, condition func(obj *unstructured.Unstructured) (bool, error)) error

func WaitForPodReady

func WaitForPodReady(ctx context.Context, client *kubernetes.Clientset, namespace, podName string, timeout time.Duration) error

Types

type AppRuntime

type AppRuntime struct {
	// contains filtered or unexported fields
}

func (*AppRuntime) AppRelease

func (a *AppRuntime) AppRelease(ctx context.Context, appRelease *biz.AppRelease) error

func (*AppRuntime) DeleteApp

func (a *AppRuntime) DeleteApp(ctx context.Context, app *biz.App) error

func (*AppRuntime) DeleteAppRelease

func (a *AppRuntime) DeleteAppRelease(ctx context.Context, appRelease *biz.AppRelease) error

func (*AppRuntime) DeleteAppVersion

func (a *AppRuntime) DeleteAppVersion(ctx context.Context, app *biz.App, appVersion *biz.AppVersion) error

func (*AppRuntime) GetAppAndVersionInfo

func (a *AppRuntime) GetAppAndVersionInfo(ctx context.Context, app *biz.App) error

func (*AppRuntime) GetAppReleaseResources

func (a *AppRuntime) GetAppReleaseResources(ctx context.Context, appRelease *biz.AppRelease) error

func (*AppRuntime) ReloadAppRepo

func (a *AppRuntime) ReloadAppRepo(ctx context.Context, appRepo *biz.AppRepo) error

type AppStatus

type AppStatus int32
const (
	AppStatus_PENDING   AppStatus = 0
	AppStatus_COMPLETED AppStatus = 1
	AppStatus_FAILED    AppStatus = 2
)

func (AppStatus) Int32

func (a AppStatus) Int32() int32

type CanaryDeployment

type CanaryDeployment struct {
	Image      string            `json:"image,omitempty"`
	Replicas   int32             `json:"replicas,omitempty"`
	Config     map[string]string `json:"config,omitempty"` // key: filename, value: content
	TrafficPct int32             `json:"traffic_pct,omitempty"`
}

type CloudServiceSpec

type CloudServiceSpec struct {
	CloudServiceType     CloudServiceType  `json:"cloud_service_type,omitempty"`
	Gateway              string            `json:"gateway,omitempty"`
	Image                string            `json:"image,omitempty"`
	Replicas             int32             `json:"replicas,omitempty"`
	RequestCPU           int32             `json:"request_cpu,omitempty"`
	LimitCPU             int32             `json:"limit_cpu,omitempty"`
	RequestGPU           int32             `json:"request_gpu,omitempty"`
	LimitGPU             int32             `json:"limit_gpu,omitempty"`
	RequestMemory        int32             `json:"request_memory,omitempty"`
	LimitMemory          int32             `json:"limit_memory,omitempty"`
	Volumes              []Volume          `json:"volumes,omitempty"`
	Ports                []Port            `json:"ports,omitempty"`
	ConfigPath           string            `json:"config_path,omitempty"` // dir
	Config               map[string]string `json:"config,omitempty"`      // key: filename, value: content
	IngressNetworkPolicy []NetworkPolicy   `json:"ingress_network_policy,omitempty"`
	EgressNetworkPolicy  []NetworkPolicy   `json:"egress_network_policy,omitempty"`
	CanaryDeployment     CanaryDeployment  `json:"canary_deployment,omitempty"`
}

CloudServiceSpec defines the desired state of CloudService.

type CloudServiceType

type CloudServiceType string
const (
	CloudServiceTypeHttpServer CloudServiceType = "HttpServer"
	CloudServiceTypeGrpcServer CloudServiceType = "GrpcServer"
)

type ClusterRuntime

type ClusterRuntime struct {
	// contains filtered or unexported fields
}

func (*ClusterRuntime) CurrentCluster

func (c *ClusterRuntime) CurrentCluster(ctx context.Context, cluster *biz.Cluster) error

func (*ClusterRuntime) ReloadCluster

func (c *ClusterRuntime) ReloadCluster(ctx context.Context, cluster *biz.Cluster) error

type NetworkPolicy

type NetworkPolicy struct {
	IpCIDR      string            `json:"ip_cidr,omitempty"`
	Namespace   string            `json:"namespace,omitempty"`
	MatchLabels map[string]string `json:"match_labels,omitempty"`
}

type Port

type Port struct {
	Name          string `json:"name,omitempty"`
	IngressPath   string `json:"ingress_path,omitempty"`
	Protocol      string `json:"protocol,omitempty"`
	ContainerPort int32  `json:"container_port,omitempty"`
}

type ProjectRuntime

type ProjectRuntime struct {
	// contains filtered or unexported fields
}

func (*ProjectRuntime) Delete

func (uc *ProjectRuntime) Delete(ctx context.Context, project *biz.Project) error

func (*ProjectRuntime) Reload

func (uc *ProjectRuntime) Reload(ctx context.Context, project *biz.Project) error

type ServiceRuntime

type ServiceRuntime struct {
	// contains filtered or unexported fields
}

func (*ServiceRuntime) ApplyService

func (s *ServiceRuntime) ApplyService(ctx context.Context, service *biz.Service, continuousDeployment *biz.ContinuousDeployment) error

func (*ServiceRuntime) GetServiceStatus

func (s *ServiceRuntime) GetServiceStatus(ctx context.Context, service *biz.Service) error

type Volume

type Volume struct {
	Name         string `json:"name,omitempty"`
	Path         string `json:"path,omitempty"`
	Storage      int32  `json:"storage,omitempty"`
	StorageClass string `json:"storage_class,omitempty"`
}

type WorkflowRuntime

type WorkflowRuntime struct {
	// contains filtered or unexported fields
}

func (*WorkflowRuntime) CleanWorkflow

func (w *WorkflowRuntime) CleanWorkflow(ctx context.Context, workflow *biz.Workflow) error

func (*WorkflowRuntime) CommitWorkflow

func (w *WorkflowRuntime) CommitWorkflow(ctx context.Context, workflow *biz.Workflow) error

func (*WorkflowRuntime) GetWorkflowStatus

func (w *WorkflowRuntime) GetWorkflowStatus(ctx context.Context, workflow *biz.Workflow) error

type WorkspaceRuntime

type WorkspaceRuntime struct {
	// contains filtered or unexported fields
}

func (*WorkspaceRuntime) Delete

func (uc *WorkspaceRuntime) Delete(ctx context.Context, wk *biz.Workspace) error

func (*WorkspaceRuntime) Reload

func (uc *WorkspaceRuntime) Reload(ctx context.Context, wk *biz.Workspace) error

Jump to

Keyboard shortcuts

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