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

feat(chart): Set GOMAXPROCS and GOMEMLIMIT environment variables #8989

Merged
merged 1 commit into from May 22, 2024

Conversation

jnoordsij
Copy link
Contributor

@jnoordsij jnoordsij commented Apr 30, 2024

Set GOMAXPROCS and GOMEMLIMIT environment variables based on container resources.

The resourceFieldRef is a very specific Kubernetes directive that is created specifically for passing resource-related values, which rounds up the CPU value to the nearest whole number (e.g. 250m to 1) and passes the memory as a numeric value; so 64Mi would result in the environment variable being set to 67108864. This by design makes it completely compatible with Go's API.

An example is documented within Kubernetes documentation itself: https://kubernetes.io/docs/tasks/inject-data-application/environment-variable-expose-pod-information/#use-container-fields-as-values-for-environment-variables.

Inspired by traefik/traefik-helm-chart#1029, this should reduce potential CPU throttling and OOMKills on containers.

This also replaces a reference to .Values.web.containers.env in the metrics-scraper deployment, which I assumed to be an unintented faulty value.

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Apr 30, 2024
@k8s-ci-robot k8s-ci-robot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Apr 30, 2024
@floreks floreks changed the title [helm] Set GOMAXPROCS and GOMEMLIMIT environment variables feat(helm): Set GOMAXPROCS and GOMEMLIMIT environment variables May 22, 2024
@floreks floreks changed the title feat(helm): Set GOMAXPROCS and GOMEMLIMIT environment variables feat(chart): Set GOMAXPROCS and GOMEMLIMIT environment variables May 22, 2024
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: floreks, jnoordsij

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label May 22, 2024
@floreks floreks added the kind/feature Categorizes issue or PR as related to a new feature. label May 22, 2024
@floreks floreks self-assigned this May 22, 2024
Copy link

codecov bot commented May 22, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 37.19%. Comparing base (a49364c) to head (a908b50).
Report is 40 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #8989      +/-   ##
==========================================
- Coverage   37.20%   37.19%   -0.01%     
==========================================
  Files         255      255              
  Lines       11156    11156              
  Branches      157      158       +1     
==========================================
- Hits         4151     4150       -1     
- Misses       6755     6756       +1     
  Partials      250      250              

@floreks floreks merged commit 0b35416 into kubernetes:master May 22, 2024
17 of 22 checks passed
@jnoordsij jnoordsij deleted the set-gomemlimit-gomaxprocs branch May 22, 2024 16:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/feature Categorizes issue or PR as related to a new feature. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants