Repository: knative-sandbox/eventing-rabbitmq (go)

Issue:
Add `resource.[requests|limits]` to reconciled objects
**Problem**
Skimming through the `reconciler` codebase/folders, it seems that none of the deployments/pods created have any `resources` specified. This can lead to performance and stability issues, especially not meeting the documented scaling behavior (#408).

**[Persona:](https://github.com/knative/eventing/blob/main/docs/personas.md)**
Operators and users.

**Exit Criteria**
Documented scaling limits (benchmarks) are met even when deploying the resources in a constrained (overutilized) cluster.

**Time Estimate (optional):**
Implementation is straightforward (add `requests` and/or `limits`), but finding the right values might take time (in benchmarks).

**Additional context (optional)**
Even without benchmarking, adding sane defaults (at least `requests`) should be done for the various reconciled resources.

cc/ @salaboy @gabo1208 


Pull request description:
Deployments resources
<!-- Thanks for sending a pull request! -->

# Changes

<!-- 
Describe your changes here- ideally you can get that description straight from
your descriptive commit message(s)! 

- :gift: Add new feature
- :bug: Fix bug
- :broom: Update or clean up current behavior
- :wastebasket: Remove feature or internal logic
-->

- 🎁 Now the Broker's Ingress and Dispatcher have deployment resource requests and limits
- 🎁 Now the Source's Receive Adapter have deployment resources requests and limits
Both are based on an overall stimation with a scenario where 1500msgs/s are sent over a parallelism of 1000 

<!--
In addition, categorize the changes you're making using the "/kind" Prow command, example:

/kind <kind>

Supported kinds are: api-change, bug, cleanup, deprecation, removal, documentation, enhancement, performance

-->
/kind enhancement

<!--
*Automatically closes linked issue when PR is merged.
Usage: `Fixes #<issue number>`, or `Fixes (paste link of issue)`.
_If PR is about `failing-tests or flakes`, please post the related issues/tests in a comment and do not use `Fixes`_*
-->
Fixes #703 

<!-- Please include the 'why' behind your changes if no issue exists -->

**Release Note**

<!--
:page_facing_up: If this change has user-visible impact, write a release note in the block
below. Include the string "action required" if additional action is required of
users switching to the new release, for example in case of a breaking change.

Write as if you are speaking to users, not other Knative contributors. If this
change has no user-visible impact, no release-note is needed.
-->
```release-note
- 🎁 Now the Broker's Ingress and Dispatcher have deployment resource requests and limits
- 🎁 Now the Source's Receive Adapter have deployment resources requests and limits
```



Patch:
diff --git a/.github/workflows/kind-conformance.yaml b/.github/workflows/kind-conformance.yaml
index 906c787a..dc801bab 100644
--- a/.github/workflows/kind-conformance.yaml
+++ b/.github/workflows/kind-conformance.yaml
@@ -24,7 +24,7 @@ jobs:
 
         # Map between K8s and KinD versions.
         # This is attempting to make it a bit clearer what's being tested.
-        # See: https://github.com/kubernetes-sigs/kind/releases/tag/v0.11.1
+        # See: https://github.com/kubernetes-sigs/kind/releases/tag/v0.12.0
         include:
         - k8s-version: v1.22.1
           kind-image-sha: sha256:100b3558428386d1372591f8d62add85b900538d94db8e455b66ebaf05a3ca3a
diff --git a/Makefile b/Makefile
index ba3fe565..b09e4338 100644
--- a/Makefile
+++ b/Makefile
@@ -77,7 +77,7 @@ releases-gcloud:
 	$(OPEN) https://cloud.google.com/sdk/docs/quickstart
 
 KO_RELEASES := https://github.com/google/ko/releases
-KO_VERSION := 0.9.3
+KO_VERSION := 0.11.2
 KO_BIN_DIR := $(LOCAL_BIN)/ko_$(KO_VERSION)_$(PLATFORM)_x86_64
 KO_URL := $(KO_RELEASES)/download/v$(KO_VERSION)/$(notdir $(KO_BIN_DIR)).tar.gz
 KO := $(KO_BIN_DIR)/ko
@@ -95,7 +95,7 @@ releases-ko:
 	$(OPEN) $(KO_RELEASES)
 
 KIND_RELEASES := https://github.com/kubernetes-sigs/kind/releases
-KIND_VERSION := 0.11.1
+KIND_VERSION := 0.12.0
 KIND_URL := $(KIND_RELEASES)/download/v$(KIND_VERSION)/kind-$(platform)-amd64
 KIND := $(LOCAL_BIN)/kind_$(KIND_VERSION)_$(platform)_amd64
 $(KIND): | $(CURL) $(LOCAL_BIN)
@@ -131,7 +131,7 @@ releases-envsubst:
 
 KUBECTL_RELEASES := https://github.com/kubernetes/kubernetes/tags
 # Keep this in sync with KIND_K8S_VERSION
-KUBECTL_VERSION := 1.22.1
+KUBECTL_VERSION := 1.24.0
 KUBECTL_BIN := kubectl-$(KUBECTL_VERSION)-$(platform)-amd64
 KUBECTL_URL := https://storage.googleapis.com/kubernetes-release/release/v$(KUBECTL_VERSION)/bin/$(platform)/amd64/kubectl
 KUBECTL := $(LOCAL_BIN)/$(KUBECTL_BIN)
@@ -313,7 +313,7 @@ install-rabbitmq-cluster-operator: | $(KUBECONFIG) $(KUBECTL) ## Install RabbitM
 # https://github.com/jetstack/cert-manager/releases
 # ⚠️  You may want to keep this in sync with RABBITMQ_TOPOLOGY_OPERATOR_VERSION
 # In other words, don't upgrade cert-manager to a version that was released AFTER RABBITMQ_TOPOLOGY_OPERATOR_VERSION
-CERT_MANAGER_VERSION ?= 1.7.0
+CERT_MANAGER_VERSION ?= 1.8.0
 .PHONY: install-cert-manager
 install-cert-manager: | $(KUBECONFIG) $(KUBECTL) ## Install Cert Manager - dependency of RabbitMQ Topology Operator
 	$(KUBECTL) $(K_CMD) --filename \
@@ -321,13 +321,13 @@ install-cert-manager: | $(KUBECONFIG) $(KUBECTL) ## Install Cert Manager - depen
 	$(KUBECTL) wait --for=condition=available deploy/cert-manager-webhook --timeout=60s --namespace $(CERT_MANAGER_NAMESPACE)
 
 # https://github.com/rabbitmq/messaging-topology-operator/releases
-RABBITMQ_TOPOLOGY_OPERATOR_VERSION ?= 1.4.1
+RABBITMQ_TOPOLOGY_OPERATOR_VERSION ?= 1.6.0
 .PHONY: install-rabbitmq-topology-operator
 install-rabbitmq-topology-operator: | install-cert-manager $(KUBECTL) ## Install RabbitMQ Topology Operator
 	$(KUBECTL) $(K_CMD) --filename \
 		https://github.com/rabbitmq/messaging-topology-operator/releases/download/v$(RABBITMQ_TOPOLOGY_OPERATOR_VERSION)/messaging-topology-operator-with-certmanager.yaml
 
-KNATIVE_VERSION ?= 1.1.0
+KNATIVE_VERSION ?= 1.4.0
 
 # https://github.com/knative/serving/releases
 .PHONY: install-knative-serving
diff --git a/pkg/reconciler/broker/resources/dispatcher.go b/pkg/reconciler/broker/resources/dispatcher.go
index c8243526..caabac92 100644
--- a/pkg/reconciler/broker/resources/dispatcher.go
+++ b/pkg/reconciler/broker/resources/dispatcher.go
@@ -21,6 +21,7 @@ import (
 
 	appsv1 "k8s.io/api/apps/v1"
 	corev1 "k8s.io/api/core/v1"
+	"k8s.io/apimachinery/pkg/api/resource"
 	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
 
 	"github.com/rickb777/date/period"
@@ -146,6 +147,16 @@ func MakeDispatcherDeployment(args *DispatcherArgs) *appsv1.Deployment {
 						Name:  dispatcherContainerName,
 						Image: args.Image,
 						Env:   envs,
+						// This resource requests and limits comes from performance testing 1500msgs/s with a parallelism of 1000
+						// more info in this issue: https://github.com/knative-sandbox/eventing-rabbitmq/issues/703
+						Resources: corev1.ResourceRequirements{
+							Requests: corev1.ResourceList{
+								corev1.ResourceCPU:    resource.MustParse("300m"),
+								corev1.ResourceMemory: resource.MustParse("64Mi")},
+							Limits: corev1.ResourceList{
+								corev1.ResourceCPU:    resource.MustParse("4000m"),
+								corev1.ResourceMemory: resource.MustParse("600Mi")},
+						},
 					}},
 				},
 			},
