Update Scripts

We will no longer need to manually update the '/etc/hosts' file
for 'in-cluster' scenario with the bug fix in [0]. This patch set
is meant to update the scripts in the tools directory to reflect
that change.

Note that user will still need to ensure that the DNS is set up or
'/etc/hosts' file is properly updated if he/she is executing the
workflow from outside the cluster, e.g. via jump server

[0] https://review.gerrithub.io/#/c/398739/

Change-Id: I0580cfc473b0f1b0ed824a578d3e6c89dd6f1443
This commit is contained in:
Anthony Lin 2018-02-09 05:40:13 +00:00
parent 1c893ab3ef
commit b8bb66d412
3 changed files with 44 additions and 103 deletions

View File

@ -33,53 +33,17 @@ if [[ -z "$2" ]]; then
exit 1 exit 1
fi fi
# NOTE: If user is executing the script from outside the cluster, e.g. from
# a remote jump server, then he/she will need to ensure that the DNS server
# is able to resolve the FQDN of the Shipyard and Keystone public URL (both
# will be pointing to the IP of the Ingress Controller). If the DNS resolution
# is not available, the user will need to ensure that the /etc/hosts file is
# properly updated before running the script.
# Define Variables # Define Variables
collection=$1 collection=$1
directory=$2 directory=$2
namespace="ucp" namespace="${namespace:-ucp}"
# Initialize Variables with Default Values
OS_USER_DOMAIN_NAME="${OS_USER_DOMAIN_NAME:-default}"
OS_PROJECT_DOMAIN_NAME="${OS_PROJECT_DOMAIN_NAME:-default}"
OS_PROJECT_NAME="${OS_PROJECT_NAME:-service}"
OS_USERNAME="${OS_USERNAME:-shipyard}"
OS_PASSWORD="${OS_PASSWORD:-password}"
OS_AUTH_URL="${OS_AUTH_URL:-http://keystone.${namespace}:80/v3}"
# Determine IP address of Ingress Controller
ingress_controller_ip=`sudo kubectl get pods -n ${namespace} -o wide | grep -v ingress-error-pages | grep -m 1 ingress | awk '{print $6}'`
# Update /etc/hosts with the IP of the ingress controller
# Note that these values would need to be set in the case
# where DNS resolution of the Keystone and Shipyard URLs
# is not available. We can skip this step if DNS is in place.
delete_etc_hosts_entries() {
# Delete lines in /etc/hosts that contain reference to the
# keystone and shipyard-api pods
sudo sed -i '/keystone/d' /etc/hosts
sudo sed -i '/shipyard-api/d' /etc/hosts
}
update_etc_hosts() {
cat << EOF | sudo tee -a /etc/hosts
$ingress_controller_ip keystone.${namespace}
$ingress_controller_ip shipyard-api.${namespace}.svc.cluster.local
EOF
}
if [[ ${ingress_controller_ip} ]]; then
# Delete any existing entries for the keystone and shipyard-api
# pods and replace it with the latest retrieved IP
delete_etc_hosts_entries
update_etc_hosts
else
echo -e "Unable to retrieve IP of Ingress Controller!"
exit 1
fi
# Clone shipyard repository if it does not exists # Clone shipyard repository if it does not exists
if [[ ! -d shipyard ]]; then if [[ ! -d shipyard ]]; then
@ -94,12 +58,12 @@ cd shipyard && sudo pip3 install -r requirements.txt
sudo python3 setup.py install sudo python3 setup.py install
# Export Environment Variables # Export Environment Variables
export OS_USER_DOMAIN_NAME=${OS_USER_DOMAIN_NAME} export OS_USER_DOMAIN_NAME="${OS_USER_DOMAIN_NAME:-default}"
export OS_PROJECT_DOMAIN_NAME=${OS_PROJECT_DOMAIN_NAME} export OS_PROJECT_DOMAIN_NAME="${OS_PROJECT_DOMAIN_NAME:-default}"
export OS_PROJECT_NAME=${OS_PROJECT_NAME} export OS_PROJECT_NAME="${OS_PROJECT_NAME:-service}"
export OS_USERNAME=${OS_USERNAME} export OS_USERNAME="${OS_USERNAME:-shipyard}"
export OS_PASSWORD=${OS_PASSWORD} export OS_PASSWORD="${OS_PASSWORD:-password}"
export OS_AUTH_URL=${OS_AUTH_URL} export OS_AUTH_URL="${OS_AUTH_URL:-http://keystone.${namespace}.svc.cluster.local:80/v3}"
# The directory will contain all the .yaml files with Drydock, Promenade, # The directory will contain all the .yaml files with Drydock, Promenade,
# Armada, and Divingbell configurations. It will also contain all the # Armada, and Divingbell configurations. It will also contain all the

