The following patch add automatically the environment variable `GOMAXPROCS`, when a CPU limit is defined. Otherwise CPU throttling may occur. Reviewed-on: https://gitea.com/gitea/helm-chart/pulls/772 Reviewed-by: techknowlogick <techknowlogick@noreply.gitea.com> Reviewed-by: justusbunsi <justusbunsi@noreply.gitea.com> Co-authored-by: Markus Pesch <markus.pesch@cryptic.systems> Co-committed-by: Markus Pesch <markus.pesch@cryptic.systems>
This commit is contained in:
parent
cc7532ec90
commit
4f42f4bee3
37
README.md
37
README.md
@ -8,6 +8,7 @@
|
|||||||
- [Dependency Versioning](#dependency-versioning)
|
- [Dependency Versioning](#dependency-versioning)
|
||||||
- [Installing](#installing)
|
- [Installing](#installing)
|
||||||
- [High Availability](#high-availability)
|
- [High Availability](#high-availability)
|
||||||
|
- [Limit resources](#limit-resources)
|
||||||
- [Configuration](#configuration)
|
- [Configuration](#configuration)
|
||||||
- [Default Configuration](#default-configuration)
|
- [Default Configuration](#default-configuration)
|
||||||
- [Database defaults](#database-defaults)
|
- [Database defaults](#database-defaults)
|
||||||
@ -149,6 +150,42 @@ Care must be taken for production use as not all implementation details of Gitea
|
|||||||
Deploying a HA-ready Gitea instance requires some effort including using HA-ready dependencies.
|
Deploying a HA-ready Gitea instance requires some effort including using HA-ready dependencies.
|
||||||
See the [HA Setup](docs/ha-setup.md) document for more details.
|
See the [HA Setup](docs/ha-setup.md) document for more details.
|
||||||
|
|
||||||
|
## Limit resources
|
||||||
|
|
||||||
|
If the application is deployed with a CPU resource limit, Prometheus may throw a CPU throttling warning for the
|
||||||
|
application. This has more or less to do with the fact that the application finds the number of CPUs of the host, but
|
||||||
|
cannot use the available CPU time to perform computing operations.
|
||||||
|
|
||||||
|
The application must be informed that despite several CPUs only a part (limit) of the available computing time is
|
||||||
|
available. As this is a Golang application, this can be implemented using `GOMAXPROCS`. The following example is one way
|
||||||
|
of defining `GOMAXPROCS` automatically based on the defined CPU limit like `100m`. Please keep in mind, that the CFS
|
||||||
|
rate of `100ms` - default on each kubernetes node, is also very important to avoid CPU throttling.
|
||||||
|
|
||||||
|
Further information about this topic can be found [here](https://kanishk.io/posts/cpu-throttling-in-containerized-go-apps/).
|
||||||
|
|
||||||
|
> [!NOTE]
|
||||||
|
> The environment variable `GOMAXPROCS` is set automatically, when a CPU limit is defined. An explicit configuration is
|
||||||
|
> not anymore required.
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
deployment:
|
||||||
|
env:
|
||||||
|
# Will be automatically defined!
|
||||||
|
- name: GOMAXPROCS
|
||||||
|
valueFrom:
|
||||||
|
resourceFieldRef:
|
||||||
|
divisor: "1" # Is required for GitDevOps systems like ArgoCD/Flux. Otherwise throw the system a diff error. (k8s-default=1)
|
||||||
|
resource: limits.cpu
|
||||||
|
|
||||||
|
resources:
|
||||||
|
limits:
|
||||||
|
cpu: 100m
|
||||||
|
memory: 512Mi
|
||||||
|
requests:
|
||||||
|
cpu: 100m
|
||||||
|
memory: 512Mi
|
||||||
|
```
|
||||||
|
|
||||||
## Configuration
|
## Configuration
|
||||||
|
|
||||||
Gitea offers lots of configuration options.
|
Gitea offers lots of configuration options.
|
||||||
|
@ -291,6 +291,13 @@ spec:
|
|||||||
value: /data
|
value: /data
|
||||||
- name: GITEA_TEMP
|
- name: GITEA_TEMP
|
||||||
value: /tmp/gitea
|
value: /tmp/gitea
|
||||||
|
{{- if and (hasKey .Values.resources "limits") (hasKey .Values.resources.limits "cpu") }}
|
||||||
|
- name: GOMAXPROCS
|
||||||
|
valueFrom:
|
||||||
|
resourceFieldRef:
|
||||||
|
divisor: "1"
|
||||||
|
resource: limits.cpu
|
||||||
|
{{- end }}
|
||||||
- name: TMPDIR
|
- name: TMPDIR
|
||||||
value: /tmp/gitea
|
value: /tmp/gitea
|
||||||
{{- if .Values.image.rootless }}
|
{{- if .Values.image.rootless }}
|
||||||
|
@ -45,3 +45,31 @@ tests:
|
|||||||
content:
|
content:
|
||||||
name: ENV_TO_INI_MOUNT_POINT
|
name: ENV_TO_INI_MOUNT_POINT
|
||||||
value: /env-to-ini-mounts
|
value: /env-to-ini-mounts
|
||||||
|
- it: CPU resources are defined as well as GOMAXPROCS
|
||||||
|
template: templates/gitea/deployment.yaml
|
||||||
|
set:
|
||||||
|
resources:
|
||||||
|
limits:
|
||||||
|
cpu: 200ms
|
||||||
|
memory: 200Mi
|
||||||
|
requests:
|
||||||
|
cpu: 100ms
|
||||||
|
memory: 100Mi
|
||||||
|
asserts:
|
||||||
|
- contains:
|
||||||
|
path: spec.template.spec.containers[0].env
|
||||||
|
content:
|
||||||
|
name: GOMAXPROCS
|
||||||
|
valueFrom:
|
||||||
|
resourceFieldRef:
|
||||||
|
divisor: "1"
|
||||||
|
resource: limits.cpu
|
||||||
|
- equal:
|
||||||
|
path: spec.template.spec.containers[0].resources
|
||||||
|
value:
|
||||||
|
limits:
|
||||||
|
cpu: 200ms
|
||||||
|
memory: 200Mi
|
||||||
|
requests:
|
||||||
|
cpu: 100ms
|
||||||
|
memory: 100Mi
|
||||||
|
Loading…
x
Reference in New Issue
Block a user