diff --git a/pkg/reconciler/broker/resources/ingress.go b/pkg/reconciler/broker/resources/ingress.go
index 69af9c28..6d40b4f8 100644
--- a/pkg/reconciler/broker/resources/ingress.go
+++ b/pkg/reconciler/broker/resources/ingress.go
@@ -21,6 +21,7 @@ import (
 
 	appsv1 "k8s.io/api/apps/v1"
 	corev1 "k8s.io/api/core/v1"
+	"k8s.io/apimachinery/pkg/api/resource"
 	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
 	"k8s.io/apimachinery/pkg/util/intstr"
 
@@ -120,6 +121,16 @@ func MakeIngressDeployment(args *IngressArgs) *appsv1.Deployment {
 							ContainerPort: 8080,
 							Name:          "http",
 						}},
+						// This resource requests and limits comes from performance testing 1500msgs/s with a parallelism of 1000
+						// more info in this issue: https://github.com/knative-sandbox/eventing-rabbitmq/issues/703
+						Resources: corev1.ResourceRequirements{
+							Requests: corev1.ResourceList{
+								corev1.ResourceCPU:    resource.MustParse("150m"),
+								corev1.ResourceMemory: resource.MustParse("32Mi")},
+							Limits: corev1.ResourceList{
+								corev1.ResourceCPU:    resource.MustParse("1000m"),
+								corev1.ResourceMemory: resource.MustParse("400Mi")},
+						},
 					}},
 				},
 			},
