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

Commit a466723

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 f2e8941 commit a466723

File tree

5 files changed

+134
-0
lines changed

5 files changed

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

clr-k8s-examples/README.md

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

149+
### CRI Resource Manager
150+
Go to [`10-cri-resource-manager`](./10-cri-resource-manager).
151+
149152
## Cleaning up the cluster (Hard reset to a clean state)
150153

151154
Run `reset_stack.sh` on all the nodes

0 commit comments

Comments
 (0)