View File

@ -13,7 +13,7 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
set -x set -ex
# User can run the script like how they would execute the Shipyard CLI. # User can run the script like how they would execute the Shipyard CLI.
# For instance, to run the 'shipyard get actions' command, user can execute # For instance, to run the 'shipyard get actions' command, user can execute
@ -22,69 +22,38 @@ set -x
# $ ./tools/run_shipyard.sh get actions # $ ./tools/run_shipyard.sh get actions
# #
# NOTE: User can retrieve the IP of the ingress_controller_ip by executing # NOTE: If user is executing the script from outside the cluster, e.g. from
# the following command: # a remote jump server, then he/she will need to ensure that the DNS server
# # is able to resolve the FQDN of the Shipyard and Keystone public URL (both
# ingress_controller_ip=`sudo kubectl get pods -n ucp -o wide | grep -v ingress-error-pages | grep -m 1 ingress | awk '{print $6}'` # will be pointing to the IP of the Ingress Controller). If the DNS resolution
# # is not available, the user will need to ensure that the /etc/hosts file is
# properly updated before running the script.
# NOTE: User should update /etc/hosts with the IP of the ingress # Define Variables
# controller if DNS resolution of the Keystone and Shipyard URLs
# is not available. User can execute the following command to update
# the /etc/hosts file:
# #
# cat << EOF | sudo tee -a /etc/hosts # NOTE: User will need to set up the required environment variables
# before executing this script if they differ from the default values.
# #
# $ingress_controller_ip keystone.ucp namespace="${namespace:-ucp}"
# $ingress_controller_ip shipyard-api.ucp.svc.cluster.local SHIPYARD_IMAGE="${SHIPYARD_IMAGE:-quay.io/attcomdev/shipyard:latest}"
# EOF
#
# NOTE: User will need to set up the necessary environment variables
# before executing this script. For instance, user can set up the
# environment with the following default values:
#
# export SHIPYARD_IMAGE='quay.io/attcomdev/shipyard:latest'
# export OS_AUTH_URL="http://keystone.ucp:80/v3"
# export OS_IDENTITY_API_VERSION=3
# export OS_USERNAME="shipyard"
# export OS_USER_DOMAIN_NAME="default"
# export OS_PASSWORD="password"
# export OS_PROJECT_DOMAIN_NAME="default"
# export OS_PROJECT_NAME="service"
#
# Define OpenStack Environment Variables
OS_AUTH_URL=`env | grep OS_AUTH_URL`
OS_IDENTITY_API_VERSION=`env | grep OS_IDENTITY_API_VERSION`
OS_USERNAME=`env | grep OS_USERNAME`
OS_USER_DOMAIN_NAME=`env | grep OS_USER_DOMAIN_NAME`
OS_PASSWORD=`env | grep OS_PASSWORD`
OS_PROJECT_DOMAIN_NAME=`env | grep OS_PROJECT_DOMAIN_NAME`
OS_PROJECT_NAME=`env | grep OS_PROJECT_NAME`
# Define shipyard image variable
# NOTE: We only want the location of the image. Hence we will need
# to stip off 'SHIPYARD_IMAGE=' from SHIPYARD_IMAGE_ENV_VARIABLE
SHIPYARD_IMAGE_ENV_VARIABLE=`env | grep SHIPYARD_IMAGE`
SHIPYARD_IMAGE="${SHIPYARD_IMAGE_ENV_VARIABLE#*=}"
# Define Base Docker Command # Define Base Docker Command
# NOTE: We will mount the current directory so that any directories # NOTE: We will mount the current directory so that any directories
# would be relative to that # would be relative to that
# NOTE: We will map the host directory to '/home/shipyard/host' on # NOTE: We will map the host directory to '/home/shipyard/host' on
# the Shipyard docker container # the Shipyard docker container
read -r -d '' base_docker_command << EOM base_docker_command=$(cat << EndOfCommand
sudo docker run sudo docker run
-e ${OS_AUTH_URL} -e OS_AUTH_URL=${OS_AUTH_URL:-http://keystone.${namespace}.svc.cluster.local:80/v3}
-e ${OS_IDENTITY_API_VERSION} -e OS_USERNAME=${OS_USERNAME:-shipyard}
-e ${OS_USERNAME} -e OS_USER_DOMAIN_NAME=${OS_USER_DOMAIN_NAME:-default}
-e ${OS_USER_DOMAIN_NAME} -e OS_PASSWORD=${OS_PASSWORD:-password}
-e ${OS_PASSWORD} -e OS_PROJECT_DOMAIN_NAME=${OS_PROJECT_DOMAIN_NAME:-default}
-e ${OS_PROJECT_DOMAIN_NAME} -e OS_PROJECT_NAME=${OS_PROJECT_NAME:-service}
-e ${OS_PROJECT_NAME}
--rm --net=host --rm --net=host
-v $(pwd):/home/shipyard/host/ -v $(pwd):/home/shipyard/host/
EOM EndOfCommand
)
# Execute Shipyard CLI # Execute Shipyard CLI
# We will pass all arguments in and the Shipyard CLI will perform # We will pass all arguments in and the Shipyard CLI will perform

View File

@ -13,6 +13,14 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
# NOTE: If user is executing deploy_site, update_site or redeploy_server
# workflow from outside the cluster, e.g. from a remote jump server, then
# he/she will need to ensure that the DNS server is able to resolve the
# FQDN of the Shipyard and Keystone public URL (both will be pointing to
# the IP of the Ingress Controller). If the DNS resolution is not available,
# the user will need to ensure that the /etc/hosts file is properly updated
# before setting up the environment variables and running the worflow.
# Define Variable # Define Variable
namespace="${namespace:-ucp}" namespace="${namespace:-ucp}"
@ -24,7 +32,7 @@ namespace="${namespace:-ucp}"
# exporting the required environment variable prior to running the script # exporting the required environment variable prior to running the script
export max_shipyard_count=${max_shipyard_count:-60} export max_shipyard_count=${max_shipyard_count:-60}
export shipyard_query_time=${shipyard_query_time:-90} export shipyard_query_time=${shipyard_query_time:-90}
export OS_AUTH_URL="${OS_AUTH_URL:-http://keystone.${namespace}:80/v3}" export OS_AUTH_URL="${OS_AUTH_URL:-http://keystone.${namespace}.svc.cluster.local:80/v3}"
export OS_PASSWORD="${OS_PASSWORD:-password}" export OS_PASSWORD="${OS_PASSWORD:-password}"
export OS_PROJECT_DOMAIN_NAME="${OS_PROJECT_DOMAIN_NAME:-default}" export OS_PROJECT_DOMAIN_NAME="${OS_PROJECT_DOMAIN_NAME:-default}"
export OS_PROJECT_NAME="${OS_PROJECT_NAME:-service}" export OS_PROJECT_NAME="${OS_PROJECT_NAME:-service}"