From 6c6f0b0b1872c0f377bb028ff9a83bba7014f8c9 Mon Sep 17 00:00:00 2001 From: Stefan Dinescu Date: Wed, 25 Mar 2020 10:56:34 +0200 Subject: [PATCH] Add support for overriding docker images The clients tarball provides a set of default docker images to be used. This commit adds support for users to change those default images to other images from any registry. Changes included in this commit: - add the "-p" and "-a" parameters to the "configure_client.sh" script in order to override default platform and application image locations - fixed README file to properly handle IPv6 address when configuring the authentication file for helm - forced host networking for client docker containers in order to better handle network connectivity to the remote setups we want to connect to Change-Id: I9b88ad91ee873330a0fd62ec7eb6056dd544a758 Story: 2006711 Task: 39150 Signed-off-by: Stefan Dinescu --- remote_cli/README | 5 +++++ remote_cli/client_wrapper.sh | 8 ++++---- remote_cli/configure_client.sh | 22 +++++++++++++++++++++- 3 files changed, 30 insertions(+), 5 deletions(-) diff --git a/remote_cli/README b/remote_cli/README index db2583f..ec26ef1 100644 --- a/remote_cli/README +++ b/remote_cli/README @@ -96,6 +96,11 @@ if [ -z "$OAM_IP" ]; then # AIO-SX doesn't use oam_floating_ip, but instead uses just oam_ip OAM_IP=$(system oam-show |grep oam_ip| awk '{print $4}') fi +# If it's an IPv6 address we must enclose it in brackets +if [[ $OAM_IP =~ .*:.* ]]; then + OAM_IP="[${OAM_IP}]" +fi + kubectl config --kubeconfig ${OUTPUT_FILE} set-cluster stxcluster --server=https://${OAM_IP}:6443 --insecure-skip-tls-verify diff --git a/remote_cli/client_wrapper.sh b/remote_cli/client_wrapper.sh index 543fd1f..113ec48 100755 --- a/remote_cli/client_wrapper.sh +++ b/remote_cli/client_wrapper.sh @@ -70,11 +70,11 @@ else fi if [[ "$FORCE_SHELL" == "true" ]]; then - exec ${SHELL_COMMAND} run --rm -ti ${COMMAND_ENV} ${VOLUME_LIST} --workdir /wd ${CLIENT_IMAGE_NAME} "$@" + exec ${SHELL_COMMAND} run --rm --network host -ti ${COMMAND_ENV} ${VOLUME_LIST} --workdir /wd ${CLIENT_IMAGE_NAME} "$@" elif [[ "$FORCE_NO_SHELL" == "true" ]]; then - exec ${SHELL_COMMAND} run --rm -t ${COMMAND_ENV} ${VOLUME_LIST} --workdir /wd ${CLIENT_IMAGE_NAME} "$@" + exec ${SHELL_COMMAND} run --rm --network host -t ${COMMAND_ENV} ${VOLUME_LIST} --workdir /wd ${CLIENT_IMAGE_NAME} "$@" elif [ -z "$2" ]; then - exec ${SHELL_COMMAND} run --rm -ti ${COMMAND_ENV} ${VOLUME_LIST} --workdir /wd ${CLIENT_IMAGE_NAME} "$@" + exec ${SHELL_COMMAND} run --rm --network host -ti ${COMMAND_ENV} ${VOLUME_LIST} --workdir /wd ${CLIENT_IMAGE_NAME} "$@" else - exec ${SHELL_COMMAND} run --rm -t ${COMMAND_ENV} ${VOLUME_LIST} --workdir /wd ${CLIENT_IMAGE_NAME} "$@" + exec ${SHELL_COMMAND} run --rm --network host -t ${COMMAND_ENV} ${VOLUME_LIST} --workdir /wd ${CLIENT_IMAGE_NAME} "$@" fi diff --git a/remote_cli/configure_client.sh b/remote_cli/configure_client.sh index f844295..70b592f 100755 --- a/remote_cli/configure_client.sh +++ b/remote_cli/configure_client.sh @@ -15,6 +15,8 @@ TAG_FILE=docker_image_version.sh WORK_DIR='.' custom_conf_file=0 explicit_client_type=0 +override_platform_image=0 +override_application_image=0 # The script may be called from locations other # than its own folder, so build the full path to @@ -39,9 +41,11 @@ usage(){ echo " (default value is admin-openrc.sh)" echo "-k k8s_file kubernetis config file" echo " (default value is temp-kubeconfig)" + echo "-p override platform docker image" + echo "-a override application docker image" } -while getopts ":hr:w:o:t:k:" opt; do +while getopts ":hr:w:o:t:k:p:a:" opt; do case $opt in h) usage @@ -64,6 +68,14 @@ while getopts ":hr:w:o:t:k:" opt; do k) K8S_FILE=${OPTARG} ;; + p) + PLATFORM_IMAGE=${OPTARG} + override_platform_image=1 + ;; + a) + APPLICATION_IMAGE=${OPTARG} + override_application_image=1 + ;; *) echo "Invalid parameter provided" usage @@ -136,3 +148,11 @@ fi echo "source ${PATH_TO_SCRIPT}/$ALIAS_FILE" >> $CONF_FILE echo "source ${PATH_TO_SCRIPT}/$TAG_FILE" >> $CONF_FILE + +if [[ $override_platform_image -eq 1 ]]; then + echo "export PLATFORM_DOCKER_IMAGE=\"${PLATFORM_IMAGE}\"" >> $CONF_FILE +fi + +if [[ $override_application_image -eq 1 ]]; then + echo "export APPLICATION_DOCKER_IMAGE=\"${APPLICATION_IMAGE}\"" >> $CONF_FILE +fi