Skip to content

Commit

Permalink
increase the logs from containerd version 1.5.10 (#4506)
Browse files Browse the repository at this point in the history
  • Loading branch information
camilamacedo86 authored May 20, 2023
1 parent e67dc22 commit 9fcb7cb
Show file tree
Hide file tree
Showing 19 changed files with 551 additions and 38 deletions.
31 changes: 29 additions & 2 deletions addons/containerd/1.5.10/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -42,30 +42,43 @@ function containerd_install() {
# as soon as the container starts
try_1m_stderr cp ${DIR}/addons/containerd/${CONTAINERD_VERSION}/assets/runc $(which runc)

logStep "Containerd configuration"
containerd_configure

log "Enabling containerd"
systemctl enable containerd

log "Enabling containerd crictl"
containerd_configure_ctl "$src"

log "Checking for containerd custom settings"
containerd_configure_limitnofile

# NOTE: this will not remove the proxy
log "Checking for proxy set"
if [ -n "$PROXY_ADDRESS" ]; then
log "Proxy is set with the value: ($PROXY_ADDRESS)"
containerd_configure_proxy
fi

log "Checking registry configuration for the distro ${K8S_DISTRO} and if Docker registry IP is set"
if commandExists ${K8S_DISTRO}_registry_containerd_configure && [ -n "$DOCKER_REGISTRY_IP" ]; then
log "Docker registry IP is set with the value: ($DOCKER_REGISTRY_IP)"
${K8S_DISTRO}_registry_containerd_configure "$DOCKER_REGISTRY_IP"
CONTAINERD_NEEDS_RESTART=1
fi

log "Checking if containerd requires to be re-started"
if [ "$CONTAINERD_NEEDS_RESTART" = "1" ]; then
log "Re-starting containerd"
systemctl daemon-reload
restart_systemd_and_wait containerd
CONTAINERD_NEEDS_RESTART=0
fi

logSuccess "Containerd is successfully configured"

log "Checking if is required to migrate images from Docker"
if [ "$AIRGAP" = "1" ] && [ "$CONTAINERD_DID_MIGRATE_FROM_DOCKER" = "1" ]; then
logStep "Migrating images from Docker to Containerd..."
containerd_migrate_images_from_docker
Expand All @@ -74,9 +87,11 @@ function containerd_install() {

load_images $src/images

log "Checking if the kubelet service is enabled"
if systemctl list-unit-files | grep -v disabled | grep -q kubelet.service ; then
# do not try to start and wait for the kubelet if it is not yet configured
if [ -f /etc/kubernetes/kubelet.conf ]; then
log "Starting kubectl"
systemctl start kubelet
# If using the internal load balancer the Kubernetes API server will be unavailable until
# kubelet starts the HAProxy static pod. This check ensures the Kubernetes API server
Expand Down Expand Up @@ -111,7 +126,7 @@ function containerd_install_libzstd_if_missing() {

function containerd_configure() {
if [ "$CONTAINERD_PRESERVE_CONFIG" = "1" ]; then
echo "Skipping containerd configuration"
echo "Skipping containerd configuration in order to preserve config."
return
fi
mkdir -p /etc/containerd
Expand All @@ -125,7 +140,8 @@ function containerd_configure() {
SystemdCgroup = true
EOF

if [ -n "$CONTAINERD_TOML_CONFIG" ]; then
if [ -n "$CONTAINERD_TOML_CONFIG" ]; then
log "Found Containerd TomlConfig set. Installer will patch the value $CONTAINERD_TOML_CONFIG"
local tmp=$(mktemp)
echo "$CONTAINERD_TOML_CONFIG" > "$tmp"
"$DIR/bin/toml" -basefile=/etc/containerd/config.toml -patchfile="$tmp"
Expand All @@ -137,10 +153,13 @@ EOF
function containerd_configure_ctl() {
local src="$1"

log "Checks if the file /etc/crictl.yaml exist"
if [ -e "/etc/crictl.yaml" ]; then
log "Found /etc/crictl.yaml"
return 0
fi

log "Creates /etc/crictl.yaml"
cp "$src/crictl.yaml" /etc/crictl.yaml
}

Expand All @@ -151,9 +170,11 @@ function containerd_configure_limitnofile() {
local file=/etc/systemd/system/containerd.service.d/override-limitnofile.conf

if [ -f "$file" ]; then
log "Found /etc/systemd/system/containerd.service.d/override-limitnofile.conf"
return
fi

log "Creating /etc/systemd/system/containerd.service.d"
mkdir -p /etc/systemd/system/containerd.service.d

echo "# Generated by kURL" > "$file"
Expand All @@ -162,12 +183,17 @@ function containerd_configure_limitnofile() {
}

function containerd_configure_proxy() {
log "Configuring containerd proxy"
local previous_proxy="$(cat /etc/systemd/system/containerd.service.d/http-proxy.conf 2>/dev/null | grep -io 'https*_proxy=[^\" ]*' | awk 'BEGIN { FS="=" }; { print $2 }')"
local previous_no_proxy="$(cat /etc/systemd/system/containerd.service.d/http-proxy.conf 2>/dev/null | grep -io 'no_proxy=[^\" ]*' | awk 'BEGIN { FS="=" }; { print $2 }')"
log "Previous proxy: ($previous_proxy)"
log "Previous no proxy: (previous_no_proxy)"
if [ "$PROXY_ADDRESS" = "$previous_proxy" ] && [ "$NO_PROXY_ADDRESSES" = "$previous_no_proxy" ]; then
log "No changes were found. Proxy configuration still the same"
return
fi

log "Updating proxy configuration: HTTP_PROXY=${PROXY_ADDRESS} NO_PROXY=${NO_PROXY_ADDRESSES}"
mkdir -p /etc/systemd/system/containerd.service.d
local file=/etc/systemd/system/containerd.service.d/http-proxy.conf

Expand All @@ -176,6 +202,7 @@ function containerd_configure_proxy() {

echo "Environment=\"HTTP_PROXY=${PROXY_ADDRESS}\" \"HTTPS_PROXY=${PROXY_ADDRESS}\" \"NO_PROXY=${NO_PROXY_ADDRESSES}\"" >> $file


CONTAINERD_NEEDS_RESTART=1
}

Expand Down
31 changes: 29 additions & 2 deletions addons/containerd/1.5.11/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -42,30 +42,43 @@ function containerd_install() {
# as soon as the container starts
try_1m_stderr cp ${DIR}/addons/containerd/${CONTAINERD_VERSION}/assets/runc $(which runc)

logStep "Containerd configuration"
containerd_configure

log "Enabling containerd"
systemctl enable containerd

log "Enabling containerd crictl"
containerd_configure_ctl "$src"

log "Checking for containerd custom settings"
containerd_configure_limitnofile

# NOTE: this will not remove the proxy
log "Checking for proxy set"
if [ -n "$PROXY_ADDRESS" ]; then
log "Proxy is set with the value: ($PROXY_ADDRESS)"
containerd_configure_proxy
fi

log "Checking registry configuration for the distro ${K8S_DISTRO} and if Docker registry IP is set"
if commandExists ${K8S_DISTRO}_registry_containerd_configure && [ -n "$DOCKER_REGISTRY_IP" ]; then
log "Docker registry IP is set with the value: ($DOCKER_REGISTRY_IP)"
${K8S_DISTRO}_registry_containerd_configure "$DOCKER_REGISTRY_IP"
CONTAINERD_NEEDS_RESTART=1
fi

log "Checking if containerd requires to be re-started"
if [ "$CONTAINERD_NEEDS_RESTART" = "1" ]; then
log "Re-starting containerd"
systemctl daemon-reload
restart_systemd_and_wait containerd
CONTAINERD_NEEDS_RESTART=0
fi

logSuccess "Containerd is successfully configured"

log "Checking if is required to migrate images from Docker"
if [ "$AIRGAP" = "1" ] && [ "$CONTAINERD_DID_MIGRATE_FROM_DOCKER" = "1" ]; then
logStep "Migrating images from Docker to Containerd..."
containerd_migrate_images_from_docker
Expand All @@ -74,9 +87,11 @@ function containerd_install() {

load_images $src/images

log "Checking if the kubelet service is enabled"
if systemctl list-unit-files | grep -v disabled | grep -q kubelet.service ; then
# do not try to start and wait for the kubelet if it is not yet configured
if [ -f /etc/kubernetes/kubelet.conf ]; then
log "Starting kubectl"
systemctl start kubelet
# If using the internal load balancer the Kubernetes API server will be unavailable until
# kubelet starts the HAProxy static pod. This check ensures the Kubernetes API server
Expand Down Expand Up @@ -111,7 +126,7 @@ function containerd_install_libzstd_if_missing() {

function containerd_configure() {
if [ "$CONTAINERD_PRESERVE_CONFIG" = "1" ]; then
echo "Skipping containerd configuration"
echo "Skipping containerd configuration in order to preserve config."
return
fi
mkdir -p /etc/containerd
Expand All @@ -125,7 +140,8 @@ function containerd_configure() {
SystemdCgroup = true
EOF

if [ -n "$CONTAINERD_TOML_CONFIG" ]; then
if [ -n "$CONTAINERD_TOML_CONFIG" ]; then
log "Found Containerd TomlConfig set. Installer will patch the value $CONTAINERD_TOML_CONFIG"
local tmp=$(mktemp)
echo "$CONTAINERD_TOML_CONFIG" > "$tmp"
"$DIR/bin/toml" -basefile=/etc/containerd/config.toml -patchfile="$tmp"
Expand All @@ -137,10 +153,13 @@ EOF
function containerd_configure_ctl() {
local src="$1"

log "Checks if the file /etc/crictl.yaml exist"
if [ -e "/etc/crictl.yaml" ]; then
log "Found /etc/crictl.yaml"
return 0
fi

log "Creates /etc/crictl.yaml"
cp "$src/crictl.yaml" /etc/crictl.yaml
}

Expand All @@ -151,9 +170,11 @@ function containerd_configure_limitnofile() {
local file=/etc/systemd/system/containerd.service.d/override-limitnofile.conf

if [ -f "$file" ]; then
log "Found /etc/systemd/system/containerd.service.d/override-limitnofile.conf"
return
fi

log "Creating /etc/systemd/system/containerd.service.d"
mkdir -p /etc/systemd/system/containerd.service.d

echo "# Generated by kURL" > "$file"
Expand All @@ -162,12 +183,17 @@ function containerd_configure_limitnofile() {
}

function containerd_configure_proxy() {
log "Configuring containerd proxy"
local previous_proxy="$(cat /etc/systemd/system/containerd.service.d/http-proxy.conf 2>/dev/null | grep -io 'https*_proxy=[^\" ]*' | awk 'BEGIN { FS="=" }; { print $2 }')"
local previous_no_proxy="$(cat /etc/systemd/system/containerd.service.d/http-proxy.conf 2>/dev/null | grep -io 'no_proxy=[^\" ]*' | awk 'BEGIN { FS="=" }; { print $2 }')"
log "Previous proxy: ($previous_proxy)"
log "Previous no proxy: (previous_no_proxy)"
if [ "$PROXY_ADDRESS" = "$previous_proxy" ] && [ "$NO_PROXY_ADDRESSES" = "$previous_no_proxy" ]; then
log "No changes were found. Proxy configuration still the same"
return
fi

log "Updating proxy configuration: HTTP_PROXY=${PROXY_ADDRESS} NO_PROXY=${NO_PROXY_ADDRESSES}"
mkdir -p /etc/systemd/system/containerd.service.d
local file=/etc/systemd/system/containerd.service.d/http-proxy.conf

Expand All @@ -176,6 +202,7 @@ function containerd_configure_proxy() {

echo "Environment=\"HTTP_PROXY=${PROXY_ADDRESS}\" \"HTTPS_PROXY=${PROXY_ADDRESS}\" \"NO_PROXY=${NO_PROXY_ADDRESSES}\"" >> $file


CONTAINERD_NEEDS_RESTART=1
}

Expand Down
31 changes: 29 additions & 2 deletions addons/containerd/1.6.10/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -42,30 +42,43 @@ function containerd_install() {
# as soon as the container starts
try_1m_stderr cp ${DIR}/addons/containerd/${CONTAINERD_VERSION}/assets/runc $(which runc)

logStep "Containerd configuration"
containerd_configure

log "Enabling containerd"
systemctl enable containerd

log "Enabling containerd crictl"
containerd_configure_ctl "$src"

log "Checking for containerd custom settings"
containerd_configure_limitnofile

# NOTE: this will not remove the proxy
log "Checking for proxy set"
if [ -n "$PROXY_ADDRESS" ]; then
log "Proxy is set with the value: ($PROXY_ADDRESS)"
containerd_configure_proxy
fi

log "Checking registry configuration for the distro ${K8S_DISTRO} and if Docker registry IP is set"
if commandExists ${K8S_DISTRO}_registry_containerd_configure && [ -n "$DOCKER_REGISTRY_IP" ]; then
log "Docker registry IP is set with the value: ($DOCKER_REGISTRY_IP)"
${K8S_DISTRO}_registry_containerd_configure "$DOCKER_REGISTRY_IP"
CONTAINERD_NEEDS_RESTART=1
fi

log "Checking if containerd requires to be re-started"
if [ "$CONTAINERD_NEEDS_RESTART" = "1" ]; then
log "Re-starting containerd"
systemctl daemon-reload
restart_systemd_and_wait containerd
CONTAINERD_NEEDS_RESTART=0
fi

logSuccess "Containerd is successfully configured"

log "Checking if is required to migrate images from Docker"
if [ "$AIRGAP" = "1" ] && [ "$CONTAINERD_DID_MIGRATE_FROM_DOCKER" = "1" ]; then
logStep "Migrating images from Docker to Containerd..."
containerd_migrate_images_from_docker
Expand All @@ -74,9 +87,11 @@ function containerd_install() {

load_images $src/images

log "Checking if the kubelet service is enabled"
if systemctl list-unit-files | grep -v disabled | grep -q kubelet.service ; then
# do not try to start and wait for the kubelet if it is not yet configured
if [ -f /etc/kubernetes/kubelet.conf ]; then
log "Starting kubectl"
systemctl start kubelet
# If using the internal load balancer the Kubernetes API server will be unavailable until
# kubelet starts the HAProxy static pod. This check ensures the Kubernetes API server
Expand Down Expand Up @@ -111,7 +126,7 @@ function containerd_install_libzstd_if_missing() {

function containerd_configure() {
if [ "$CONTAINERD_PRESERVE_CONFIG" = "1" ]; then
echo "Skipping containerd configuration"
echo "Skipping containerd configuration in order to preserve config."
return
fi
mkdir -p /etc/containerd
Expand All @@ -125,7 +140,8 @@ function containerd_configure() {
SystemdCgroup = true
EOF

if [ -n "$CONTAINERD_TOML_CONFIG" ]; then
if [ -n "$CONTAINERD_TOML_CONFIG" ]; then
log "Found Containerd TomlConfig set. Installer will patch the value $CONTAINERD_TOML_CONFIG"
local tmp=$(mktemp)
echo "$CONTAINERD_TOML_CONFIG" > "$tmp"
"$DIR/bin/toml" -basefile=/etc/containerd/config.toml -patchfile="$tmp"
Expand All @@ -137,10 +153,13 @@ EOF
function containerd_configure_ctl() {
local src="$1"

log "Checks if the file /etc/crictl.yaml exist"
if [ -e "/etc/crictl.yaml" ]; then
log "Found /etc/crictl.yaml"
return 0
fi

log "Creates /etc/crictl.yaml"
cp "$src/crictl.yaml" /etc/crictl.yaml
}

Expand All @@ -151,9 +170,11 @@ function containerd_configure_limitnofile() {
local file=/etc/systemd/system/containerd.service.d/override-limitnofile.conf

if [ -f "$file" ]; then
log "Found /etc/systemd/system/containerd.service.d/override-limitnofile.conf"
return
fi

log "Creating /etc/systemd/system/containerd.service.d"
mkdir -p /etc/systemd/system/containerd.service.d

echo "# Generated by kURL" > "$file"
Expand All @@ -162,12 +183,17 @@ function containerd_configure_limitnofile() {
}

function containerd_configure_proxy() {
log "Configuring containerd proxy"
local previous_proxy="$(cat /etc/systemd/system/containerd.service.d/http-proxy.conf 2>/dev/null | grep -io 'https*_proxy=[^\" ]*' | awk 'BEGIN { FS="=" }; { print $2 }')"
local previous_no_proxy="$(cat /etc/systemd/system/containerd.service.d/http-proxy.conf 2>/dev/null | grep -io 'no_proxy=[^\" ]*' | awk 'BEGIN { FS="=" }; { print $2 }')"
log "Previous proxy: ($previous_proxy)"
log "Previous no proxy: (previous_no_proxy)"
if [ "$PROXY_ADDRESS" = "$previous_proxy" ] && [ "$NO_PROXY_ADDRESSES" = "$previous_no_proxy" ]; then
log "No changes were found. Proxy configuration still the same"
return
fi

log "Updating proxy configuration: HTTP_PROXY=${PROXY_ADDRESS} NO_PROXY=${NO_PROXY_ADDRESSES}"
mkdir -p /etc/systemd/system/containerd.service.d
local file=/etc/systemd/system/containerd.service.d/http-proxy.conf

Expand All @@ -176,6 +202,7 @@ function containerd_configure_proxy() {

echo "Environment=\"HTTP_PROXY=${PROXY_ADDRESS}\" \"HTTPS_PROXY=${PROXY_ADDRESS}\" \"NO_PROXY=${NO_PROXY_ADDRESSES}\"" >> $file


CONTAINERD_NEEDS_RESTART=1
}

Expand Down
Loading

0 comments on commit 9fcb7cb

Please sign in to comment.