Update configure-insecure-registry-and-reload to support more type of container service
@@ -68,23 +68,35 @@ EOF
return 1
fi
- configure-insecure-registry-and-reload "sudo bash -c" $(pgrep dockerd)
+ configure-insecure-registry-and-reload "sudo bash -c" $(pgrep dockerd) ${docker_daemon_config}
}
function configure-insecure-registry-and-reload() {
local cmd_context="${1}" # context to run command e.g. sudo, docker exec
local docker_pid="${2}"
- ${cmd_context} "$(insecure-registry-config-cmd)"
+ local config_file="${3}"
+ ${cmd_context} "$(insecure-registry-config-cmd ${config_file})"
${cmd_context} "$(reload-daemon-cmd "${docker_pid}")"
}
function insecure-registry-config-cmd() {
+ local config_file="${1}"
+ case $config_file in
+ $docker_daemon_config)
echo "cat <<EOF > ${docker_daemon_config}
{
\"insecure-registries\": [\"${CONTAINER_REGISTRY_HOST}\"]
}
EOF
"
+ ;;
+ $containerd_config)
+ echo "sed -i '/\[plugins.cri.registry.mirrors\]/a [plugins.cri.registry.mirrors."\"${CONTAINER_REGISTRY_HOST}\""]\nendpoint = ["\"http://${CONTAINER_REGISTRY_HOST}\""]' ${containerd_config}"
+ ;;
+ *)
+ echo "Sorry, config insecure registy is not supported for $config_file"
+ ;;
+ esac
}
function reload-daemon-cmd() {
@@ -158,8 +170,8 @@ function check-clusters-ready() {
function configure-insecure-registry-on-cluster() {
cmd_context="docker exec cluster${1}-control-plane bash -c"
containerd_id=`${cmd_context} "pgrep -x containerd"`
- ${cmd_context} "sed -i '/\[plugins.cri.registry.mirrors\]/a [plugins.cri.registry.mirrors."\"${CONTAINER_REGISTRY_HOST}\""]\nendpoint = ["\"http://${CONTAINER_REGISTRY_HOST}\""]' ${containerd_config}"
- ${cmd_context} "$(reload-daemon-cmd "${containerd_id}")"
+
+ configure-insecure-registry-and-reload "${cmd_context}" ${containerd_id} ${containerd_config}
}
if [[ "${CREATE_INSECURE_REGISTRY}" ]]; then
