Skip to content

Commit c7bbd26

Browse files
authored
Append SystemCGroup from containderd config file (#435)
*Issue description:* There was a change in the most recent EC2 AMI such that the config file for containderd has the attribute `SystemdCgroup` missing. (Before the attribute was present with the value set to `SystemdCgroup = false`) This attribute needs to be set to true in order for the k8s cluster to work. *Description of changes:* The sed command will initially replace the false value with true for SystemCgroup. If the systemCgroup doesn't exist though, it will try to append the attribute to the `[plugins.'io.containerd.cri.v1.runtime'.containerd.runtimes.runc.options] ` plugin Ran the script on personal account and verified that k8s is running again By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
1 parent 830910a commit c7bbd26

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

.github/workflows/util/setup-k8s.sh

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,8 @@ function run_k8s_master() {
9393
sudo containerd config default > config.toml
9494
sudo cp config.toml /etc/containerd/config.toml
9595
sudo sed -i 's/SystemdCgroup \= false/SystemdCgroup \= true/' /etc/containerd/config.toml
96-
sudo sed -i 's/systemd_cgroup \= true/systemd_cgroup \= true/' /etc/containerd/config.toml
96+
grep -Eq '^[[:space:]]*"?SystemdCgroup"?[[:space:]]*=[[:space:]]*true' /etc/containerd/config.toml || \
97+
sudo sed -i "/^[[:space:]]*\\[plugins\\.'io\\.containerd\\.cri\\.v1\\.runtime'\\.containerd\\.runtimes\\.runc\\.options\\]/a\ SystemdCgroup = true" /etc/containerd/config.toml
9798
sudo systemctl restart containerd && sleep 20
9899
sudo setenforce 0 && sudo sed -i 's/^SELINUX=enforcing$/SELINUX=permissive/' /etc/selinux/config
99100
echo -e "[kubernetes]\nname=Kubernetes\nbaseurl=https://pkgs.k8s.io/core:/stable:/v1.29/rpm/\nenabled=1\ngpgcheck=1\ngpgkey=https://pkgs.k8s.io/core:/stable:/v1.29/rpm/repodata/repomd.xml.key\nexclude=kubelet kubeadm kubectl cri-tools kubernetes-cni" | sudo tee /etc/yum.repos.d/kubernetes.repo
@@ -142,7 +143,8 @@ function run_k8s_worker() {
142143
sudo containerd config default > config.toml
143144
sudo cp config.toml /etc/containerd/config.toml
144145
sudo sed -i 's/SystemdCgroup \= false/SystemdCgroup \= true/' /etc/containerd/config.toml
145-
sudo sed -i 's/systemd_cgroup \= true/systemd_cgroup \= true/' /etc/containerd/config.toml
146+
grep -Eq '^[[:space:]]*"?SystemdCgroup"?[[:space:]]*=[[:space:]]*true' /etc/containerd/config.toml || \
147+
sudo sed -i "/^[[:space:]]*\\[plugins\\.'io\\.containerd\\.cri\\.v1\\.runtime'\\.containerd\\.runtimes\\.runc\\.options\\]/a\ SystemdCgroup = true" /etc/containerd/config.toml
146148
sudo systemctl restart containerd
147149
sudo setenforce 0 && sudo sed -i 's/^SELINUX=enforcing$/SELINUX=permissive/' /etc/selinux/config
148150
echo -e "[kubernetes]\nname=Kubernetes\nbaseurl=https://pkgs.k8s.io/core:/stable:/v1.29/rpm/\nenabled=1\ngpgcheck=1\ngpgkey=https://pkgs.k8s.io/core:/stable:/v1.29/rpm/repodata/repomd.xml.key\nexclude=kubelet kubeadm kubectl cri-tools kubernetes-cni" | sudo tee /etc/yum.repos.d/kubernetes.repo

0 commit comments

Comments
 (0)