Documentation ¶
Index ¶
- Constants
- Variables
- func ComputeResource(resourceQuantity resource.Quantity, fraction float64) resource.Quantity
- func InitClusterControllers(cfg *config.Config, environmentClusterMap map[string]*mlpcluster.K8sConfig) (map[string]Controller, error)
- type BaseService
- type ConfigMap
- type Container
- type Controller
- type CreateSparkRequest
- type Env
- type Job
- type KnativeService
- type KubernetesService
- type PersistentVolumeClaim
- type PodDisruptionBudget
- type Port
- type RequestLimitResources
- type Resource
- type Role
- type RoleBinding
- type Secret
- type SecretVolume
- type ServiceAccount
- type VirtualService
- type VolumeMount
Constants ¶
const ( AutoscalingClassHPA string = "hpa.autoscaling.knative.dev" AutoscalingClassKPA string = "kpa.autoscaling.knative.dev" KnativeServiceLabelKey string = "serving.knative.dev/service" KnativeUserContainerName string = "user-container" DefaultRequestTimeoutSeconds int64 = 30 )
const (
// ServiceAccountFileName is the name of the service account
ServiceAccountFileName = "service-account.json"
)
Variables ¶
var DefaultSparkDriverRoleRules = []apirbacv1.PolicyRule{ { APIGroups: []string{ "", }, Resources: []string{ "pods", }, Verbs: []string{ "*", }, }, { APIGroups: []string{ "", }, Resources: []string{ "services", }, Verbs: []string{ "*", }, }, { APIGroups: []string{ "", }, Resources: []string{ "configmaps", }, Verbs: []string{ "*", }, }, }
DefaultSparkDriverRoleRules is the default spark required policies
var ErrNamespaceAlreadyExists = errors.New("namespace already exists")
Functions ¶
func ComputeResource ¶
Ref: https://github.com/knative/serving/blob/release-0.14/pkg/reconciler/revision/resources/queue.go#L115
func InitClusterControllers ¶
func InitClusterControllers( cfg *config.Config, environmentClusterMap map[string]*mlpcluster.K8sConfig, ) (map[string]Controller, error)
InitClusterControllers takes in the app config and initializes one cluster controller per environment and returns a map where the key is the env name and the value is the corresponding controller.
Types ¶
type BaseService ¶
type BaseService struct { Name string `json:"name"` Namespace string `json:"namespace"` Image string `json:"image"` // Resources CPURequests resource.Quantity `json:"cpu_requests"` CPULimit *resource.Quantity `json:"cpu_limit"` MemoryRequests resource.Quantity `json:"memory_requests"` MemoryLimit *resource.Quantity `json:"memory_limit"` // Health Checks ProbePort int32 `json:"probe_port"` LivenessHTTPGetPath string `json:"liveness_path"` ReadinessHTTPGetPath string `json:"readiness_path"` ProbeInitDelaySeconds int32 `json:"probe_delay_seconds"` // Env vars Envs []corev1.EnvVar `json:"envs"` // Labels Labels map[string]string `json:"labels"` ConfigMap *ConfigMap PersistentVolumeClaim *PersistentVolumeClaim `json:"persistent_volume_claim"` // Volumes Volumes []corev1.Volume `json:"volumes"` VolumeMounts []corev1.VolumeMount `json:"volume_mounts"` // InitContainers InitContainers []Container `json:"init_containers"` }
BaseService defines the common properties of services that can be specified for its deployment by the cluster controller
type ConfigMap ¶
type ConfigMap struct { Name string `json:"name"` FileName string `json:"file_name"` Data string `json:"data"` Labels map[string]string `json:"labels"` }
ConfigMap contains information to create a config map
type Container ¶
type Container struct { Name string Image string Args []string VolumeMounts []VolumeMount Envs []Env Resources RequestLimitResources }
Container contains the Kubernetes Container to be deployed
type Controller ¶
type Controller interface { // Namespace CreateNamespace(ctx context.Context, name string) error // Knative Service GetKnativeServiceURL(ctx context.Context, svcName string, namespace string) string DeployKnativeService(ctx context.Context, svc *KnativeService) error DeleteKnativeService(ctx context.Context, svcName string, namespace string, ignoreNotFound bool) error GetKnativeServiceDesiredReplicas(ctx context.Context, svcName string, namespace string) (int, error) // Istio VirtualService ApplyIstioVirtualService(ctx context.Context, routerEndpoint *VirtualService) error DeleteIstioVirtualService(ctx context.Context, svcName string, namespace string) error // StatefulSet DeleteKubernetesStatefulSet(ctx context.Context, name string, namespace string, ignoreNotFound bool) error // Service DeployKubernetesService(ctx context.Context, svc *KubernetesService) error DeleteKubernetesService(ctx context.Context, svcName string, namespace string, ignoreNotFound bool) error // ConfigMap ApplyConfigMap(ctx context.Context, namespace string, configMap *ConfigMap) error DeleteConfigMap(ctx context.Context, name string, namespace string, ignoreNotFound bool) error // Secret CreateSecret(ctx context.Context, secret *Secret) error DeleteSecret(ctx context.Context, secretName string, namespace string, ignoreNotFound bool) error // PVC DeletePVCs(ctx context.Context, listOptions metav1.ListOptions, namespace string, ignoreNotFound bool) error // Pod ListPods(ctx context.Context, namespace string, labelSelector string) (*apicorev1.PodList, error) ListPodLogs(ctx context.Context, namespace string, podName string, opts *apicorev1.PodLogOptions) (io.ReadCloser, error) // Job CreateJob(ctx context.Context, namespace string, job Job) (*apibatchv1.Job, error) GetJob(ctx context.Context, namespace string, jobName string) (*apibatchv1.Job, error) DeleteJob(ctx context.Context, namespace string, jobName string) error // Service Account CreateServiceAccount(ctx context.Context, namespace string, serviceAccount *ServiceAccount) (*apicorev1.ServiceAccount, error) CreateRole(ctx context.Context, namespace string, role *Role) (*apirbacv1.Role, error) CreateRoleBinding(ctx context.Context, namespace string, roleBinding *RoleBinding) (*apirbacv1.RoleBinding, error) // Spark Application CreateSparkApplication(ctx context.Context, namespace string, request *CreateSparkRequest) (*apisparkv1beta2.SparkApplication, error) GetSparkApplication(ctx context.Context, namespace, appName string) (*apisparkv1beta2.SparkApplication, error) DeleteSparkApplication(ctx context.Context, namespace, appName string) error // PodDisruptionBudget ApplyPodDisruptionBudget(ctx context.Context, pdb PodDisruptionBudget) (*apipolicyv1.PodDisruptionBudget, error) DeletePodDisruptionBudget(ctx context.Context, namespace, pdbName string) error }
Controller defines the operations supported by the cluster controller
type CreateSparkRequest ¶
type CreateSparkRequest struct { JobName string JobLabels map[string]string JobImageRef string JobApplicationPath string JobArguments []string JobConfigMount string DriverCPURequest string DriverMemoryRequest string ExecutorCPURequest string ExecutorMemoryRequest string ExecutorReplica int32 ServiceAccountName string SparkInfraConfig *config.SparkAppConfig EnvVars *[]openapi.EnvVar }
CreateSparkRequest is the request for creating a spark driver
type Job ¶
type Job struct { Name string Namespace string Labels map[string]string Annotations map[string]string Completions *int32 BackOffLimit *int32 TTLSecondsAfterFinished *int32 RestartPolicy corev1.RestartPolicy Containers []Container SecretVolumes []SecretVolume TolerationName *string NodeSelector map[string]string ServiceAccount string }
Job contains the information to build a Kubernetes Job object
type KnativeService ¶
type KnativeService struct { *BaseService IsClusterLocal bool `json:"is_cluster_local"` ContainerPort int32 `json:"containerPort"` Protocol routerConfig.Protocol `json:"protocol"` // Autoscaling properties MinReplicas int `json:"minReplicas"` MaxReplicas int `json:"maxReplicas"` InitialScale *int `json:"initialScale"` AutoscalingMetric string `json:"autoscalingMetric"` // AutoscalingTarget is expected to be an absolute value for concurrency / rps // and a % value (of the requested value) for cpu / memory based autoscaling. AutoscalingTarget string `json:"autoscalingTarget"` // TopologySpreadConstraints contains a list of topology spread constraint to be applied on the pods of this service TopologySpreadConstraints []corev1.TopologySpreadConstraint `json:"topologySpreadConstraints"` // Resource properties QueueProxyResourcePercentage int `json:"queueProxyResourcePercentage"` }
KnativeService defines the properties for Knative services
func (*KnativeService) BuildKnativeServiceConfig ¶
func (cfg *KnativeService) BuildKnativeServiceConfig() (*knservingv1.Service, error)
Creates a new config object compatible with the knative serving API, from the given config
type KubernetesService ¶
type KubernetesService struct { *BaseService InitContainers []Container `json:"init_containers"` Command []string `json:"command"` Args []string `json:"args"` Replicas int `json:"replicas"` Ports []Port `json:"ports"` SecurityContext *corev1.PodSecurityContext `json:"security_context"` }
KubernetesService defines the properties for Kubernetes services
func (*KubernetesService) BuildKubernetesServiceConfig ¶
func (cfg *KubernetesService) BuildKubernetesServiceConfig() (*appsv1.StatefulSet, *corev1.Service)
type PersistentVolumeClaim ¶
type PersistentVolumeClaim struct { Name string `json:"name"` Namespace string `json:"namespace"` AccessModes []string `json:"access_modes"` Size resource.Quantity `json:"size"` Labels map[string]string `json:"labels"` }
PersistentVolumeClaim contains the information to build a persistent volume claim
func (*PersistentVolumeClaim) BuildPersistentVolumeClaim ¶
func (pvc *PersistentVolumeClaim) BuildPersistentVolumeClaim() *corev1.PersistentVolumeClaim
type PodDisruptionBudget ¶
type PodDisruptionBudget struct { Name string `json:"name"` Namespace string `json:"namespace"` Labels map[string]string `json:"labels"` MinAvailablePercentage *int `json:"min_available_percentage"` Selector *apimetav1.LabelSelector `json:"selector"` }
func (PodDisruptionBudget) BuildPDBSpec ¶
func (cfg PodDisruptionBudget) BuildPDBSpec() (*policyv1cfg.PodDisruptionBudgetSpecApplyConfiguration, error)
type RequestLimitResources ¶
RequestLimitResources is a Kubernetes resource request and limits
func (*RequestLimitResources) Build ¶
func (r *RequestLimitResources) Build() corev1.ResourceRequirements
Build converts the spec into a Kubernetes spec
type Resource ¶
Resource is a Kubernetes resource
func (*Resource) Build ¶
func (r *Resource) Build() corev1.ResourceList
Build converts the spec into a Kubernetes spec
type Role ¶
type Role struct { Name string `json:"name"` Namespace string `json:"namespace"` Labels map[string]string `json:"labels"` PolicyRules []apirbacv1.PolicyRule `json:"rules"` }
Role contains the information to build a role
type RoleBinding ¶
type RoleBinding struct { Name string `json:"name"` Namespace string `json:"namespace"` Labels map[string]string `json:"labels"` RoleName string `json:"role_name"` ServiceAccountName string `json:"service_account_name"` }
RoleBinding contains the information to build a role binding
func (*RoleBinding) BuildRoleBinding ¶
func (r *RoleBinding) BuildRoleBinding() *apirbacv1.RoleBinding
type Secret ¶
Secret defines a kubernetes secret.
func (*Secret) BuildSecret ¶
BuildSecret builds a kubernetes secret from the given config.
type SecretVolume ¶
SecretVolume is a Kubernetes volume that mounted by a secret
func (*SecretVolume) Build ¶
func (v *SecretVolume) Build() corev1.Volume
Build converts the spec into a Kubernetes spec
type ServiceAccount ¶
type ServiceAccount struct { Name string `json:"name"` Namespace string `json:"namespace"` Labels map[string]string `json:"labels"` }
ServiceAccount contains the information to build a service account
func (*ServiceAccount) BuildServiceAccount ¶
func (sa *ServiceAccount) BuildServiceAccount() *corev1.ServiceAccount
type VirtualService ¶
type VirtualService struct { Name string `json:"name"` Namespace string `json:"namespace"` Labels map[string]string `json:"labels"` Gateway string `json:"gateway"` Endpoint string `json:"endpoint"` DestinationHost string `json:"destination_host"` HostRewrite string `json:"host_rewrite"` MatchURIPrefixes []string `json:"match_uri_prefix"` }
func (VirtualService) BuildVirtualService ¶
func (cfg VirtualService) BuildVirtualService() *v1beta1.VirtualService
type VolumeMount ¶
VolumeMount is a Kubernetes VolumeMount
func (*VolumeMount) Build ¶
func (vm *VolumeMount) Build() corev1.VolumeMount
Build converts the spec into a Kubernetes spec