diff --git a/pkg/reconciler/source/resources/receive_adapter.go b/pkg/reconciler/source/resources/receive_adapter.go
index 1ba1d7cf..7b1d76e7 100644
--- a/pkg/reconciler/source/resources/receive_adapter.go
+++ b/pkg/reconciler/source/resources/receive_adapter.go
@@ -23,6 +23,7 @@ import (
 	"github.com/rickb777/date/period"
 	v1 "k8s.io/api/apps/v1"
 	corev1 "k8s.io/api/core/v1"
+	"k8s.io/apimachinery/pkg/api/resource"
 	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
 	"knative.dev/eventing-rabbitmq/pkg/apis/sources/v1alpha1"
 	eventingduckv1 "knative.dev/eventing/pkg/apis/duck/v1"
@@ -189,6 +190,16 @@ func MakeReceiveAdapter(args *ReceiveAdapterArgs) *v1.Deployment {
 							Image:           args.Image,
 							ImagePullPolicy: "IfNotPresent",
 							Env:             env,
+							// This resource requests and limits comes from performance testing 1500msgs/s with a parallelism of 1000
+							// more info in this issue: https://github.com/knative-sandbox/eventing-rabbitmq/issues/703
+							Resources: corev1.ResourceRequirements{
+								Requests: corev1.ResourceList{
+									corev1.ResourceCPU:    resource.MustParse("300m"),
+									corev1.ResourceMemory: resource.MustParse("64Mi")},
+								Limits: corev1.ResourceList{
+									corev1.ResourceCPU:    resource.MustParse("4000m"),
+									corev1.ResourceMemory: resource.MustParse("600Mi")},
+							},
 						},
 					},
 				},
diff --git a/pkg/reconciler/trigger/resources/dispatcher.go b/pkg/reconciler/trigger/resources/dispatcher.go
index d63f6fad..e1bac858 100644
--- a/pkg/reconciler/trigger/resources/dispatcher.go
+++ b/pkg/reconciler/trigger/resources/dispatcher.go
@@ -24,6 +24,7 @@ import (
 	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
 
 	"github.com/rickb777/date/period"
+	"k8s.io/apimachinery/pkg/api/resource"
 	eventingduckv1 "knative.dev/eventing/pkg/apis/duck/v1"
 	"knative.dev/eventing/pkg/apis/eventing"
 	eventingv1 "knative.dev/eventing/pkg/apis/eventing/v1"
@@ -91,6 +92,16 @@ func MakeDispatcherDeployment(args *DispatcherArgs) *appsv1.Deployment {
 			Name:  "BROKER_INGRESS_URL",
 			Value: args.BrokerIngressURL.String(),
 		}},
