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}"
+ [ -n "${DOCKER_REGISTRY_URL}" ] && K3S_INSTALL_OPTS="${K3S_INSTALL_OPTS} -d ${DOCKER_REGISTRY_URL}"
+ [ -n "${DOCKER_REGISTRY_USER}" ] && K3S_INSTALL_OPTS="${K3S_INSTALL_OPTS} -u ${DOCKER_REGISTRY_USER}"
+ [ -n "${DOCKER_REGISTRY_PASSWORD}" ] && K3S_INSTALL_OPTS="${K3S_INSTALL_OPTS} -P ${DOCKER_REGISTRY_PASSWORD}"
# 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,
echo "Kubeadm requires docker, so docker will be installed."
fi
install_docker_ce
+ [ -n "${DOCKER_REGISTRY_URL}" ] && docker_login
fi
track docker_ce docker_ce_ok
docker.io:
endpoint:
- "${DOCKER_PROXY_URL}"
+EOF
+ fi
+ if [ -n "${DOCKER_REGISTRY_URL}" ]; then
+ echo "Configuring docker private registry in /etc/rancher/k3s/registries.yaml"
+ cat << EOF | sudo tee -a /etc/rancher/k3s/registries.yaml > /dev/null
+configs:
+ ${DOCKER_REGISTRY_URL}:
+ auth:
+ username: ${DOCKER_REGISTRY_USER}
+ password: ${DOCKER_REGISTRY_PASSWORD}
EOF
fi
}
}
# main
-while getopts ":D:i:p:-: " o; do
+while getopts ":D:i:p:d:u:P:-: " o; do
case "${o}" in
i)
DEFAULT_IP="${OPTARG}"
p)
DOCKER_PROXY_URL="${OPTARG}"
;;
+ d)
+ DOCKER_REGISTRY_URL="${OPTARG}"
+ ;;
+ u)
+ DOCKER_REGISTRY_USER="${OPTARG}"
+ ;;
+ P)
+ DOCKER_REGISTRY_PASSWORD="${OPTARG}"
+ ;;
-)
[ "${OPTARG}" == "debug" ] && DEBUG_INSTALL="y" && continue
echo -e "Invalid option: '--$OPTARG'\n" >&2
DEFAULT_IP=${DEFAULT_IP:-"127.0.0.1"}
OSM_DEVOPS=${OSM_DEVOPS:-"/usr/share/osm-devops"}
DOCKER_PROXY_URL=${DOCKER_PROXY_URL=-}
+DOCKER_REGISTRY_URL=${DOCKER_REGISTRY_URL=-}
+DOCKER_REGISTRY_USER=${DOCKER_REGISTRY_USER=-}
+DOCKER_REGISTRY_PASSWORD=${DOCKER_REGISTRY_PASSWORD=-}
echo "DEBUG_INSTALL=${DEBUG_INSTALL}"
echo "DEFAULT_IP=${DEFAULT_IP}"
echo "OSM_DEVOPS=${OSM_DEVOPS}"
echo "DOCKER_PROXY_URL=${DOCKER_PROXY_URL}"
+echo "DOCKER_REGISTRY_URL=${DOCKER_REGISTRY_URL}"
+echo "DOCKER_REGISTRY_USER=${DOCKER_REGISTRY_USER}"
echo "HOME=$HOME"
source $OSM_DEVOPS/common/logging