Skip to content
This repository was archived by the owner on Aug 7, 2025. It is now read-only.

Commit afa35be

Browse files
author
Obed N Munoz
committed
Add support for cri-resource-manager project
This commit adds support for installing and configuring the [cri-resource-manager](https://github.com/intel/cri-resource-manager) project as an systemd-based service. It also adds the automation to configure `kubelet` service to consume it as a remote container runtime. Finally, it's providing the automation for cleaning up the `kubelet` service configuration to its original state without `cri-resource-manager`. Binary installation will be temporally consumed from a personal fork that is currently hosting `cri-resource-manager` binaries in the meantime that `cri-resource-manager` generates its packaging strategy. Signed-off-by: Obed N Munoz <[email protected]>
1 parent e985ffd commit afa35be

File tree

5 files changed

+161
-0
lines changed

5 files changed

+161
-0
lines changed
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
# CRI Resource Manager
2+
CRI Resource Manager serves as a relay/proxy between kubelet and the container runtime, relaying requests and responses back and forth between these two, potentially altering requests as they fly by.
3+
4+
This document explains a very simple use case for the `cri-resource-manager`, for more details and tweaks
5+
on CRI Resource Manager service, you can go to https://github.com/intel/cri-resource-manager.
6+
7+
## Install
8+
9+
[`install.sh`](install.sh) script will download the binary and install it as an `systemd` service unit. This script will be executed in all nodes where `cri-resmgr` is required.
10+
11+
Below you can see the available variables you can use to customize the usage of your CRI Resource Manager service.
12+
13+
| Variable | Description | Default Value |
14+
|-----------------------------|-------------------------------------------|--------------------------------------------------|
15+
| `RUNNER` | Default Container Runtime | `containerd` |
16+
| `CRI_RESMGR_POLICY` | CRI Resource Manager Policy type | `null` |
17+
| `CRI_RESMGR_POLICY_OPTIONS` | CRI Resource Manager extra policy options | `-dump='reset,full:.*' -dump-file=/tmp/cri.dump` |
18+
| `CRI_RESMGR_DEBUG_OPTIONS` | CRI Resource Manager debugging options | `<none>` |
19+
20+
**Example:**
21+
```bash
22+
$ RUNNER=containerd ./install.sh
23+
```
24+
25+
Verify that the cri-resource-manager service is actually running.
26+
27+
```bash
28+
$ systemctl status cri-resource-manager
29+
```
30+
31+
Verify that the `cri-resmgr` socket is created, it will indicate that `cri-resource-manager` is ready to receive requests.
32+
```bash
33+
$ sudo ls -la /var/run/cri-resmgr/cri-resmgr.sock
34+
```
35+
36+
## Setup as a container runtime in `kubelet`
37+
38+
The [`setup.sh`](setup.sh) script will configure the `kubelet` service to use the `cri-resource-manager` relay as its remote container runtime. This script will be executed in all nodes where `cri-resmgr` is being configured.
39+
40+
**Example:**
41+
```bash
42+
$ ./setup.sh
43+
```
44+
45+
Kubelet service should be restarted and now using `cri-resource-manager` as its container runtime
46+
47+
```bash
48+
$ ps aux | grep kubelet | grep container-runtime
49+
root 28703 1.7 2.0 1246348 83088 ? Ssl 20:03 0:06 /usr/bin/kubelet --bootstrap-kubeconfig=/etc/kubernetes/bootstrap-kubelet.conf --kubeconfig=/etc/kubernetes/kubelet.conf --config=/var/lib/kubelet/config.yaml --container-runtime remote --container-runtime-endpoint unix:///var/run/cri-resmgr/cri-resmgr.sock
50+
```
51+
52+
`cri-resource-manager` service's logs will be located at `/tmp/cri.dump`
53+
54+
```bash
55+
$ tail /tmp/cri.dump
56+
```
57+
58+
## Cleanup
59+
60+
The [`clean.sh`](clean.sh) will first clean the `kubelet` service as it was before the `cri-resource-manager` and restarts `kubelet` service. This script will be executed in all nodes where `cri-resmgr` is being uninstalled.
61+
Then. it will proceed to stop the `cri-resource-manager` service.
62+
63+
**Example:**
64+
```bash
65+
$ ./clean.sh
66+
```
67+
68+
## More kubernetes native approach (experimental)
69+
70+
In case that you're interested in a more Kubernetes native way of deploying the CRI Resource manager, take a look on: https://github.com/intel/cri-resource-manager/pull/55
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#!/bin/bash
2+
# Copyright (c) 2019 Intel Corporation
3+
#
4+
# SPDX-License-Identifier: Apache-2.0
5+
#
6+
# Uninstall and stop the CRI Resource Manager service
7+
8+
set -o errexit
9+
set -o nounset
10+
11+
# Kubelet
12+
KUBEADM_FLAGS="/var/lib/kubelet/kubeadm-flags.env"
13+
sudo rm -f /etc/systemd/system/kubelet.service.d/99-cri-resource-manager.conf
14+
sudo systemctl daemon-reload
15+
sudo systemctl restart kubelet
16+
17+
if sudo test -f "$KUBEADM_FLAGS.bkp" ; then
18+
sudo mv $KUBEADM_FLAGS.bkp $KUBEADM_FLAGS
19+
fi
20+
21+
# CRI Resource Manager
22+
sudo systemctl stop cri-resource-manager
23+
sudo systemctl disable cri-resource-manager
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#!/bin/bash
2+
# Copyright (c) 2019 Intel Corporation
3+
#
4+
# SPDX-License-Identifier: Apache-2.0
5+
#
6+
# Install and start the CRI Resource Manager service
7+
8+
set -o errexit
9+
set -o nounset
10+
11+
RUNNER=${RUNNER:-"containerd"}
12+
CRI_RESMGR_POLICY=${CRI_RESMGR_POLICY:-"null"}
13+
CRI_RESMGR_POLICY_OPTIONS=${CRI_RESMGR_POLICY_OPTIONS:-"-dump='reset,full:.*' -dump-file=/tmp/cri.dump"}
14+
CRI_RESMGR_DEBUG_OPTIONS=${CRI_RESMGR_DEBUG_OPTIONS:-""}
15+
16+
curl https://raw.githubusercontent.com/obedmr/cri-resource-manager/master/godownloader.sh | bash
17+
sudo cp ./bin/* /usr/bin/
18+
19+
runtime_socket=$(sudo find /run/ -iname $RUNNER.sock | head -1)
20+
CRI_RESMGR_POLICY_OPTIONS+=" -runtime-socket=$runtime_socket -image-socket=$runtime_socket"
21+
22+
sudo mkdir -p /etc/sysconfig/
23+
cat <<EOF | sudo tee /etc/sysconfig/cri-resource-manager
24+
POLICY=$CRI_RESMGR_POLICY
25+
POLICY_OPTIONS=$CRI_RESMGR_POLICY_OPTIONS
26+
DEBUG_OPTIONS=$CRI_RESMGR_DEBUG_OPTIONS
27+
EOF
28+
29+
sudo mkdir -p /etc/systemd/system/
30+
curl https://raw.githubusercontent.com/obedmr/cri-resource-manager/master/cmd/cri-resmgr/cri-resource-manager.service | sudo tee /etc/systemd/system/cri-resource-manager.service
31+
32+
sudo sed -i '/Requires=/d' /etc/systemd/system/cri-resource-manager.service
33+
sudo systemctl daemon-reload
34+
sudo systemctl restart cri-resource-manager.service
35+
sudo systemctl enable cri-resource-manager.service
36+
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#!/bin/bash
2+
# Copyright (c) 2019 Intel Corporation
3+
#
4+
# SPDX-License-Identifier: Apache-2.0
5+
#
6+
# Configure CRI Resource Manager as container runtime endpoint for kubelet
7+
8+
set -o errexit
9+
set -o nounset
10+
11+
CRI_RESMGR_SOCKET="/var/run/cri-resmgr/cri-resmgr.sock"
12+
KUBEADM_FLAGS="/var/lib/kubelet/kubeadm-flags.env"
13+
14+
if sudo test -S "$CRI_RESMGR_SOCKET" ; then
15+
sudo mkdir -p /etc/systemd/system/kubelet.service.d/
16+
cat <<EOF | sudo tee /etc/systemd/system/kubelet.service.d/99-cri-resource-manager.conf
17+
[Service]
18+
Environment=KUBELET_EXTRA_ARGS=
19+
Environment=KUBELET_EXTRA_ARGS="--container-runtime remote --container-runtime-endpoint unix://${CRI_RESMGR_SOCKET}"
20+
EOF
21+
22+
if sudo test -f "$KUBEADM_FLAGS" ; then
23+
sudo mv $KUBEADM_FLAGS $KUBEADM_FLAGS.bkp
24+
fi
25+
26+
sudo systemctl daemon-reload
27+
sudo systemctl restart cri-resource-manager
28+
sudo systemctl restart kubelet
29+
fi

clr-k8s-examples/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,9 @@ kubectl -n monitoring port-forward svc/grafana 3000
156156
Grafana is available at this URL http://localhost:3000 . Default credentials are
157157
`admin/admin`. Upon entering you will be asked to chose a new password.
158158

159+
### CRI Resource Manager
160+
Go to [`10-cri-resource-manager`](./10-cri-resource-manager).
161+
159162
## Cleaning up the cluster (Hard reset to a clean state)
160163

161164
Run `reset_stack.sh` on all the nodes

0 commit comments

Comments
 (0)