-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Patch containerd to enable NRI before deploying NRI plugin
This commit adds an init container to enable NRI in containerd configuration file. Users installing plugin via Helm have an option to opt in for using that init container to enable the NRI before running plugin. By default, this option is disabled. Signed-off-by: Feruzjon Muyassarov <[email protected]>
- Loading branch information
1 parent
66846cb
commit e42f239
Showing
7 changed files
with
127 additions
and
0 deletions.
There are no files selected for viewing
36 changes: 36 additions & 0 deletions
36
deployment/helm/resource-management-policies/balloons/templates/configmap_enable_nri.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
{{- if .Values.nri.enable }} | ||
apiVersion: v1 | ||
kind: ConfigMap | ||
metadata: | ||
name: patch-containerd-config | ||
namespace: {{ .Release.Namespace }} | ||
labels: | ||
{{- include "balloons-plugin.labels" . | nindent 4 }} | ||
data: | ||
patch_nri.sh: | | ||
#!/bin/bash | ||
config_file="/home/config.toml" | ||
plugin="[plugins.\"io.containerd.nri.v1.nri\"]" | ||
switch="disable = false" | ||
cp /etc/containerd/config.toml "$config_file" | ||
# Check if the nri entry exists in the config file | ||
if grep -q "$plugin" "$config_file"; then | ||
# Check if the nri is already enabled | ||
if grep -q "disable = false" "$config_file"; then | ||
echo "NRI is already enabled..." | ||
else | ||
# Enable the NRI plugin | ||
sed -i "s/disable = true/$switch/" "$config_file" | ||
cp -f "$config_file" /etc/containerd/config.toml | ||
echo "Restarting containerd...." | ||
nsenter -t 1 -m bash | ||
systemctl restart containerd | ||
echo "NRI has been enabled..." | ||
fi | ||
else | ||
echo "NRI entry doesn't exist in the config file." | ||
fi | ||
{{- end }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,3 +17,6 @@ hostPort: 8891 | |
resources: | ||
cpu: 500m | ||
memory: 512Mi | ||
|
||
nri: | ||
enable: false |
36 changes: 36 additions & 0 deletions
36
...ment/helm/resource-management-policies/topology-aware/templates/configmap_emable_nri.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
{{- if .Values.nri.enable }} | ||
apiVersion: v1 | ||
kind: ConfigMap | ||
metadata: | ||
name: patch-containerd-config | ||
namespace: {{ .Release.Namespace }} | ||
labels: | ||
{{- include "topology-aware-plugin.labels" . | nindent 4 }} | ||
data: | ||
patch_nri.sh: | | ||
#!/bin/bash | ||
config_file="/home/config.toml" | ||
plugin="[plugins.\"io.containerd.nri.v1.nri\"]" | ||
switch="disable = false" | ||
cp /etc/containerd/config.toml "$config_file" | ||
# Check if the nri entry exists in the config file | ||
if grep -q "$plugin" "$config_file"; then | ||
# Check if the nri is already enabled | ||
if grep -q "disable = false" "$config_file"; then | ||
echo "NRI is already enabled..." | ||
else | ||
# Enable the NRI plugin | ||
sed -i "s/disable = true/$switch/" "$config_file" | ||
cp -f "$config_file" /etc/containerd/config.toml | ||
echo "Restarting containerd...." | ||
nsenter -t 1 -m bash | ||
systemctl restart containerd | ||
echo "NRI has been enabled..." | ||
fi | ||
else | ||
echo "NRI entry doesn't exist in the config file." | ||
fi | ||
{{- end }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,3 +17,6 @@ hostPort: 8891 | |
resources: | ||
cpu: 500m | ||
memory: 512Mi | ||
|
||
nri: | ||
enable: false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters