From: beierlm Date: Thu, 5 Nov 2020 22:04:05 +0000 (-0500) Subject: Adding registry flag X-Git-Tag: release-v9.0-start~46 X-Git-Url: https://osm.etsi.org/gitweb/?a=commitdiff_plain;ds=sidebyside;h=f2782c56cca33615b9879b4615bb2a9e3a9f7cba;p=osm%2Fdevops.git Adding registry flag Allow alternate registry to be supplied, with optional credentials. If registry is just host:port/path, no credentials will be used If user:pass@host:port/path, user and pass will be supplied as credentials. Change-Id: I8acf67b2916fea059fb306782388910e543b4046 Signed-off-by: beierlm --- diff --git a/installers/charmed_install.sh b/installers/charmed_install.sh index f0f729e6..b56ed168 100755 --- a/installers/charmed_install.sh +++ b/installers/charmed_install.sh @@ -18,6 +18,8 @@ K8S_CLOUD_NAME="k8s-cloud" KUBECTL="microk8s.kubectl" IMAGES_OVERLAY_FILE=~/.osm/images-overlay.yaml +PATH=/snap/bin:${PATH} + function check_arguments(){ while [ $# -gt 0 ] ; do case $1 in @@ -29,6 +31,7 @@ function check_arguments(){ --microstack) MICROSTACK=y ;; --ha) BUNDLE="cs:osm-ha" ;; --tag) TAG="$2" ;; + --registry) REGISTRY_INFO="$2" ;; esac shift done @@ -43,7 +46,7 @@ function install_snaps(){ mkdir -p ~/.kube sudo chown -f -R `whoami` ~/.kube KUBEGRP="microk8s" - microk8s status --wait-ready + sg ${KUBEGRP} -c "microk8s status --wait-ready" else KUBECTL="kubectl" sudo snap install kubectl --classic @@ -195,6 +198,27 @@ function wait_for_port(){ } function deploy_charmed_osm(){ + if [ -v REGISTRY_INFO ] ; then + registry_parts=(${REGISTRY_INFO//@/ }) + if [ ${#registry_parts[@]} -eq 1 ] ; then + # No credentials supplied + REGISTRY_USERNAME="" + REGISTRY_PASSWORD="" + REGISTRY_URL=${registry_parts[0]} + else + credentials=${registry_parts[0]} + credential_parts=(${credentials//:/ }) + REGISTRY_USERNAME=${credential_parts[0]} + REGISTRY_PASSWORD=${credential_parts[1]} + REGISTRY_URL=${registry_parts[1]} + fi + # Ensure the URL ends with a / + case $REGISTRY_URL in + */) ;; + *) REGISTRY_URL=${REGISTRY_URL}/ + esac + fi + create_overlay echo "Creating OSM model" if [ -v KUBECFG ]; then @@ -204,7 +228,11 @@ function deploy_charmed_osm(){ fi echo "Deploying OSM with charms" images_overlay="" + if [ -v REGISTRY_URL ]; then + [ ! -v TAG ] && TAG='latest' + fi [ -v TAG ] && generate_images_overlay && images_overlay="--overlay $IMAGES_OVERLAY_FILE" + if [ -v BUNDLE ]; then juju deploy $BUNDLE --overlay ~/.osm/vca-overlay.yaml $images_overlay else @@ -326,36 +354,44 @@ EOF } function generate_images_overlay(){ + if [ ! -z "$REGISTRY_USERNAME" ] ; then + REGISTRY_CREDENTIALS=$(cat < /tmp/images-overlay.yaml applications: lcm-k8s: options: - image: opensourcemano/lcm:$TAG + image: ${REGISTRY_URL}opensourcemano/lcm:$TAG ${REGISTRY_CREDENTIALS} mon-k8s: options: - image: opensourcemano/mon:$TAG + image: ${REGISTRY_URL}opensourcemano/mon:$TAG ${REGISTRY_CREDENTIALS} ro-k8s: options: - image: opensourcemano/ro:$TAG + image: ${REGISTRY_URL}opensourcemano/ro:$TAG ${REGISTRY_CREDENTIALS} nbi-k8s: options: - image: opensourcemano/nbi:$TAG + image: ${REGISTRY_URL}opensourcemano/nbi:$TAG ${REGISTRY_CREDENTIALS} pol-k8s: options: - image: opensourcemano/pol:$TAG + image: ${REGISTRY_URL}opensourcemano/pol:$TAG ${REGISTRY_CREDENTIALS} ui-k8s: options: - image: opensourcemano/light-ui:$TAG + image: ${REGISTRY_URL}opensourcemano/light-ui:$TAG ${REGISTRY_CREDENTIALS} pla: options: - image: opensourcemano/pla:$TAG + image: ${REGISTRY_URL}opensourcemano/pla:$TAG ${REGISTRY_CREDENTIALS} ng-ui: options: - image: opensourcemano/ng-ui:$TAG + image: ${REGISTRY_URL}opensourcemano/ng-ui:$TAG ${REGISTRY_CREDENTIALS} keystone: options: - image: opensourcemano/keystone:$TAG - + image: ${REGISTRY_URL}opensourcemano/keystone:$TAG ${REGISTRY_CREDENTIALS} EOF mv /tmp/images-overlay.yaml $IMAGES_OVERLAY_FILE } diff --git a/installers/full_install_osm.sh b/installers/full_install_osm.sh index 9ae5da2d..be02fa53 100755 --- a/installers/full_install_osm.sh +++ b/installers/full_install_osm.sh @@ -72,7 +72,8 @@ function usage(){ echo -e " [--lxd-cred ]: Takes a YAML file as a parameter with the LXD Credentials information (--charmed option)" echo -e " [--microstack]: Installs microstack as a vim. (--charmed option)" echo -e " [--ha]: Installs High Availability bundle. (--charmed option)" - echo -e " [--tag]: Docker image tag" + echo -e " [--tag]: Docker image tag. (--charmed option)" + echo -e " [--registry]: Docker registry with optional credentials as user:pass@hostname:port (--charmed option)" } @@ -1694,6 +1695,7 @@ while getopts ":b:r:c:n:k:u:R:D:o:O:m:N:H:S:s:w:t:U:P:A:l:L:K:-: hy" o; do [ "${OPTARG}" == "vca" ] && continue [ "${OPTARG}" == "ha" ] && continue [ "${OPTARG}" == "tag" ] && continue + [ "${OPTARG}" == "registry" ] && continue [ "${OPTARG}" == "pla" ] && INSTALL_PLA="y" && continue [ "${OPTARG}" == "volume" ] && OPENSTACK_ATTACH_VOLUME="true" && continue echo -e "Invalid option: '--$OPTARG'\n" >&2