+		// This resource requests and limits comes from performance testing 1500msgs/s with a parallelism of 1000
+		// more info in this issue: https://github.com/knative-sandbox/eventing-rabbitmq/issues/703
+		Resources: corev1.ResourceRequirements{
+			Requests: corev1.ResourceList{
+				corev1.ResourceCPU:    resource.MustParse("300m"),
+				corev1.ResourceMemory: resource.MustParse("64Mi")},
+			Limits: corev1.ResourceList{
+				corev1.ResourceCPU:    resource.MustParse("4000m"),
+				corev1.ResourceMemory: resource.MustParse("600Mi")},
+		},
 	}
 	if args.Configs != nil {
 		dispatcher.Env = append(dispatcher.Env, args.Configs.ToEnvVars()...)


Test patch:
diff --git a/.github/workflows/kind-e2e.yaml b/.github/workflows/kind-e2e.yaml
index 80ea7f28..12edd83e 100644
--- a/.github/workflows/kind-e2e.yaml
+++ b/.github/workflows/kind-e2e.yaml
@@ -18,12 +18,12 @@ jobs:
         - v1.22.1
         - v1.23.3
         knative-version:
-        - 1.0.2
-        - 1.1.0
+        - 1.3.2
+        - 1.4.0
 
         # Map between K8s and KinD versions.
         # This is attempting to make it a bit clearer what's being tested.
-        # See: https://github.com/kubernetes-sigs/kind/releases/tag/v0.11.1
+        # See: https://github.com/kubernetes-sigs/kind/releases/tag/v0.12.0
         include:
         - k8s-version: v1.22.1
           kind-image-sha: sha256:100b3558428386d1372591f8d62add85b900538d94db8e455b66ebaf05a3ca3a
diff --git a/pkg/reconciler/broker/resources/dispatcher_test.go b/pkg/reconciler/broker/resources/dispatcher_test.go
index e199ddd0..c98f4400 100644
--- a/pkg/reconciler/broker/resources/dispatcher_test.go
+++ b/pkg/reconciler/broker/resources/dispatcher_test.go
@@ -22,6 +22,7 @@ import (
 	"github.com/google/go-cmp/cmp"
 	appsv1 "k8s.io/api/apps/v1"
 	corev1 "k8s.io/api/core/v1"
+	"k8s.io/apimachinery/pkg/api/resource"
 	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
 	v1 "knative.dev/eventing/pkg/apis/duck/v1"
 	eventingv1 "knative.dev/eventing/pkg/apis/eventing/v1"
@@ -105,6 +106,14 @@ func TestMakeDispatcherDeployment(t *testing.T) {
 					Containers: []corev1.Container{{
 						Name:  "dispatcher",
 						Image: image,
+						Resources: corev1.ResourceRequirements{
+							Requests: corev1.ResourceList{
+								corev1.ResourceCPU:    resource.MustParse("300m"),
+								corev1.ResourceMemory: resource.MustParse("64Mi")},
+							Limits: corev1.ResourceList{
+								corev1.ResourceCPU:    resource.MustParse("4000m"),
+								corev1.ResourceMemory: resource.MustParse("600Mi")},
+						},
 						Env: []corev1.EnvVar{{
 							Name:  system.NamespaceEnvKey,
 							Value: system.Namespace(),
diff --git a/pkg/reconciler/broker/resources/ingress_test.go b/pkg/reconciler/broker/resources/ingress_test.go
index 31119838..c16bce3a 100644
--- a/pkg/reconciler/broker/resources/ingress_test.go
+++ b/pkg/reconciler/broker/resources/ingress_test.go
@@ -22,6 +22,7 @@ import (
 	"github.com/google/go-cmp/cmp"
 	appsv1 "k8s.io/api/apps/v1"
 	corev1 "k8s.io/api/core/v1"
+	"k8s.io/apimachinery/pkg/api/resource"
 	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
 	"k8s.io/apimachinery/pkg/util/intstr"
 	eventingv1 "knative.dev/eventing/pkg/apis/eventing/v1"
@@ -82,6 +83,14 @@ func TestMakeIngressDeployment(t *testing.T) {
 					Containers: []corev1.Container{{
 						Image: image,
 						Name:  "ingress",
+						Resources: corev1.ResourceRequirements{
+							Requests: corev1.ResourceList{
+								corev1.ResourceCPU:    resource.MustParse("150m"),
+								corev1.ResourceMemory: resource.MustParse("32Mi")},
+							Limits: corev1.ResourceList{
+								corev1.ResourceCPU:    resource.MustParse("1000m"),
+								corev1.ResourceMemory: resource.MustParse("400Mi")},
+						},
 						Env: []corev1.EnvVar{{
 							Name:  system.NamespaceEnvKey,
 							Value: system.Namespace(),
diff --git a/pkg/reconciler/source/resources/receive_adapter_test.go b/pkg/reconciler/source/resources/receive_adapter_test.go
index 2a3e7d79..a1bcde6c 100644
--- a/pkg/reconciler/source/resources/receive_adapter_test.go
+++ b/pkg/reconciler/source/resources/receive_adapter_test.go
@@ -22,6 +22,7 @@ import (
 	"github.com/google/go-cmp/cmp"
 	v1 "k8s.io/api/apps/v1"
 	corev1 "k8s.io/api/core/v1"
+	"k8s.io/apimachinery/pkg/api/resource"
 	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
 	v1alpha12 "knative.dev/eventing-rabbitmq/pkg/apis/sources/v1alpha1"
 	eventingduckv1 "knative.dev/eventing/pkg/apis/duck/v1"
@@ -153,6 +154,14 @@ func TestMakeReceiveAdapter(t *testing.T) {
 									Name:            "receive-adapter",
 									Image:           "test-image",
 									ImagePullPolicy: "IfNotPresent",
+									Resources: corev1.ResourceRequirements{
+										Requests: corev1.ResourceList{
+											corev1.ResourceCPU:    resource.MustParse("300m"),
+											corev1.ResourceMemory: resource.MustParse("64Mi")},
+										Limits: corev1.ResourceList{
+											corev1.ResourceCPU:    resource.MustParse("4000m"),
+											corev1.ResourceMemory: resource.MustParse("600Mi")},
+									},
 									Env: []corev1.EnvVar{
 										{
 											Name:  "RABBITMQ_BROKERS",
diff --git a/pkg/reconciler/trigger/resources/dispatcher_test.go b/pkg/reconciler/trigger/resources/dispatcher_test.go
index 56846570..ea7c550a 100644
--- a/pkg/reconciler/trigger/resources/dispatcher_test.go
+++ b/pkg/reconciler/trigger/resources/dispatcher_test.go
@@ -22,6 +22,7 @@ import (
 	"github.com/google/go-cmp/cmp"
 	appsv1 "k8s.io/api/apps/v1"
 	corev1 "k8s.io/api/core/v1"
+	"k8s.io/apimachinery/pkg/api/resource"
 	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
 	"k8s.io/utils/pointer"
 	eventingduckv1 "knative.dev/eventing/pkg/apis/duck/v1"
@@ -136,6 +137,14 @@ func deployment(opts ...func(*appsv1.Deployment)) *appsv1.Deployment {
 					Containers: []corev1.Container{{
 						Name:  "dispatcher",
 						Image: image,
+						Resources: corev1.ResourceRequirements{
+							Requests: corev1.ResourceList{
+								corev1.ResourceCPU:    resource.MustParse("300m"),
+								corev1.ResourceMemory: resource.MustParse("64Mi")},
+							Limits: corev1.ResourceList{
+								corev1.ResourceCPU:    resource.MustParse("4000m"),
+								corev1.ResourceMemory: resource.MustParse("600Mi")},
+						},
 						Env: []corev1.EnvVar{{
 							Name:  system.NamespaceEnvKey,
 							Value: system.Namespace(),
diff --git a/test/e2e/kind.yaml b/test/e2e/kind.yaml
index db7ad33a..1175befc 100644
--- a/test/e2e/kind.yaml
+++ b/test/e2e/kind.yaml
@@ -21,3 +21,5 @@ nodes:
   image: kindest/node:${KIND_K8S_VERSION}@${KIND_K8S_DIGEST}
 - role: worker
   image: kindest/node:${KIND_K8S_VERSION}@${KIND_K8S_DIGEST}
+- role: worker
+  image: kindest/node:${KIND_K8S_VERSION}@${KIND_K8S_DIGEST}