Keda podspec (#2021)
* Add podspec to MQT Signed-off-by: Harsh Thakur <harshthakur9030@gmail.com> * Add preupgrade check Signed-off-by: Harsh Thakur <harshthakur9030@gmail.com> * Use zap logger Signed-off-by: Harsh Thakur <harshthakur9030@gmail.com> Co-authored-by: Sanket Sudake <sanketsudake@gmail.com>
This commit is contained in:
co-authored by
Sanket Sudake
parent
4ff204a0c4
commit
4e2632e100
@@ -490,6 +490,7 @@ type (
|
||||
// Function Reference by weight. this map contains function name as key and its weight
|
||||
// as the value. This is for canary upgrade purpose.
|
||||
// +nullable
|
||||
// +optional
|
||||
FunctionWeights map[string]int `json:"functionweights"`
|
||||
}
|
||||
|
||||
@@ -768,6 +769,16 @@ type (
|
||||
// Kind of Message Queue Trigger to be created, by default its fission
|
||||
// +optional
|
||||
MqtKind string `json:"mqtkind,omitempty"`
|
||||
|
||||
// (Optional) Podspec allows modification of deployed runtime pod with Kubernetes PodSpec
|
||||
// The merging logic is briefly described below and detailed MergePodSpec function
|
||||
// - Volumes mounts and env variables for function and fetcher container are appended
|
||||
// - All additional containers and init containers are appended
|
||||
// - Volume definitions are appended
|
||||
// - Lists such as tolerations, ImagePullSecrets, HostAliases are appended
|
||||
// - Structs are merged and variables from pod spec take precedence
|
||||
// +optional
|
||||
PodSpec *apiv1.PodSpec `json:"podspec,omitempty"`
|
||||
}
|
||||
|
||||
// TimeTriggerSpec invokes the specific function at a time or
|
||||
|
||||
@@ -737,6 +737,11 @@ func (in *MessageQueueTriggerSpec) DeepCopyInto(out *MessageQueueTriggerSpec) {
|
||||
(*out)[key] = val
|
||||
}
|
||||
}
|
||||
if in.PodSpec != nil {
|
||||
in, out := &in.PodSpec, &out.PodSpec
|
||||
*out = new(corev1.PodSpec)
|
||||
(*in).DeepCopyInto(*out)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@ import (
|
||||
"context"
|
||||
"fmt"
|
||||
"os"
|
||||
"reflect"
|
||||
"regexp"
|
||||
"strconv"
|
||||
"strings"
|
||||
@@ -23,6 +24,7 @@ import (
|
||||
|
||||
fv1 "github.com/fission/fission/pkg/apis/core/v1"
|
||||
"github.com/fission/fission/pkg/crd"
|
||||
"github.com/fission/fission/pkg/executor/util"
|
||||
"github.com/fission/fission/pkg/utils"
|
||||
)
|
||||
|
||||
@@ -265,7 +267,12 @@ func checkAndUpdateTriggerFields(mqt, newMqt *fv1.MessageQueueTrigger) bool {
|
||||
updated = true
|
||||
}
|
||||
if len(newMqt.Spec.FunctionReference.Name) > 0 && newMqt.Spec.FunctionReference.Name != mqt.Spec.FunctionReference.Name {
|
||||
newMqt.Spec.FunctionReference.Name = mqt.Spec.FunctionReference.Name
|
||||
mqt.Spec.FunctionReference.Name = newMqt.Spec.FunctionReference.Name
|
||||
updated = true
|
||||
}
|
||||
|
||||
if !reflect.DeepEqual(newMqt.Spec.PodSpec, mqt.Spec.PodSpec) {
|
||||
mqt.Spec.PodSpec = newMqt.Spec.PodSpec
|
||||
updated = true
|
||||
}
|
||||
|
||||
@@ -395,6 +402,21 @@ func getDeploymentSpec(mqt *fv1.MessageQueueTrigger, routerURL string, kubeClien
|
||||
image := os.Getenv(strings.ToUpper(imageName))
|
||||
imagePullPolicy := utils.GetImagePullPolicy(os.Getenv("CONNECTOR_IMAGE_PULL_POLICY"))
|
||||
|
||||
podSpec := &apiv1.PodSpec{
|
||||
Containers: []apiv1.Container{
|
||||
{
|
||||
Name: mqt.ObjectMeta.Name,
|
||||
Image: image,
|
||||
ImagePullPolicy: imagePullPolicy,
|
||||
Env: envVars,
|
||||
},
|
||||
},
|
||||
}
|
||||
podSpec, err = util.MergePodSpec(podSpec, mqt.Spec.PodSpec)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
blockOwnerDeletion := true
|
||||
return &appsv1.Deployment{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
@@ -424,16 +446,7 @@ func getDeploymentSpec(mqt *fv1.MessageQueueTrigger, routerURL string, kubeClien
|
||||
"app": mqt.ObjectMeta.Name,
|
||||
},
|
||||
},
|
||||
Spec: apiv1.PodSpec{
|
||||
Containers: []apiv1.Container{
|
||||
{
|
||||
Name: mqt.ObjectMeta.Name,
|
||||
Image: image,
|
||||
ImagePullPolicy: imagePullPolicy,
|
||||
Env: envVars,
|
||||
},
|
||||
},
|
||||
},
|
||||
Spec: *podSpec,
|
||||
},
|
||||
},
|
||||
}, nil
|
||||
|
||||
Reference in New Issue
Block a user