-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Expand file tree
/
Copy pathgci-init.sh
More file actions
executable file
·66 lines (55 loc) · 2.7 KB
/
gci-init.sh
File metadata and controls
executable file
·66 lines (55 loc) · 2.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#!/bin/bash
# Copyright The containerd Authors.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# http://www.apache.org/licenses/LICENSE-2.0
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# This script is used to do extra initialization on GCI.
# set up cgroupv2 based on flag CONTAINERD_CGROUPV2 in containerd-env
CONTAINERD_HOME="/home/containerd"
CONTAINERD_ENV_METADATA="containerd-env"
if [ -f "${CONTAINERD_HOME}/${CONTAINERD_ENV_METADATA}" ]; then
source "${CONTAINERD_HOME}/${CONTAINERD_ENV_METADATA}"
fi
if [ "${CONTAINERD_CGROUPV2:-"false"}" == "true" ]; then
# check cos image
if [ -r /etc/os-release ]; then
OS_ID="$(. /etc/os-release && echo "$ID")"
fi
if [ "${OS_ID}" = "cos" ]; then
if ! grep -q 'systemd.unified_cgroup_hierarchy=true' /proc/cmdline && [ "$(stat -fc %T /sys/fs/cgroup/)" != "cgroup2fs" ]; then
echo "Setting up cgroupv2"
mount_path="/tmp/esp"
mkdir -p "${mount_path}"
esp_partition="/dev/sda12"
mount "${esp_partition}" "${mount_path}"
sed -i 's/systemd.unified_cgroup_hierarchy=false/systemd.unified_cgroup_hierarchy=true/g' "${mount_path}/efi/boot/grub.cfg"
umount "${mount_path}"
rmdir "${mount_path}"
echo "Reconfigured grub; rebooting..."
reboot
fi
fi
fi
mount /tmp /tmp -o remount,exec,suid
#TODO(random-liu): Stop docker and remove this docker thing.
usermod -a -G docker jenkins
#TODO(random-liu): Change current node e2e to use init script,
# so that we don't need to copy this code everywhere.
mkdir -p /var/lib/kubelet
mkdir -p /home/kubernetes/containerized_mounter/rootfs
mount --bind /home/kubernetes/containerized_mounter/ /home/kubernetes/containerized_mounter/
mount -o remount, exec /home/kubernetes/containerized_mounter/
wget https://storage.googleapis.com/kubernetes-release/gci-mounter/mounter.tar -O /tmp/mounter.tar
tar xvf /tmp/mounter.tar -C /home/kubernetes/containerized_mounter/rootfs
mkdir -p /home/kubernetes/containerized_mounter/rootfs/var/lib/kubelet
mount --rbind /var/lib/kubelet /home/kubernetes/containerized_mounter/rootfs/var/lib/kubelet
mount --make-rshared /home/kubernetes/containerized_mounter/rootfs/var/lib/kubelet
mount --bind /proc /home/kubernetes/containerized_mounter/rootfs/proc
mount --bind /dev /home/kubernetes/containerized_mounter/rootfs/dev
rm /tmp/mounter.tar