containers as functions (#1681)
PR adds a new executortype which supports running containers as functions. New CLI under functions is added to create container as functions. Co-authored-by: Harsh Thakur <harshthakur9030@gmail.com> Co-authored-by: Sanket Sudake <sanketsudake@gmail.com>
This commit is contained in:
co-authored by
Harsh Thakur
Sanket Sudake
parent
f3e1f9df90
commit
a82281ad1c
@@ -55,6 +55,7 @@ const (
|
||||
const (
|
||||
ExecutorTypePoolmgr ExecutorType = "poolmgr"
|
||||
ExecutorTypeNewdeploy ExecutorType = "newdeploy"
|
||||
ExecutorTypeContainer ExecutorType = "container"
|
||||
)
|
||||
|
||||
const (
|
||||
|
||||
@@ -409,6 +409,11 @@ type (
|
||||
// This is optional. If not specified default value will be taken as false
|
||||
// +optional
|
||||
OnceOnly bool `json:"onceOnly,omitempty"`
|
||||
|
||||
// Podspec specifies podspec to use for executor type container based functions
|
||||
// Different arguments mentioned for container based function are populated inside a pod.
|
||||
// +optional
|
||||
PodSpec *apiv1.PodSpec `json:"podspec,omitempty"`
|
||||
}
|
||||
|
||||
// InvokeStrategy is a set of controls over how the function executes.
|
||||
@@ -450,6 +455,7 @@ type (
|
||||
// Available value:
|
||||
// - poolmgr
|
||||
// - newdeploy
|
||||
// - container
|
||||
// +optional
|
||||
ExecutorType ExecutorType `json:"ExecutorType"`
|
||||
|
||||
|
||||
@@ -149,7 +149,7 @@ func (EnvironmentSpec) SwaggerDoc() map[string]string {
|
||||
|
||||
var map_ExecutionStrategy = map[string]string{
|
||||
"": "ExecutionStrategy specifies low-level parameters for function execution, such as the number of instances.\n\nMinScale affects the cold start behavior for a function. If MinScale is 0 then the deployment is created on first invocation of function and is good for requests of asynchronous nature. If MinScale is greater than 0 then MinScale number of pods are created at the time of creation of function. This ensures faster response during first invocation at the cost of consuming resources.\n\nMaxScale is the maximum number of pods that function will scale to based on TargetCPUPercent and resources allocated to the function pod.",
|
||||
"ExecutorType": "ExecutorType is the executor type of a function used. Defaults to \"poolmgr\".\n\nAvailable value:\n - poolmgr\n - newdeploy",
|
||||
"ExecutorType": "ExecutorType is the executor type of a function used. Defaults to \"poolmgr\".\n\nAvailable value:\n - poolmgr\n - newdeploy\n - container",
|
||||
"MinScale": "This is only for newdeploy to set up minimum replicas of deployment.",
|
||||
"MaxScale": "This is only for newdeploy to set up maximum replicas of deployment.",
|
||||
"TargetCPUPercent": "This is only for newdeploy to set up target CPU utilization of HPA.",
|
||||
@@ -210,6 +210,7 @@ var map_FunctionSpec = map[string]string{
|
||||
"concurrency": "Maximum number of pods to be specialized which will serve requests This is optional. If not specified default value will be taken as 500",
|
||||
"requestsPerPod": "RequestsPerPod indicates the maximum number of concurrent requests that can be served by a specialized pod This is optional. If not specified default value will be taken as 1",
|
||||
"onceOnly": "OnceOnly specifies if specialized pod will serve exactly one request in its lifetime and would be garbage collected after serving that one request This is optional. If not specified default value will be taken as false",
|
||||
"podspec": "Podspec specifies podspec to use for executor type container based functions Different arguments mentioned for container based function are populated inside a pod.",
|
||||
}
|
||||
|
||||
func (FunctionSpec) SwaggerDoc() map[string]string {
|
||||
|
||||
@@ -274,6 +274,10 @@ func (spec FunctionSpec) Validate() error {
|
||||
result = multierror.Append(result, spec.InvokeStrategy.Validate())
|
||||
}
|
||||
|
||||
if spec.InvokeStrategy.ExecutionStrategy.ExecutorType == ExecutorTypeContainer && spec.PodSpec == nil {
|
||||
result = multierror.Append(result, MakeValidationErr(ErrorInvalidObject, "FunctionSpec.PodSpec", "", "executor type container requires a pod spec"))
|
||||
}
|
||||
|
||||
// TODO Add below validation warning
|
||||
/*if spec.FunctionTimeout <= 0 {
|
||||
result = multierror.Append(result, MakeValidationErr(ErrorInvalidValue, "FunctionTimeout value", spec.FunctionTimeout, "not a valid value. Should always be more than 0"))
|
||||
@@ -300,7 +304,7 @@ func (es ExecutionStrategy) Validate() error {
|
||||
result := &multierror.Error{}
|
||||
|
||||
switch es.ExecutorType {
|
||||
case ExecutorTypeNewdeploy, ExecutorTypePoolmgr: // no op
|
||||
case ExecutorTypeNewdeploy, ExecutorTypePoolmgr, ExecutorTypeContainer: // no op
|
||||
default:
|
||||
result = multierror.Append(result, MakeValidationErr(ErrorUnsupportedType, "ExecutionStrategy.ExecutorType", es.ExecutorType, "not a valid executor type"))
|
||||
}
|
||||
|
||||
@@ -431,6 +431,11 @@ func (in *FunctionSpec) DeepCopyInto(out *FunctionSpec) {
|
||||
*out = new(int)
|
||||
**out = **in
|
||||
}
|
||||
if in.PodSpec != nil {
|
||||
in, out := &in.PodSpec, &out.PodSpec
|
||||
*out = new(corev1.PodSpec)
|
||||
(*in).DeepCopyInto(*out)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user