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

[FEATURE] Add ability to configure resource requests and limits for the runner container #1491

Open
ahmadbabaeimoghadam opened this issue Dec 12, 2024 · 3 comments

Comments

@ahmadbabaeimoghadam
Copy link

Description

Currently, the runner container in tofu-controller does not support the configuration of resource requests and limits (CPU and memory). This feature is critical for environments where resource allocation needs to be tightly managed.

Proposal

Introduce a mechanism to allow users to set CPU and memory resource requests and limits for the runner container via configuration.

Suggested Implementation

  1. Extend the controller’s configuration schema to include resource parameters (e.g., resources.requests and resources.limits).
  2. Update the runner container’s pod spec to apply the specified resource values during pod creation.
  3. Provide clear documentation and examples to guide users on how to set these values.

Example Configuration

runnerPodTemplate:
  spec:
    resources:
      requests:
        cpu: "500m"
        memory: "256Mi"
      limits:
        cpu: "1"
        memory: "512Mi"

Use Cases

  1. Users can ensure the runner container has sufficient resources to operate efficiently.
  2. Prevent resource overuse by setting upper limits, enhancing cluster stability.

Additional Notes

  • Please ensure that existing setups without this configuration remain unaffected (backward compatibility).
  • This feature should be optional and only apply when users define the resource parameters.
@akselleirv
Copy link
Collaborator

Hello @ahmadbabaeimoghadam,

Configuring resources like you have done in your example configuration is possible in the Terraform spec.

Example:

apiVersion: infra.contrib.fluxcd.io/v1alpha2
kind: Terraform
metadata:
  name: sample
spec:
  ...
  runnerPodTemplate:
    spec:
      resources:
        limits:
          cpu: "1"
          memory: 1Gi
        requests:
          cpu: 250m
          memory: 512Mi

@ahmadbabaeimoghadam
Copy link
Author

Hello @ahmadbabaeimoghadam,

Configuring resources like you have done in your example configuration is possible in the Terraform spec.

It is introduced in release v0.16.0-rc.1?

We are using v0.15.1 and it does not support this feature. Is there any ETA for a new stable release? like v0.16.0?

@ahmadbabaeimoghadam
Copy link
Author

ahmadbabaeimoghadam commented Dec 19, 2024

Hi @akselleirv, while the controller code has been updated to allow setting resources (see: tf_controller_runner.go#L261), this functionality still doesn’t work. The issue lies in the CRD not being updated accordingly. As a result, the controller throws the following error when attempting to apply a Terraform resource with resources configured:

error validating data: ValidationError(Terraform.spec.runnerPodTemplate.spec): unknown field "resources" in io.fluxcd.contrib.infra.v1alpha2.Terraform.spec.runnerPodTemplate.spec

I deployed tf-controller v0.16.0-rc.2 using helm chart.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants