Skip to content

Commit

Permalink
Update documentation for devel
Browse files Browse the repository at this point in the history
Auto-generated from v0.1.0-38-g246e1f7 by 'update-gh-pages.sh'
  • Loading branch information
Github committed Sep 29, 2023
1 parent 611b59a commit 6785ffd
Show file tree
Hide file tree
Showing 29 changed files with 713 additions and 37 deletions.
2 changes: 1 addition & 1 deletion devel/.buildinfo
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Sphinx build info version 1
# This file hashes the configuration used when building these files. When it is not found, a full rebuild will be done.
config: 096e5cb6a6b51a425ab1cbc90a0b8e52
config: 075dee4d7e63f1e6bbb9b28fa166bb14
tags: 645f666f9bcd5a90fca523b33c5a78b7
1 change: 1 addition & 0 deletions devel/_sources/docs/index.md.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ caption: Contents
---
introduction.md
resource-policy/index.rst
memory/index.md
contributing.md
Project GitHub repository <https://github.com/containers/nri-plugins>
```
9 changes: 9 additions & 0 deletions devel/_sources/docs/memory/index.md.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Memory plugins

```{toctree}
---
maxdepth: 2
caption: Contents
---
memory-qos.md
```
155 changes: 155 additions & 0 deletions devel/_sources/docs/memory/memory-qos.md.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,155 @@
# Memory QoS NRI plugin

This NRI plugin adds two methods for controlling cgroups v2 `memory.*`
parameters: memory QoS classes and direct memory annotations.

## Workload configuration

There are two configuration methods:
1. Memory QoS classes: memory parameters are calculated in the same
way for all workloads that belong to the same class.
2. Direct workload-specific memory parameters.

Memory QoS class of a pod or a container is defined using annotations
in pod yaml:

```yaml
annotations:
# Set the default memory QoS class for all containers in this pod.
class.memory-qos.nri.io: silver

# Override the default class for the c0 container.
class.memory-qos.nri.io/c0: bronze

# Remove the default class from the c1 container.
class.memory-qos.nri.io/c1: ""
```

Cgroups v2 memory parameters are given pod annotations. Following
example affects `memory.swap.max`, `memory.high` and
`memory.oom.group`:

```yaml
annotations:
# Never swap memory of the noswap container in this pod.
memory.swap.max.memory-qos.nri.io/noswap: "0"
memory.high.memory-qos.nri.io/noswap: max

# For all containers: if a process gets OOM killed,
# do not group-kill the whole cgroup.
memory.oom.group.memory-qos.nri.io: "0"
```

## Plugin configuration

### Classes

Plugin configuration lists memory QoS classes and their parameters
that affect calculating actual memory parameters.

`classes:` is followed by list of maps with following keys and values:
- `name` (string): name of the memory QoS class, matches
`class.memory-qos.nri.io` annotation values.
- `swaplimitratio` (from 0.0 to 1.0): minimum ratio of container's
memory on swap and resources.limits.memory when container's memory
consumption reaches the limit. Adjusts `memory.high` watermark to
`resources.limits.memory * (1.0 - swaplimitratio)`.

### Unified annotations

`unifiedannotations:` (list of strings): OCI Linux unified fields
(cgroups v2 file names) whose values are allowed to be set using
direct annotations. If annotations define these values, they override
values implied by container's memory QoS class.

### Example

```yaml
classes:
- name: bronze
swaplimitratio: 0.5
- name: silver
swaplimitratio: 0.2
unifiedannotations:
- memory.swap.max
- memory.high
```

This configuration defines the following.

- If a container belogs to the memory QoS class `bronze` has allocated
half of the memory of its `resources.limits.memory`, next
allocations will cause kernel to swap out corresponding amount of
container's memory. In other words, when container's memory usage is
close to the limit, at most half of its data is stored in RAM.
- Containers in `silver` class are allowed to keep up to 80 % of their
data in RAM when reaching memory limit.
- Memory annotations are allowed to modify `memory.swap.max` and
`memory.high` values directly but, for instance, modifying
`memory.oom.group` is not enabled by this configuration.

## Developer's guide

### Prerequisites

- Containerd v1.7+
- Enable NRI in /etc/containerd/config.toml:
```
[plugins."io.containerd.nri.v1.nri"]
disable = false
disable_connections = false
plugin_config_path = "/etc/nri/conf.d"
plugin_path = "/opt/nri/plugins"
plugin_registration_timeout = "5s"
plugin_request_timeout = "2s"
socket_path = "/var/run/nri/nri.sock"
```

### Build

```bash
cd cmd/plugins/memory-qos && go build .
```

### Run

```bash
cmd/plugins/memory-qos/memory-qos -config sample-configs/nri-memory-qos.yaml -idx 40 -vv
```

### Manual test

```bash
kubectl create -f test/e2e/files/nri-memory-qos-test-pod.yaml
```

See swap status of dd processes, each allocating the same amount of
memory:

```bash
for pid in $(pidof dd); do
grep VmSwap /proc/$pid/status
done
```

### Debug

```bash
go install github.com/go-delve/delve/cmd/dlv@latest
dlv exec cmd/plugins/memory-qos/memory-qos -- -config sample-configs/nri-memory-qos.yaml -idx 40
(dlv) break plugin.CreateContainer
(dlv) continue
```

### Deploy

Build an image, import it on the node, and deploy the plugin by
running the following in `nri-plugins`:

```bash
rm -rf build
make clean
make PLUGINS=nri-memory-qos IMAGE_VERSION=devel images
ctr -n k8s.io images import build/images/nri-memory-qos-image-*.tar
kubectl create -f build/images/nri-memory-qos-deployment.yaml
```
2 changes: 1 addition & 1 deletion devel/_static/documentation_options.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
var DOCUMENTATION_OPTIONS = {
URL_ROOT: document.getElementById("documentation_options").getAttribute('data-url_root'),
VERSION: '0.1.0-37-g90dc2e5',
VERSION: '0.1.0-38-g246e1f7',
LANGUAGE: 'en',
COLLAPSE_INDEX: false,
BUILDER: 'html',
Expand Down
7 changes: 4 additions & 3 deletions devel/docs/contributing.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<meta charset="utf-8" /><meta name="generator" content="Docutils 0.18.1: http://docutils.sourceforge.net/" />

<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Contributing &mdash; NRI Plugins 0.1.0-37-g90dc2e5 documentation</title>
<title>Contributing &mdash; NRI Plugins 0.1.0-38-g246e1f7 documentation</title>
<link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
<link rel="stylesheet" href="../_static/css/theme.css" type="text/css" />
<!--[if lt IE 9]>
Expand All @@ -20,7 +20,7 @@
<script src="../_static/js/theme.js"></script>
<link rel="index" title="Index" href="../genindex.html" />
<link rel="search" title="Search" href="../search.html" />
<link rel="prev" title="CPU Allocator" href="resource-policy/developers-guide/cpu-allocator.html" />
<link rel="prev" title="Memory QoS NRI plugin" href="memory/memory-qos.html" />
</head>

<body class="wy-body-for-nav">
Expand Down Expand Up @@ -49,6 +49,7 @@
<ul class="current">
<li class="toctree-l1"><a class="reference internal" href="introduction.html">Introduction</a></li>
<li class="toctree-l1"><a class="reference internal" href="resource-policy/index.html">Resource Policy Plugins</a></li>
<li class="toctree-l1"><a class="reference internal" href="memory/index.html">Memory plugins</a></li>
<li class="toctree-l1 current"><a class="current reference internal" href="#">Contributing</a></li>
<li class="toctree-l1"><a class="reference external" href="https://github.com/containers/nri-plugins">Project GitHub repository</a></li>
</ul>
Expand Down Expand Up @@ -92,7 +93,7 @@ <h1>Contributing<a class="headerlink" href="#contributing" title="Permalink to t
</div>
</div>
<footer><div class="rst-footer-buttons" role="navigation" aria-label="Footer">
<a href="resource-policy/developers-guide/cpu-allocator.html" class="btn btn-neutral float-left" title="CPU Allocator" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left" aria-hidden="true"></span> Previous</a>
<a href="memory/memory-qos.html" class="btn btn-neutral float-left" title="Memory QoS NRI plugin" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left" aria-hidden="true"></span> Previous</a>
</div>

<hr/>
Expand Down
7 changes: 6 additions & 1 deletion devel/docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<meta charset="utf-8" /><meta name="generator" content="Docutils 0.18.1: http://docutils.sourceforge.net/" />

<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Welcome to NRI Plugins documentation &mdash; NRI Plugins 0.1.0-37-g90dc2e5 documentation</title>
<title>Welcome to NRI Plugins documentation &mdash; NRI Plugins 0.1.0-38-g246e1f7 documentation</title>
<link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
<link rel="stylesheet" href="../_static/css/theme.css" type="text/css" />
<!--[if lt IE 9]>
Expand Down Expand Up @@ -49,6 +49,7 @@
<ul>
<li class="toctree-l1"><a class="reference internal" href="introduction.html">Introduction</a></li>
<li class="toctree-l1"><a class="reference internal" href="resource-policy/index.html">Resource Policy Plugins</a></li>
<li class="toctree-l1"><a class="reference internal" href="memory/index.html">Memory plugins</a></li>
<li class="toctree-l1"><a class="reference internal" href="contributing.html">Contributing</a></li>
<li class="toctree-l1"><a class="reference external" href="https://github.com/containers/nri-plugins">Project GitHub repository</a></li>
</ul>
Expand Down Expand Up @@ -92,6 +93,10 @@ <h1>Welcome to NRI Plugins documentation<a class="headerlink" href="#welcome-to-
<li class="toctree-l2"><a class="reference internal" href="resource-policy/developers-guide/index.html">Developer’s Guide</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="memory/index.html">Memory plugins</a><ul>
<li class="toctree-l2"><a class="reference internal" href="memory/memory-qos.html">Memory QoS NRI plugin</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="contributing.html">Contributing</a></li>
<li class="toctree-l1"><a class="reference external" href="https://github.com/containers/nri-plugins">Project GitHub repository</a></li>
</ul>
Expand Down
3 changes: 2 additions & 1 deletion devel/docs/introduction.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<meta charset="utf-8" /><meta name="generator" content="Docutils 0.18.1: http://docutils.sourceforge.net/" />

<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Introduction &mdash; NRI Plugins 0.1.0-37-g90dc2e5 documentation</title>
<title>Introduction &mdash; NRI Plugins 0.1.0-38-g246e1f7 documentation</title>
<link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
<link rel="stylesheet" href="../_static/css/theme.css" type="text/css" />
<!--[if lt IE 9]>
Expand Down Expand Up @@ -50,6 +50,7 @@
<ul class="current">
<li class="toctree-l1 current"><a class="current reference internal" href="#">Introduction</a></li>
<li class="toctree-l1"><a class="reference internal" href="resource-policy/index.html">Resource Policy Plugins</a></li>
<li class="toctree-l1"><a class="reference internal" href="memory/index.html">Memory plugins</a></li>
<li class="toctree-l1"><a class="reference internal" href="contributing.html">Contributing</a></li>
<li class="toctree-l1"><a class="reference external" href="https://github.com/containers/nri-plugins">Project GitHub repository</a></li>
</ul>
Expand Down
Loading

0 comments on commit 6785ffd

Please sign in to comment.