diff --git a/pkg/deploy/gateway/gateway.go b/pkg/deploy/gateway/gateway.go index 155046522..2d63d9f23 100644 --- a/pkg/deploy/gateway/gateway.go +++ b/pkg/deploy/gateway/gateway.go @@ -17,6 +17,8 @@ import ( "fmt" "io/ioutil" + "k8s.io/apimachinery/pkg/api/resource" + "sigs.k8s.io/yaml" "github.com/sirupsen/logrus" @@ -535,11 +537,31 @@ func getContainersSpec(instance *orgv1.CheCluster) []corev1.Container { Image: gatewayImage, ImagePullPolicy: corev1.PullAlways, VolumeMounts: getTraefikContainerVolumeMounts(instance), + Resources: corev1.ResourceRequirements{ + Limits: corev1.ResourceList{ + corev1.ResourceMemory: resource.MustParse("4Gi"), + corev1.ResourceCPU: resource.MustParse("1"), + }, + Requests: corev1.ResourceList{ + corev1.ResourceMemory: resource.MustParse("128Mi"), + corev1.ResourceCPU: resource.MustParse("0.1"), + }, + }, }, { Name: "configbump", Image: configSidecarImage, ImagePullPolicy: corev1.PullAlways, + Resources: corev1.ResourceRequirements{ + Limits: corev1.ResourceList{ + corev1.ResourceMemory: resource.MustParse("256Mi"), + corev1.ResourceCPU: resource.MustParse("0.5"), + }, + Requests: corev1.ResourceList{ + corev1.ResourceMemory: resource.MustParse("64Mi"), + corev1.ResourceCPU: resource.MustParse("0.05"), + }, + }, VolumeMounts: []corev1.VolumeMount{ { Name: "dynamic-config", diff --git a/pkg/deploy/gateway/gateway_test.go b/pkg/deploy/gateway/gateway_test.go index 0b9b6d268..e07a2b1b2 100644 --- a/pkg/deploy/gateway/gateway_test.go +++ b/pkg/deploy/gateway/gateway_test.go @@ -66,8 +66,10 @@ func TestSyncAllToCluster(t *testing.T) { t.Fatalf("Failed to get deployment: %v", err) } - if len(deployment.Spec.Template.Spec.Containers) != 2 { - t.Fatalf("With classic multi-user, there should be 2 containers in the gateway, traefik and configbump. But it has '%d' containers.", len(deployment.Spec.Template.Spec.Containers)) + assert.Lenf(t, deployment.Spec.Template.Spec.Containers, 2, + "With classic multi-user, there should be 2 containers in the gateway, traefik and configbump. But it has '%d' containers.", len(deployment.Spec.Template.Spec.Containers)) + for _, c := range deployment.Spec.Template.Spec.Containers { + assert.NotNil(t, c.Resources, "container '%s' has not set resources", c.Name) } service := &corev1.Service{} @@ -121,6 +123,7 @@ func TestNativeUserGateway(t *testing.T) { } for _, c := range deployment.Spec.Template.Spec.Containers { + assert.NotNil(t, c.Resources, "container '%s' has not set resources", c.Name) if c.Name == "gateway" { if len(c.VolumeMounts) != 3 { t.Fatalf("gateway container should have 3 mounts, but it has '%d' ... \n%+v", len(c.VolumeMounts), c.VolumeMounts) diff --git a/pkg/deploy/gateway/kube_rbac_proxy.go b/pkg/deploy/gateway/kube_rbac_proxy.go index 1e67bd70c..86cafec99 100644 --- a/pkg/deploy/gateway/kube_rbac_proxy.go +++ b/pkg/deploy/gateway/kube_rbac_proxy.go @@ -17,6 +17,7 @@ import ( "github.com/eclipse-che/che-operator/pkg/deploy" "github.com/eclipse-che/che-operator/pkg/util" corev1 "k8s.io/api/core/v1" + "k8s.io/apimachinery/pkg/api/resource" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) @@ -64,6 +65,16 @@ func getKubeRbacProxyContainerSpec(instance *orgv1.CheCluster) corev1.Container MountPath: "/etc/kube-rbac-proxy", }, }, + Resources: corev1.ResourceRequirements{ + Limits: corev1.ResourceList{ + corev1.ResourceMemory: resource.MustParse("512Mi"), + corev1.ResourceCPU: resource.MustParse("0.5"), + }, + Requests: corev1.ResourceList{ + corev1.ResourceMemory: resource.MustParse("64Mi"), + corev1.ResourceCPU: resource.MustParse("0.1"), + }, + }, } } diff --git a/pkg/deploy/gateway/oauth_proxy.go b/pkg/deploy/gateway/oauth_proxy.go index 1da582031..f80cb6d53 100644 --- a/pkg/deploy/gateway/oauth_proxy.go +++ b/pkg/deploy/gateway/oauth_proxy.go @@ -16,6 +16,8 @@ import ( "fmt" "strings" + "k8s.io/apimachinery/pkg/api/resource" + orgv1 "github.com/eclipse-che/che-operator/api/v1" "github.com/eclipse-che/che-operator/pkg/deploy" "github.com/eclipse-che/che-operator/pkg/util" @@ -142,6 +144,16 @@ func getOauthProxyContainerSpec(instance *orgv1.CheCluster) corev1.Container { MountPath: "/etc/oauth-proxy", }, }, + Resources: corev1.ResourceRequirements{ + Limits: corev1.ResourceList{ + corev1.ResourceMemory: resource.MustParse("512Mi"), + corev1.ResourceCPU: resource.MustParse("0.5"), + }, + Requests: corev1.ResourceList{ + corev1.ResourceMemory: resource.MustParse("64Mi"), + corev1.ResourceCPU: resource.MustParse("0.1"), + }, + }, Ports: []corev1.ContainerPort{ {ContainerPort: GatewayServicePort, Protocol: "TCP"}, },