Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[installer] Allow configuration of resource requests and limits #9545

Merged
merged 7 commits into from Apr 28, 2022

Conversation

andrew-farries
Copy link
Contributor

@andrew-farries andrew-farries commented Apr 26, 2022

Description

One of the Webapp team's epics for Q2 is to use the Gitpod installer to deploy to Gitpod SaaS. In order to do that we will need to add additional configuration to the installer to make the output suitable for a SaaS deployment as opposed to a self-hosted deployment.

This PR adds the ability to configure the resource requests and limits for all components via the experimental section in the installer config file.

Related Issue(s)

Part of #9097

How to test

Create an installer config file containing this experimental section:

experimental:
  common:
    podConfig:
      server:
        resources:
          server:
            requests:
              cpu: 50m
              memory: 100Mi
            limits:
              cpu: 500m
              memory: 800Mi
      dashboard:
        resources:
          dashboard:
            requests:
              cpu: 60m
              memory: 100Mi
            limits:
              cpu: 100m
              memory: 500Mi

Get a versions.yaml for use with the installer:

docker run -it --rm "eu.gcr.io/gitpod-core-dev/build/versions:${version}" cat versions.yaml > versions.yaml

Then invoke the installer as:

go run . render --debug-version-file versions.yaml --config /path/to/config --use-experimental-config

The rendered output will have the values from the config for the server and dashboard component resource requests and limits. All other components will use their default hard-coded resources as before.

Release Notes

Allow resource requests and limits for each component to be configurable through the installer

Documentation

None.

Andrew Farries added 4 commits April 26, 2022 09:32
To allow each component (server, dashboard etc) to specify resource
requirements via the `experimental` config section.
Take a default set of ResourceRequirements and override them if any
resource config for the given component is present in the `experimental`
section.
Use the common.ResourceRequirements function from the parent commits,
passing in the existing defaults.
@andrew-farries andrew-farries requested review from a team April 26, 2022 10:00
@github-actions github-actions bot added team: IDE team: delivery Issue belongs to the self-hosted team team: webapp Issue belongs to the WebApp team team: workspace Issue belongs to the Workspace team labels Apr 26, 2022
@andrew-farries
Copy link
Contributor Author

I'm not sure whether it's worth making the kube-rbac-proxy component that's used in multiple pods also configurable:

Resources: corev1.ResourceRequirements{Requests: corev1.ResourceList{
corev1.ResourceCPU: resource.MustParse("1m"),
corev1.ResourceMemory: resource.MustParse("30Mi"),
}},

@geropl
Copy link
Member

geropl commented Apr 26, 2022

I'm not sure whether it's worth making the kube-rbac-proxy component that's used in multiple pods also configurable:

@andrew-farries ah, good find! No, let's keep that as is for now. 👍

@@ -79,6 +81,108 @@ func TestReplicas(t *testing.T) {
}
}

func TestResourceRequirements(t *testing.T) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❤️

Copy link
Member

@geropl geropl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, and tests run! 👍

@andrew-farries
Copy link
Contributor Author

andrew-farries commented Apr 26, 2022

/werft run

👍 started the job as gitpod-build-af-installer-specify-resourcerequirements.4
(with .werft/ from main)

@mustard-mh
Copy link
Contributor

mustard-mh commented Apr 27, 2022

incorrectServerResources := corev1.ResourceRequirements{
	Requests: corev1.ResourceList{
		"cpu":    resource.MustParse("0"),
		"memory": resource.MustParse("0"),
	},
	Limits: corev1.ResourceList{
		"cpu":    resource.MustParse("-500m"),
		"memory": resource.MustParse("800Mi"),
	},
}

after common.ResourceRequirements func, output goes

{
        "limits": {
                "cpu": "-500m",
                "memory": "800Mi"
        },
        "requests": {
                "cpu": "0",
                "memory": "0"
        }
}

Should we validate it and panic first? or let it failed after apply to k8s

@mustard-mh mustard-mh self-requested a review April 27, 2022 10:18
@geropl
Copy link
Member

geropl commented Apr 27, 2022

Should we validate it and panic first? or let it failed after apply to k8s

@mustard-mh IMO that's a kubernetes thing, as we're re-using their data structures. 👍

@geropl geropl self-assigned this Apr 27, 2022
Setting to true will add pod (anti)-affinity fields to the server
and proxy components.
@roboquat roboquat merged commit 1e29361 into main Apr 28, 2022
@roboquat roboquat deleted the af/installer-specify-resourcerequirements branch April 28, 2022 14:34
@roboquat roboquat added the deployed: webapp Meta team change is running in production label May 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
deployed: webapp Meta team change is running in production release-note size/L team: delivery Issue belongs to the self-hosted team team: IDE team: webapp Issue belongs to the WebApp team team: workspace Issue belongs to the Workspace team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants