-
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 a380696
Showing
7 changed files
with
117 additions
and
0 deletions.
There are no files selected for viewing
31 changes: 31 additions & 0 deletions
31
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,31 @@ | ||
{{- 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" | ||
cp /etc/containerd/config.toml "$config_file" | ||
# Check if the disable field is set to false under [plugins."io.containerd.nri.v1.nri"] | ||
status=$(awk -F ' = ' '/^\[plugins\."io\.containerd\.nri\.v1\.nri"\]/{flag=1} flag && /disable/{print $2; exit}' "$config_file") | ||
if [ "$status" = "false" ]; then | ||
echo "NRI is already enabled..." | ||
elif [ "$status" = "true" ]; then | ||
# Enable the NRI plugin in containerd | ||
sed '/\[plugins.\"io.containerd.nri.v1.nri/,/^$/s/disable = true/disable = false/' -i "$config_file" | ||
cp -f "$config_file" /etc/containerd/config.toml | ||
echo "Restarting containerd...." | ||
nsenter -t 1 -m systemctl restart containerd | ||
echo "NRI has now been enabled..." | ||
else | ||
echo "NRI plugin entry doesn't exist in the continerd config file." | ||
echo "Doing nothing..." | ||
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 |
31 changes: 31 additions & 0 deletions
31
...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,31 @@ | ||
{{- 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" | ||
cp /etc/containerd/config.toml "$config_file" | ||
# Check if the disable field is set to false under [plugins."io.containerd.nri.v1.nri"] | ||
status=$(awk -F ' = ' '/^\[plugins\."io\.containerd\.nri\.v1\.nri"\]/{flag=1} flag && /disable/{print $2; exit}' "$config_file") | ||
if [ "$status" = "false" ]; then | ||
echo "NRI is already enabled..." | ||
elif [ "$status" = "true" ]; then | ||
# Enable the NRI plugin in containerd | ||
sed '/\[plugins.\"io.containerd.nri.v1.nri/,/^$/s/disable = true/disable = false/' -i "$config_file" | ||
cp -f "$config_file" /etc/containerd/config.toml | ||
echo "Restarting containerd...." | ||
nsenter -t 1 -m systemctl restart containerd | ||
echo "NRI has now been enabled..." | ||
else | ||
echo "NRI plugin entry doesn't exist in the continerd config file." | ||
echo "Doing nothing..." | ||
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