Skip to content

Commit

Permalink
Pull sandbox image periodically (#1601)
Browse files Browse the repository at this point in the history
  • Loading branch information
cartermckinnon authored Jan 31, 2024
1 parent d9abb3c commit 824c55e
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 2 deletions.
3 changes: 3 additions & 0 deletions files/bootstrap.sh
Original file line number Diff line number Diff line change
Expand Up @@ -575,10 +575,13 @@ if [[ "$CONTAINER_RUNTIME" = "containerd" ]]; then
if ! cmp -s /etc/eks/containerd/containerd-config.toml /etc/containerd/config.toml; then
sudo cp -v /etc/eks/containerd/containerd-config.toml /etc/containerd/config.toml
sudo cp -v /etc/eks/containerd/sandbox-image.service /etc/systemd/system/sandbox-image.service
sudo cp -v /etc/eks/containerd/sandbox-image.timer /etc/systemd/system/sandbox-image.timer
sudo chown root:root /etc/systemd/system/sandbox-image.service
sudo chown root:root /etc/systemd/system/sandbox-image.timer
systemctl daemon-reload
systemctl enable containerd sandbox-image
systemctl restart sandbox-image containerd
systemctl enable --now sandbox-image.timer
fi
sudo cp -v /etc/eks/containerd/kubelet-containerd.service /etc/systemd/system/kubelet.service
sudo chown root:root /etc/systemd/system/kubelet.service
Expand Down
9 changes: 9 additions & 0 deletions files/sandbox-image.timer
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[Unit]
Description=Pulls the containerd sandbox image periodically

[Timer]
OnUnitActiveSec=60
Persistent=true

[Install]
WantedBy=timers.target
5 changes: 4 additions & 1 deletion scripts/install-worker.sh
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ fi

sudo mv $WORKING_DIR/kubelet-containerd.service /etc/eks/containerd/kubelet-containerd.service
sudo mv $WORKING_DIR/sandbox-image.service /etc/eks/containerd/sandbox-image.service
sudo mv $WORKING_DIR/sandbox-image.timer /etc/eks/containerd/sandbox-image.timer
sudo mv $WORKING_DIR/pull-sandbox-image.sh /etc/eks/containerd/pull-sandbox-image.sh
sudo mv $WORKING_DIR/pull-image.sh /etc/eks/containerd/pull-image.sh
sudo chmod +x /etc/eks/containerd/pull-sandbox-image.sh
Expand Down Expand Up @@ -413,10 +414,12 @@ if [[ "$CACHE_CONTAINER_IMAGES" == "true" ]] && ! [[ ${ISOLATED_REGIONS} =~ $BIN
cat /etc/eks/containerd/containerd-config.toml | sed s,SANDBOX_IMAGE,$PAUSE_CONTAINER,g | sudo tee /etc/eks/containerd/containerd-cached-pause-config.toml
sudo cp -v /etc/eks/containerd/containerd-cached-pause-config.toml /etc/containerd/config.toml
sudo cp -v /etc/eks/containerd/sandbox-image.service /etc/systemd/system/sandbox-image.service
sudo cp -v /etc/eks/containerd/sandbox-image.timer /etc/systemd/system/sandbox-image.timer
sudo chown root:root /etc/systemd/system/sandbox-image.service
sudo chown root:root /etc/systemd/system/sandbox-image.timer
sudo systemctl daemon-reload
sudo systemctl start containerd
sudo systemctl enable containerd sandbox-image
sudo systemctl enable containerd sandbox-image sandbox-image.timer

K8S_MINOR_VERSION=$(echo "${KUBERNETES_VERSION}" | cut -d'.' -f1-2)

Expand Down
2 changes: 1 addition & 1 deletion test/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ COPY --from=aemm /ec2-metadata-mock /sbin/ec2-metadata-mock
RUN mkdir -p /etc/systemd/system
RUN mkdir -p /etc/eks/containerd
COPY files/ /etc/eks/
COPY files/containerd-config.toml files/kubelet-containerd.service files/pull-sandbox-image.sh files/sandbox-image.service /etc/eks/containerd/
COPY files/containerd-config.toml files/kubelet-containerd.service files/pull-sandbox-image.sh files/sandbox-image.service files/sandbox-image.timer /etc/eks/containerd/
COPY files/kubelet-config.json /etc/kubernetes/kubelet/kubelet-config.json
COPY files/kubelet-kubeconfig /var/lib/kubelet/kubeconfig
COPY files/ecr-credential-provider-config.json /etc/eks/image-credential-provider/config.json
Expand Down

0 comments on commit 824c55e

Please sign in to comment.