diff --git a/api/v1alpha1/common.go b/api/v1alpha1/common.go index f9e542bce..d6431423b 100644 --- a/api/v1alpha1/common.go +++ b/api/v1alpha1/common.go @@ -246,8 +246,9 @@ const ( AtmostOnce ProcessGuarantee = "atmost_once" EffectivelyOnce ProcessGuarantee = "effectively_once" - DefaultTenant string = "public" - DefaultCluster string = "kubernetes" + DefaultTenant string = "public" + DefaultNamespace string = "default" + DefaultCluster string = "kubernetes" ) func validResourceRequirement(requirements corev1.ResourceRequirements) bool { diff --git a/api/v1alpha1/function_types.go b/api/v1alpha1/function_types.go index a79b73dd7..6cf8e0b77 100644 --- a/api/v1alpha1/function_types.go +++ b/api/v1alpha1/function_types.go @@ -32,6 +32,7 @@ type FunctionSpec struct { Name string `json:"name,omitempty"` ClassName string `json:"className,omitempty"` Tenant string `json:"tenant,omitempty"` + Namespace string `json:"namespace,omitempty"` ClusterName string `json:"clusterName,omitempty"` Replicas *int32 `json:"replicas,omitempty"` diff --git a/api/v1alpha1/function_webhook.go b/api/v1alpha1/function_webhook.go index fa39563fd..6d6eaabe9 100644 --- a/api/v1alpha1/function_webhook.go +++ b/api/v1alpha1/function_webhook.go @@ -72,6 +72,10 @@ func (r *Function) Default() { r.Spec.Tenant = DefaultTenant } + if r.Spec.Namespace == "" { + r.Spec.Namespace = DefaultNamespace + } + if r.Spec.MaxPendingAsyncRequests == nil { maxPending := int32(1000) r.Spec.MaxPendingAsyncRequests = &maxPending diff --git a/api/v1alpha1/sink_types.go b/api/v1alpha1/sink_types.go index 1a60a986e..9e75bdb12 100644 --- a/api/v1alpha1/sink_types.go +++ b/api/v1alpha1/sink_types.go @@ -33,6 +33,7 @@ type SinkSpec struct { ClassName string `json:"className,omitempty"` ClusterName string `json:"clusterName,omitempty"` Tenant string `json:"tenant,omitempty"` + Namespace string `json:"namespace,omitempty"` SinkType string `json:"sinkType,omitempty"` // refer to `--sink-type` as builtin connector Replicas *int32 `json:"replicas,omitempty"` diff --git a/api/v1alpha1/sink_webhook.go b/api/v1alpha1/sink_webhook.go index 1b33fcb5b..94e6c4374 100644 --- a/api/v1alpha1/sink_webhook.go +++ b/api/v1alpha1/sink_webhook.go @@ -72,6 +72,10 @@ func (r *Sink) Default() { r.Spec.Tenant = DefaultTenant } + if r.Spec.Namespace == "" { + r.Spec.Namespace = DefaultNamespace + } + if r.Spec.Resources.Requests != nil { if r.Spec.Resources.Requests.Cpu() == nil { r.Spec.Resources.Requests.Cpu().Set(int64(1)) diff --git a/api/v1alpha1/source_types.go b/api/v1alpha1/source_types.go index 861466a40..29d656341 100644 --- a/api/v1alpha1/source_types.go +++ b/api/v1alpha1/source_types.go @@ -32,6 +32,7 @@ type SourceSpec struct { Name string `json:"name,omitempty"` ClassName string `json:"className,omitempty"` Tenant string `json:"tenant,omitempty"` + Namespace string `json:"namespace,omitempty"` ClusterName string `json:"clusterName,omitempty"` SourceType string `json:"sourceType,omitempty"` // refer to `--source-type` as builtin connector Replicas *int32 `json:"replicas,omitempty"` diff --git a/api/v1alpha1/source_webhook.go b/api/v1alpha1/source_webhook.go index ee6c34db9..a9ce5934e 100644 --- a/api/v1alpha1/source_webhook.go +++ b/api/v1alpha1/source_webhook.go @@ -72,6 +72,10 @@ func (r *Source) Default() { r.Spec.Tenant = DefaultTenant } + if r.Spec.Namespace == "" { + r.Spec.Namespace = DefaultNamespace + } + if r.Spec.Resources.Requests != nil { if r.Spec.Resources.Requests.Cpu() == nil { r.Spec.Resources.Requests.Cpu().Set(int64(1)) diff --git a/charts/function-mesh-operator/crds/compute.functionmesh.io_functionmeshes.yaml b/charts/function-mesh-operator/crds/compute.functionmesh.io_functionmeshes.yaml index 18cbd7ebd..b5e263b8d 100644 --- a/charts/function-mesh-operator/crds/compute.functionmesh.io_functionmeshes.yaml +++ b/charts/function-mesh-operator/crds/compute.functionmesh.io_functionmeshes.yaml @@ -725,6 +725,10 @@ spec: - type type: object type: array + builtinAutoscaler: + items: + type: string + type: array imagePullSecrets: items: properties: @@ -3145,6 +3149,10 @@ spec: - type type: object type: array + builtinAutoscaler: + items: + type: string + type: array imagePullSecrets: items: properties: @@ -4944,6 +4952,8 @@ spec: type: string clusterName: type: string + forwardSourceMessageProperty: + type: boolean golang: properties: go: @@ -5543,6 +5553,10 @@ spec: - type type: object type: array + builtinAutoscaler: + items: + type: string + type: array imagePullSecrets: items: properties: diff --git a/charts/function-mesh-operator/crds/compute.functionmesh.io_functions.yaml b/charts/function-mesh-operator/crds/compute.functionmesh.io_functions.yaml index 947862775..e7fc91d48 100644 --- a/charts/function-mesh-operator/crds/compute.functionmesh.io_functions.yaml +++ b/charts/function-mesh-operator/crds/compute.functionmesh.io_functions.yaml @@ -726,6 +726,10 @@ spec: - type type: object type: array + builtinAutoscaler: + items: + type: string + type: array imagePullSecrets: items: properties: diff --git a/charts/function-mesh-operator/crds/compute.functionmesh.io_sinks.yaml b/charts/function-mesh-operator/crds/compute.functionmesh.io_sinks.yaml index 83f3a3cd7..c64d10a3f 100644 --- a/charts/function-mesh-operator/crds/compute.functionmesh.io_sinks.yaml +++ b/charts/function-mesh-operator/crds/compute.functionmesh.io_sinks.yaml @@ -660,6 +660,10 @@ spec: - type type: object type: array + builtinAutoscaler: + items: + type: string + type: array imagePullSecrets: items: properties: diff --git a/charts/function-mesh-operator/crds/compute.functionmesh.io_sources.yaml b/charts/function-mesh-operator/crds/compute.functionmesh.io_sources.yaml index 1dc29098f..b3b22344f 100644 --- a/charts/function-mesh-operator/crds/compute.functionmesh.io_sources.yaml +++ b/charts/function-mesh-operator/crds/compute.functionmesh.io_sources.yaml @@ -36,6 +36,8 @@ spec: type: string clusterName: type: string + forwardSourceMessageProperty: + type: boolean golang: properties: go: @@ -635,6 +637,10 @@ spec: - type type: object type: array + builtinAutoscaler: + items: + type: string + type: array imagePullSecrets: items: properties: diff --git a/config/crd/bases/compute.functionmesh.io_functionmeshes.yaml b/config/crd/bases/compute.functionmesh.io_functionmeshes.yaml index b5e263b8d..4d54c48e5 100644 --- a/config/crd/bases/compute.functionmesh.io_functionmeshes.yaml +++ b/config/crd/bases/compute.functionmesh.io_functionmeshes.yaml @@ -151,6 +151,8 @@ spec: type: integer name: type: string + namespace: + type: string output: properties: customSchemaSinks: @@ -2631,6 +2633,8 @@ spec: type: integer name: type: string + namespace: + type: string negativeAckRedeliveryDelayMs: format: int32 type: integer @@ -4979,6 +4983,8 @@ spec: type: integer name: type: string + namespace: + type: string output: properties: customSchemaSinks: diff --git a/config/crd/bases/compute.functionmesh.io_functions.yaml b/config/crd/bases/compute.functionmesh.io_functions.yaml index e7fc91d48..72a11da17 100644 --- a/config/crd/bases/compute.functionmesh.io_functions.yaml +++ b/config/crd/bases/compute.functionmesh.io_functions.yaml @@ -152,6 +152,8 @@ spec: type: integer name: type: string + namespace: + type: string output: properties: customSchemaSinks: diff --git a/config/crd/bases/compute.functionmesh.io_sinks.yaml b/config/crd/bases/compute.functionmesh.io_sinks.yaml index c64d10a3f..38edca51d 100644 --- a/config/crd/bases/compute.functionmesh.io_sinks.yaml +++ b/config/crd/bases/compute.functionmesh.io_sinks.yaml @@ -142,6 +142,8 @@ spec: type: integer name: type: string + namespace: + type: string negativeAckRedeliveryDelayMs: format: int32 type: integer diff --git a/config/crd/bases/compute.functionmesh.io_sources.yaml b/config/crd/bases/compute.functionmesh.io_sources.yaml index b3b22344f..9a9e22c3a 100644 --- a/config/crd/bases/compute.functionmesh.io_sources.yaml +++ b/config/crd/bases/compute.functionmesh.io_sources.yaml @@ -63,6 +63,8 @@ spec: type: integer name: type: string + namespace: + type: string output: properties: customSchemaSinks: diff --git a/controllers/spec/utils.go b/controllers/spec/utils.go index d82f15f2e..6ba6a06ed 100644 --- a/controllers/spec/utils.go +++ b/controllers/spec/utils.go @@ -34,7 +34,7 @@ func convertFunctionDetails(function *v1alpha1.Function) *proto.FunctionDetails return &proto.FunctionDetails{ Tenant: function.Spec.Tenant, - Namespace: function.Namespace, + Namespace: function.Spec.Namespace, Name: function.Spec.Name, ClassName: function.Spec.ClassName, LogTopic: function.Spec.LogTopic, @@ -67,7 +67,7 @@ func convertGoFunctionConfs(function *v1alpha1.Function) *GoFunctionConf { Port: int(GRPCPort.ContainerPort), ClusterName: function.Spec.ClusterName, Tenant: function.Spec.Tenant, - NameSpace: function.Namespace, + NameSpace: function.Spec.Namespace, Name: function.Spec.Name, LogTopic: function.Spec.LogTopic, ProcessingGuarantees: int32(convertProcessingGuarantee(function.Spec.ProcessingGuarantee)), @@ -204,7 +204,7 @@ func generateFunctionOutputSpec(function *v1alpha1.Function) *proto.SinkSpec { func convertSourceDetails(source *v1alpha1.Source) *proto.FunctionDetails { return &proto.FunctionDetails{ Tenant: source.Spec.Tenant, - Namespace: source.Namespace, + Namespace: source.Spec.Namespace, Name: source.Name, ClassName: "org.apache.pulsar.functions.api.utils.IdentityFunction", ProcessingGuarantees: convertProcessingGuarantee(source.Spec.ProcessingGuarantee), @@ -262,7 +262,7 @@ func generateSourceOutputSpec(source *v1alpha1.Source) *proto.SinkSpec { func convertSinkDetails(sink *v1alpha1.Sink) *proto.FunctionDetails { return &proto.FunctionDetails{ Tenant: sink.Spec.Tenant, - Namespace: sink.Namespace, + Namespace: sink.Spec.Namespace, Name: sink.Name, ClassName: "org.apache.pulsar.functions.api.utils.IdentityFunction", ProcessingGuarantees: convertProcessingGuarantee(sink.Spec.ProcessingGuarantee), diff --git a/manifests/crd.yaml b/manifests/crd.yaml index 4ac2a19c0..6b73066d9 100644 --- a/manifests/crd.yaml +++ b/manifests/crd.yaml @@ -149,6 +149,8 @@ spec: type: integer name: type: string + namespace: + type: string output: properties: customSchemaSinks: @@ -2629,6 +2631,8 @@ spec: type: integer name: type: string + namespace: + type: string negativeAckRedeliveryDelayMs: format: int32 type: integer @@ -4977,6 +4981,8 @@ spec: type: integer name: type: string + namespace: + type: string output: properties: customSchemaSinks: @@ -7540,6 +7546,8 @@ spec: type: integer name: type: string + namespace: + type: string output: properties: customSchemaSinks: @@ -10084,6 +10092,8 @@ spec: type: integer name: type: string + namespace: + type: string negativeAckRedeliveryDelayMs: format: int32 type: integer @@ -12496,6 +12506,8 @@ spec: type: integer name: type: string + namespace: + type: string output: properties: customSchemaSinks: