Skip to content

Commit

Permalink
revise based on comments
Browse files Browse the repository at this point in the history
  • Loading branch information
caozhuozi committed Feb 19, 2024
1 parent 0f55e6e commit c12ffb6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
6 changes: 3 additions & 3 deletions site/content/en/docs/user/metrics-configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ extension functions you can use in a CEL expression to help calculate the simula
* `Usage()` returns the current instantaneous resource usage with the simulation data in [ResourceUsage (ClusterResourceUsage)].
For example: `Usage(pod, "memory")`, `Usage(node, "memory")`, `Usage(pod, "memory", container.name)` return the
current working set of a resource (pod, node or container) in bytes.
* `CumulativeUsage()` return the cumulative resource usage in seconds with the simulation data given in [ResourceUsage (ClusterResourceUsage)].
* `CumulativeUsage()` returns the cumulative resource usage in seconds with the simulation data given in [ResourceUsage (ClusterResourceUsage)].
For example: `CumulativeUsage(pod, "cpu")`, `CumulativeUsage(node, "cpu")`, `CumulativeUsage(pod, "cpu", container.name)`
return a cumulative cpu time consumed by a resource (pod, node or container) in core-seconds.

Expand Down Expand Up @@ -131,10 +131,10 @@ Therefore, please ensure that the associated ResourceUsage or ClusterResourceUsa

## Out-of-box Metric Config

`kwok` currently provides the [Metrics config][metrics resource endpoint]that is capable of
`kwok` currently provides the [Metrics config][metrics resource endpoint] that is capable of
simulating kubelet's `"metrics/resource"` endpoint.

To integrate the simulated endpoint with metrics-server (version is required >= 0.7.0), please add the
To integrate the simulated endpoint with metrics-server (required version >= 0.7.0), add the
`"metrics.k8s.io/resource-metrics-path": "/metrics/nodes/<nodeName>/metrics/resource"` annotation to the fake
nodes managed by `kwok`.

Expand Down
5 changes: 3 additions & 2 deletions site/content/en/docs/user/resource-usage-configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ If `containers` is not given in a group, the `usage` in that group will be appli
You can simply set a static [Quantity value] (`100Mi`, `1000m`, etc.) via `cpu.value` and `memory.value` to define the cpu and memory resource usage respectively.
Besides, users are also allowed to provide a [CEL expression] via `expressions` to describe the resource usage more flexibly. For example,
the following expression tries to extract the cpu resource usage from the pod's annotation if it has or use a default value.

```yaml
expression: |
"kwok.x-k8s.io/usage-cpu" in pod.metadata.annotations
Expand All @@ -65,7 +66,7 @@ yields memory usage that grows linearly with time.
```yaml
expression: (pod.SinceSecond() / 60.0) * Quantity("1Mi")
```
Please refer to [built-in CEL extension functions] for an exhausted list that may helpful to config dynamic resource usages.
Please refer to [built-in CEL extension functions] for an exhausted list that may be helpful to configure dynamic resource usage.


### ClusterResourceUsage
Expand Down Expand Up @@ -112,7 +113,7 @@ Please refer to [pod resource usage from annotation] for a concrete example.

The resource usages defined in ResourceUsage and ClusterResourceUsage resources can be fetched from the metric service of `kwok` at port `10247` with path `/metrics/nodes/{nodeName}/metrics/resource`,
where `{nodeName}` is the name of the fake node that the pod is scheduled to.
The returned metrics look the same as the response of kubelet's `/metrics/resource` endpoint.
The returned metrics are similar to the response from kubelet's `/metrics/resource` endpoint.

Please refer to [`kwok` Metric][Metric] about how to integrate `kwok` simulated metrics endpoints with metrics-server.

Expand Down

0 comments on commit c12ffb6

Please sign in to comment.