Skip to content
This repository has been archived by the owner on Oct 24, 2023. It is now read-only.

Commit

Permalink
chore: ensure containerd has image cache on VHDs (#4249)
Browse files Browse the repository at this point in the history
  • Loading branch information
jackfrancis authored Feb 12, 2021
1 parent 1c12289 commit 3497425
Show file tree
Hide file tree
Showing 4 changed files with 84 additions and 99 deletions.
23 changes: 11 additions & 12 deletions parts/k8s/cloud-init/artifacts/cse_config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -304,9 +304,10 @@ enableCRISystemdMonitor() {
}
{{- if NeedsContainerd}}
installContainerd() {
removeMoby
local v
v=$(containerd -version | cut -d " " -f 3 | sed 's|v||')
if [[ $v != "${CONTAINERD_VERSION}" ]]; then
if [[ $v != "${CONTAINERD_VERSION}"* ]]; then
os_lower=$(echo ${OS} | tr '[:upper:]' '[:lower:]')
if [[ ${OS} == "${UBUNTU_OS_NAME}" ]]; then
url_path="${os_lower}/${UBUNTU_RELEASE}/multiarch/prod"
Expand All @@ -315,12 +316,7 @@ installContainerd() {
else
exit 25
fi
removeMoby
removeContainerd
retrycmd_no_stats 120 5 25 curl ${MS_APT_REPO}/config/ubuntu/${UBUNTU_RELEASE}/prod.list >/tmp/microsoft-prod.list || exit 25
retrycmd 10 5 10 cp /tmp/microsoft-prod.list /etc/apt/sources.list.d/ || exit 25
retrycmd_no_stats 120 5 25 curl ${MS_APT_REPO}/keys/microsoft.asc | gpg --dearmor >/tmp/microsoft.gpg || exit 26
retrycmd 10 5 10 cp /tmp/microsoft.gpg /etc/apt/trusted.gpg.d/ || exit 26
apt_get_update || exit 99
apt_get_install 20 30 120 moby-runc moby-containerd=${CONTAINERD_VERSION}* --allow-downgrades || exit 27
fi
Expand Down Expand Up @@ -676,14 +672,17 @@ installSGXDrivers() {
{{end}}
{{- if HasVHDDistroNodes}}
cleanUpContainerImages() {
docker rmi $(docker images --format '{{OpenBraces}}.Repository{{CloseBraces}}:{{OpenBraces}}.Tag{{CloseBraces}}' | grep -vE "${KUBERNETES_VERSION}$|${KUBERNETES_VERSION}-|${KUBERNETES_VERSION}_" | grep 'hyperkube') &
docker rmi $(docker images --format '{{OpenBraces}}.Repository{{CloseBraces}}:{{OpenBraces}}.Tag{{CloseBraces}}' | grep -vE "${KUBERNETES_VERSION}$|${KUBERNETES_VERSION}-|${KUBERNETES_VERSION}_" | grep 'cloud-controller-manager') &
{{- if NeedsContainerd}}
docker rmi -f $(docker images -a -q) &
{{else}}
docker rmi $(docker images --format '{{OpenBraces}}.Repository{{CloseBraces}}:{{OpenBraces}}.Tag{{CloseBraces}}' | grep -vE "${ETCD_VERSION}$|${ETCD_VERSION}-|${ETCD_VERSION}_" | grep 'etcd') &
docker rmi $(docker images --format '{{OpenBraces}}.Repository{{CloseBraces}}:{{OpenBraces}}.Tag{{CloseBraces}}' | grep 'hcp-tunnel-front') &
docker rmi $(docker images --format '{{OpenBraces}}.Repository{{CloseBraces}}:{{OpenBraces}}.Tag{{CloseBraces}}' | grep 'kube-svc-redirect') &
docker rmi $(docker images --format '{{OpenBraces}}.Repository{{CloseBraces}}:{{OpenBraces}}.Tag{{CloseBraces}}' | grep 'nginx') &

docker rmi $(docker images --format '{{OpenBraces}}.Repository{{CloseBraces}}:{{OpenBraces}}.Tag{{CloseBraces}}' | grep -vE "${KUBERNETES_VERSION}$|${KUBERNETES_VERSION}-|${KUBERNETES_VERSION}_" | grep 'kube-proxy') &
docker rmi $(docker images --format '{{OpenBraces}}.Repository{{CloseBraces}}:{{OpenBraces}}.Tag{{CloseBraces}}' | grep -vE "${KUBERNETES_VERSION}$|${KUBERNETES_VERSION}-|${KUBERNETES_VERSION}_" | grep 'kube-controller-manager') &
docker rmi $(docker images --format '{{OpenBraces}}.Repository{{CloseBraces}}:{{OpenBraces}}.Tag{{CloseBraces}}' | grep -vE "${KUBERNETES_VERSION}$|${KUBERNETES_VERSION}-|${KUBERNETES_VERSION}_" | grep 'kube-apiserver') &
docker rmi $(docker images --format '{{OpenBraces}}.Repository{{CloseBraces}}:{{OpenBraces}}.Tag{{CloseBraces}}' | grep -vE "${KUBERNETES_VERSION}$|${KUBERNETES_VERSION}-|${KUBERNETES_VERSION}_" | grep 'kube-scheduler') &
docker rmi registry:2.7.1 &
ctr -n=k8s.io image rm $(ctr -n=k8s.io images ls -q) &
{{- end}}
}
cleanUpGPUDrivers() {
rm -Rf $GPU_DEST
Expand Down
14 changes: 9 additions & 5 deletions parts/k8s/cloud-init/artifacts/cse_install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ installDeps() {
if [[ ${OS} == "${UBUNTU_OS_NAME}" ]]; then
retrycmd_no_stats 120 5 25 curl -fsSL ${MS_APT_REPO}/config/ubuntu/${UBUNTU_RELEASE}/packages-microsoft-prod.deb >/tmp/packages-microsoft-prod.deb || exit 42
retrycmd 60 5 10 dpkg -i /tmp/packages-microsoft-prod.deb || exit 43
retrycmd_no_stats 120 5 25 curl ${MS_APT_REPO}/config/ubuntu/${UBUNTU_RELEASE}/prod.list >/tmp/microsoft-prod.list || exit 25
retrycmd 10 5 10 cp /tmp/microsoft-prod.list /etc/apt/sources.list.d/ || exit 25
retrycmd_no_stats 120 5 25 curl ${MS_APT_REPO}/keys/microsoft.asc | gpg --dearmor >/tmp/microsoft.gpg || exit 26
retrycmd 10 5 10 cp /tmp/microsoft.gpg /etc/apt/trusted.gpg.d/ || exit 26
aptmarkWALinuxAgent hold
packages+=" cgroup-lite ceph-common glusterfs-client"
if [[ $UBUNTU_RELEASE == "18.04" ]]; then
Expand Down Expand Up @@ -110,11 +114,6 @@ installMoby() {
removeMoby
fi
if [ -n "${install_pkgs}" ]; then
retrycmd_no_stats 120 5 25 curl ${MS_APT_REPO}/config/ubuntu/${UBUNTU_RELEASE}/prod.list >/tmp/microsoft-prod.list || exit 25
retrycmd 10 5 10 cp /tmp/microsoft-prod.list /etc/apt/sources.list.d/ || exit 25
retrycmd_no_stats 120 5 25 curl ${MS_APT_REPO}/keys/microsoft.asc | gpg --dearmor >/tmp/microsoft.gpg || exit 26
retrycmd 10 5 10 cp /tmp/microsoft.gpg /etc/apt/trusted.gpg.d/ || exit 26
apt_get_update || exit 99
apt_get_install 20 30 120 ${install_pkgs} --allow-downgrades || exit 27
fi
}
Expand Down Expand Up @@ -233,6 +232,11 @@ pullContainerImage() {
local cli_tool=$1 url=$2
retrycmd 60 1 1200 $cli_tool pull $url || exit 35
}
loadContainerImage() {
docker pull $1 || exit 35
docker save $1 | ctr -n=k8s.io images import - || exit 35

}
overrideNetworkConfig() {
CONFIG_FILEPATH="/etc/cloud/cloud.cfg.d/80_azure_net_config.cfg"
touch ${CONFIG_FILEPATH}
Expand Down
37 changes: 20 additions & 17 deletions pkg/engine/templates_generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 3497425

Please sign in to comment.