-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: dongjiang1989 <[email protected]>
- Loading branch information
1 parent
6be7b9f
commit 114be03
Showing
6 changed files
with
81 additions
and
2 deletions.
There are no files selected for viewing
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
32 changes: 32 additions & 0 deletions
32
charts/kubeservice-lxcfs-webhook/script/container_remount_lxcfs_containerd.sh
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,32 @@ | ||
#!/bin/bash +x | ||
|
||
LXCFS="/var/lib/lxc/lxcfs" | ||
|
||
containers=$(crictl ps | grep -v pause | grep -v calico | grep -v cilium |awk '{print $1}' | grep -v CONTAINER) | ||
for container in $containers; do | ||
# 获取挂载点信息 | ||
mounts=$(crictl inspect $container | jq -r '.info.config.mounts[] | "\(.container_path) -> \(.host_path)"' | grep "$LXCFS/") | ||
|
||
echo "Mounts for container $container:" | ||
echo "$mounts" | ||
|
||
# 检查是否有挂载到 LXCFS 路径 | ||
echo "$mounts" | grep "$LXCFS/" | ||
if [ $? -eq 0 ]; then | ||
echo "remount $container" | ||
PID=$(crictl inspect $container | jq -r '.info.pid') | ||
# mount /proc | ||
for file in meminfo cpuinfo loadavg stat diskstats swaps uptime; do | ||
echo nsenter --target $PID --mount -- /bin/mount -B -t proc "$LXCFS/proc/$file" "/proc/$file" | ||
nsenter --target $PID --mount -- /bin/mount -B "$LXCFS/proc/$file" "/proc/$file" | ||
done | ||
|
||
# mount /sys | ||
for file in online; do | ||
echo nsenter --target $PID --mount -- /bin/mount -B "$LXCFS/sys/devices/system/cpu/$file" "/sys/devices/system/cpu/$file" | ||
nsenter --target $PID --mount -- /bin/mount -B "$LXCFS/sys/devices/system/cpu/$file" "/sys/devices/system/cpu/$file" | ||
done | ||
else | ||
echo "容器 $container 没有挂载 /var/lib/lxc/lxcfs" | ||
fi | ||
done |
26 changes: 26 additions & 0 deletions
26
charts/kubeservice-lxcfs-webhook/script/container_remount_lxcfs_docker.sh
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,26 @@ | ||
#! /bin/bash +x | ||
|
||
PATH=$PATH:/bin | ||
LXCFS="/var/lib/lxc/lxcfs" | ||
LXCFS_ROOT_PATH="/var/lib/lxc" | ||
|
||
containers=$(docker ps | grep -v pause | grep -v calico | grep -v cilium | awk '{print $1}' | grep -v CONTAINE) | ||
|
||
for container in $containers;do | ||
mountpoint=$(docker inspect --format '{{ range .Mounts }}{{ if eq .Destination "/var/lib/lxc" }}{{ .Source }}{{ end }}{{ end }}' $container) | ||
# 确保本身pod中就有mount point | ||
if [ "$mountpoint" = "$LXCFS_ROOT_PATH" ];then | ||
echo "remount $container" | ||
PID=$(docker inspect --format '{{.State.Pid}}' $container) | ||
# mount /proc | ||
for file in meminfo cpuinfo loadavg stat diskstats swaps uptime;do | ||
echo nsenter --target $PID --mount -- mount -B "$LXCFS/proc/$file" "/proc/$file" | ||
nsenter --target $PID --mount -- /bin/mount -B "$LXCFS/proc/$file" "/proc/$file" | ||
done | ||
# mount /sys | ||
for file in online;do | ||
echo nsenter --target $PID --mount -- mount -B "$LXCFS/sys/devices/system/cpu/$file" "/sys/devices/system/cpu/$file" | ||
nsenter --target $PID --mount -- /bin/mount -B "$LXCFS/sys/devices/system/cpu/$file" "/sys/devices/system/cpu/$file" | ||
done | ||
fi | ||
done |
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
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