From: garciadeblas Date: Thu, 2 Nov 2023 06:56:50 +0000 (+0100) Subject: Fix air-gapped installation issues with containerd and OSM helm chart X-Git-Url: https://osm.etsi.org/gitweb/?a=commitdiff_plain;h=73738a808076b4167ee1b86b28b655e83bdc4f8e;p=osm%2Fdevops.git Fix air-gapped installation issues with containerd and OSM helm chart Change-Id: I5d8a8afc751d892de6be92ebbb62bd3ace382b21 Signed-off-by: garciadeblas --- diff --git a/installers/full_install_osm.sh b/installers/full_install_osm.sh index 653b1bae..b49bb579 100755 --- a/installers/full_install_osm.sh +++ b/installers/full_install_osm.sh @@ -284,9 +284,17 @@ EOF" [ -n "${INSTALL_NGSA}" ] || OSM_HELM_OPTS="${OSM_HELM_OPTS} --set global.oldServiceAssurance=true" if [ -n "${OSM_BEHIND_PROXY}" ]; then OSM_HELM_OPTS="${OSM_HELM_OPTS} --set global.behindHttpProxy=true" - [ -n "${HTTP_PROXY}" ] && OSM_HELM_OPTS="${OSM_HELM_OPTS} --set global.httpProxy.HTTP_PROXY=${HTTP_PROXY}" - [ -n "${HTTPS_PROXY}" ] && OSM_HELM_OPTS="${OSM_HELM_OPTS} --set global.httpProxy.HTTPS_PROXY=${HTTPS_PROXY}" - [ -n "${NO_PROXY}" ] && OSM_HELM_OPTS="${OSM_HELM_OPTS} --set global.httpProxy.NO_PROXY=${NO_PROXY}" + [ -n "${HTTP_PROXY}" ] && OSM_HELM_OPTS="${OSM_HELM_OPTS} --set global.httpProxy.HTTP_PROXY=\"${HTTP_PROXY}\"" + [ -n "${HTTPS_PROXY}" ] && OSM_HELM_OPTS="${OSM_HELM_OPTS} --set global.httpProxy.HTTPS_PROXY=\"${HTTPS_PROXY}\"" + if [ -n "${NO_PROXY}" ]; then + if [[ ! "${NO_PROXY}" =~ .*".svc".* ]]; then + NO_PROXY="${NO_PROXY},.svc" + fi + if [[ ! "${NO_PROXY}" =~ .*".cluster.local".* ]]; then + NO_PROXY="${NO_PROXY},.cluster.local" + fi + OSM_HELM_OPTS="${OSM_HELM_OPTS} --set global.httpProxy.NO_PROXY=\"${NO_PROXY//,/\,}\"" + fi fi echo "helm -n $OSM_NAMESPACE install $OSM_NAMESPACE $OSM_DEVOPS/installers/helm/osm -f ${OSM_HELM_WORK_DIR}/osm-values.yaml ${OSM_HELM_OPTS}" diff --git a/installers/install_docker_ce.sh b/installers/install_docker_ce.sh index e5c2f44d..5010f7e3 100755 --- a/installers/install_docker_ce.sh +++ b/installers/install_docker_ce.sh @@ -15,6 +15,36 @@ set +eux +function configure_containerd() { + echo "Configuring containerd to expose CRI and use systemd cgroup" + sudo mv /etc/containerd/config.toml /etc/containerd/config.toml.orig 2>/dev/null + sudo bash -c "containerd config default > /etc/containerd/config.toml" + sudo sed -i 's/SystemdCgroup = false/SystemdCgroup = true/' /etc/containerd/config.toml + if [ -n "${DOCKER_PROXY_URL}" ]; then + echo "Configuring ${DOCKER_PROXY_URL} as registry mirror in /etc/containerd/config.toml" + sudo sed -i "s#\[plugins.\"io.containerd.grpc.v1.cri\".registry.mirrors\]#\[plugins.\"io.containerd.grpc.v1.cri\".registry.mirrors\]\n \[plugins.\"io.containerd.grpc.v1.cri\".registry.mirrors.\"docker.io\"\]\n endpoint = \[\"${DOCKER_PROXY_URL}\"\]\n \[plugins.\"io.containerd.grpc.v1.cri\".registry.mirrors.\"registry.hub.docker.com\"]\n endpoint = \[\"${DOCKER_PROXY_URL}\"]#" /etc/containerd/config.toml + fi + if [ -n "${OSM_BEHIND_PROXY}" ] ; then + echo "Configuring http proxies in /etc/systemd/system/containerd.service.d/http-proxy.conf" + if ! [ -f /etc/systemd/system/containerd.service.d/http-proxy.conf ] ; then + sudo mkdir -p /etc/systemd/system/containerd.service.d + cat << EOF | sudo tee -a /etc/systemd/system/containerd.service.d/http-proxy.conf +[Service] +EOF + fi + [ -n "${HTTP_PROXY}" ] && sudo bash -c "cat <> /etc/systemd/system/containerd.service.d/http-proxy.conf +Environment=\"HTTP_PROXY=${HTTP_PROXY}\" +EOF" + [ -n "${HTTPS_PROXY}" ] && sudo bash -c "cat <> /etc/systemd/system/containerd.service.d/http-proxy.conf +Environment=\"HTTPS_PROXY=${HTTPS_PROXY}\" +EOF" + [ -n "${NO_PROXY}" ] && sudo bash -c "cat <> /etc/systemd/system/containerd.service.d/http-proxy.conf +Environment=\"NO_PROXY=${NO_PROXY}\" +EOF" + fi + sudo systemctl restart containerd +} + function install_docker_ce() { # installs and configures Docker CE [ -z "${DEBUG_INSTALL}" ] || DEBUG beginning of function @@ -75,14 +105,7 @@ EOF" echo "... restarted Docker service" fi - echo "Configuring containerd to expose CRI, use systemd cgroup and use DOCKER_PROXY_URL as registry mirror" - sudo mv /etc/containerd/config.toml /etc/containerd/config.toml.orig 2>/dev/null - sudo bash -c "containerd config default > /etc/containerd/config.toml" - sudo sed -i 's/SystemdCgroup = false/SystemdCgroup = true/' /etc/containerd/config.toml - if [ -n "${DOCKER_PROXY_URL}" ]; then - sudo sed -i "s#\[plugins.\"io.containerd.grpc.v1.cri\".registry.mirrors\]#\[plugins.\"io.containerd.grpc.v1.cri\".registry.mirrors\]\n \[plugins.\"io.containerd.grpc.v1.cri\".registry.mirrors.\"docker.io\"\]\n endpoint = \[\"${DOCKER_PROXY_URL}\"\]\n \[plugins.\"io.containerd.grpc.v1.cri\".registry.mirrors.\"registry.hub.docker.com\"]\n endpoint = \[\"${DOCKER_PROXY_URL}\"]#" /etc/containerd/config.toml - fi - sudo systemctl restart containerd + configure_containerd [ -z "${DEBUG_INSTALL}" ] || ! echo "File: /etc/docker/daemon.json" || cat /etc/docker/daemon.json echo "Testing Docker CE installation ..."