FATAL_TRACK k8scluster "install_cluster_addons.sh failed for kubeadm cluster"
elif [ "${K8S_CLUSTER_ENGINE}" == "k3s" ]; then
K3S_INSTALL_OPTS="-i ${OSM_DEFAULT_IP} -D ${OSM_DEVOPS} ${DEBUG_INSTALL}"
+ [ -n "${DOCKER_PROXY_URL}" ] && K3S_INSTALL_OPTS="${K3S_INSTALL_OPTS} -p ${DOCKER_PROXY_URL}"
# The K3s installation script will automatically take the HTTP_PROXY, HTTPS_PROXY and NO_PROXY,
# as well as the CONTAINERD_HTTP_PROXY, CONTAINERD_HTTPS_PROXY and CONTAINERD_NO_PROXY variables
# from the shell, if they are present, and write them to the environment file of k3s systemd service,
# K3s releases: https://github.com/k3s-io/k3s/releases/
K8S_VERSION="v1.29.3+k3s1"
+# configure registry
+function configure_registry() {
+ if [ -n "${DOCKER_PROXY_URL}" ]; then
+ echo "Configuring docker proxy URL in /etc/rancher/k3s/registries.yaml"
+ cat << EOF | sudo tee /etc/rancher/k3s/registries.yaml > /dev/null
+mirrors:
+ docker.io:
+ endpoint:
+ - "${DOCKER_PROXY_URL}"
+EOF
+ fi
+}
+
# installs k3s
function install_k3s() {
[ -z "${DEBUG_INSTALL}" ] || DEBUG beginning of function
}
# main
-while getopts ":D:i:-: " o; do
+while getopts ":D:i:p:-: " o; do
case "${o}" in
i)
DEFAULT_IP="${OPTARG}"
D)
OSM_DEVOPS="${OPTARG}"
;;
+ p)
+ DOCKER_PROXY_URL="${OPTARG}"
+ ;;
-)
[ "${OPTARG}" == "debug" ] && DEBUG_INSTALL="y" && continue
echo -e "Invalid option: '--$OPTARG'\n" >&2
DEBUG_INSTALL=${DEBUG_INSTALL:-}
DEFAULT_IP=${DEFAULT_IP:-"127.0.0.1"}
OSM_DEVOPS=${OSM_DEVOPS:-"/usr/share/osm-devops"}
+DOCKER_PROXY_URL=${DOCKER_PROXY_URL=-}
echo "DEBUG_INSTALL=${DEBUG_INSTALL}"
echo "DEFAULT_IP=${DEFAULT_IP}"
echo "OSM_DEVOPS=${OSM_DEVOPS}"
+echo "DOCKER_PROXY_URL=${DOCKER_PROXY_URL}"
echo "HOME=$HOME"
source $OSM_DEVOPS/common/logging
source $OSM_DEVOPS/common/track
+configure_registry
install_k3s
track k8scluster k3s_install_ok
check_for_readiness