From: garciadeblas Date: Mon, 30 Nov 2020 14:07:03 +0000 (+0000) Subject: Updates in CI pipeline and installer for the new pipeline: registry and proxy url... X-Git-Tag: release-v9.0-start~9 X-Git-Url: https://osm.etsi.org/gitweb/?a=commitdiff_plain;h=7f1e1043fc4a21f67f76ae8293caaf9c33cfb928;p=osm%2Fdevops.git Updates in CI pipeline and installer for the new pipeline: registry and proxy url, different docker tag for specific modules Change-Id: Id434332fd1e051d9888bb35bf03ace974cd14bbc Signed-off-by: garciadeblas --- diff --git a/installers/full_install_osm.sh b/installers/full_install_osm.sh index a60898ed..875ee250 100755 --- a/installers/full_install_osm.sh +++ b/installers/full_install_osm.sh @@ -17,6 +17,8 @@ function usage(){ echo -e "usage: $0 [OPTIONS]" echo -e "Install OSM from binaries or source code (by default, from binaries)" echo -e " OPTIONS" + echo -e " -h / --help: print this help" + echo -e " -y: do not prompt for confirmation, assumes yes" echo -e " -r : use specified repository name for osm packages" echo -e " -R : use specified release for osm binaries (deb packages, lxd images, ...)" echo -e " -u : use specified repository url for osm packages" @@ -37,7 +39,7 @@ function usage(){ echo -e " --vimemu: additionally deploy the VIM emulator as a docker container" echo -e " --elk_stack: additionally deploy an ELK docker stack for event logging" echo -e " --pla: install the PLA module for placement support" - echo -e " -m : install OSM but only rebuild the specified docker images (LW-UI, NBI, LCM, RO, MON, POL, KAFKA, MONGO, PROMETHEUS, PROMETHEUS-CADVISOR, KEYSTONE-DB, PLA, NONE)" + echo -e " -m : install OSM but only rebuild or pull the specified docker images (LW-UI, NG-UI, NBI, LCM, RO, MON, POL, PLA, KAFKA, MONGO, PROMETHEUS, PROMETHEUS-CADVISOR, KEYSTONE-DB, NONE)" echo -e " -o : ONLY (un)installs one of the addons (vimemu, elk_stack, k8s_monitor)" echo -e " -O : Install OSM to an OpenStack infrastructure. is required. If a is used, the clouds.yaml file should be under ~/.config/openstack/ or /etc/openstack/" echo -e " -N : Public network name required to setup OSM to OpenStack" @@ -47,6 +49,9 @@ function usage(){ echo -e " -l: LXD cloud yaml file" echo -e " -L: LXD credentials yaml file" echo -e " -K: Specifies the name of the controller to use - The controller must be already bootstrapped" + echo -e " -d use docker registry URL instead of dockerhub" + echo -e " -p set docker proxy URL as part of docker CE configuration" + echo -e " -T specify docker tag for the modules specified with option -m" echo -e " --nolxd: do not install and configure LXD, allowing unattended installations (assumes LXD is already installed and confifured)" echo -e " --nodocker: do not install docker, do not initialize a swarm (assumes docker is already installed and a swarm has been initialized)" echo -e " --nojuju: do not juju, assumes already installed" @@ -62,8 +67,6 @@ function usage(){ # echo -e " --reconfigure: reconfigure the modules (DO NOT change NAT rules)" # echo -e " --update: update to the latest stable release or to the latest commit if using a specific branch" echo -e " --showopts: print chosen options and exit (only for debugging)" - echo -e " -y: do not prompt for confirmation, assumes yes" - echo -e " -h / --help: print this help" echo -e " --charmed: Deploy and operate OSM with Charms on k8s" echo -e " [--bundle ]: Specify with which bundle to deploy OSM with charms (--charmed option)" echo -e " [--k8s ]: Specify with which kubernetes to deploy OSM with charms (--charmed option)" @@ -215,21 +218,17 @@ function uninstall_lightweight() { remove_stack osm_elk fi echo "Now osm docker images and volumes will be deleted" + # TODO: clean-up of images should take into account if other tags were used for specific modules newgrp docker << EONG - docker image rm ${DOCKER_USER}/ro:${OSM_DOCKER_TAG} - docker image rm ${DOCKER_USER}/lcm:${OSM_DOCKER_TAG} - docker image rm ${DOCKER_USER}/keystone:${OSM_DOCKER_TAG} - docker image rm ${DOCKER_USER}/nbi:${OSM_DOCKER_TAG} - docker image rm ${DOCKER_USER}/mon:${OSM_DOCKER_TAG} - docker image rm ${DOCKER_USER}/pol:${OSM_DOCKER_TAG} - docker image rm ${DOCKER_USER}/pla:${OSM_DOCKER_TAG} - docker image rm ${DOCKER_USER}/osmclient:${OSM_DOCKER_TAG} +for module in ro lcm keystone nbi mon pol pla osmclient; do + docker image rm ${DOCKER_REGISTRY_URL}${DOCKER_USER}/${module}:${OSM_DOCKER_TAG} +done EONG if [ -n "$NGUI" ]; then - sg docker -c "docker image rm ${DOCKER_USER}/ng-ui:${OSM_DOCKER_TAG}" + sg docker -c "docker image rm ${DOCKER_REGISTRY_URL}${DOCKER_USER}/ng-ui:${OSM_DOCKER_TAG}" else - sg docker -c "docker image rm ${DOCKER_USER}/light-ui:${OSM_DOCKER_TAG}" + sg docker -c "docker image rm ${DOCKER_REGISTRY_URL}${DOCKER_USER}/light-ui:${OSM_DOCKER_TAG}" fi if [ -n "$KUBERNETES" ]; then @@ -402,6 +401,25 @@ function install_docker_ce() { sleep 2 sudo service docker restart echo "... restarted Docker service" + if [ -n "${DOCKER_PROXY_URL}" ]; then + echo "Configuring docker proxy ..." + if [ -f daemon.json ]; then + if grep -q registry-mirrors daemon.json; then + sudo sed -Ei 's/("registry-mirrors".*\[)(.*)\]/\1\2, \"'"${DOCKER_PROXY_URL}"'\"\]/' daemon.json + else + sudo sed -i 's/{/{\n "registry-mirrors": [\"'"${DOCKER_PROXY_URL}"'\"]",/' daemon.json + fi + else + sudo cat << EOF > daemon.json +{ + "registry-mirrors": ["${DOCKER_PROXY_URL}"] +} +EOF + fi + sudo systemctl daemon-reload + sudo service docker restart + echo "... restarted Docker service again" + fi sg docker -c "docker version" || FATAL "Docker installation failed" echo "... Docker CE installation done" return 0 @@ -498,15 +516,8 @@ function juju_createproxy() { function generate_docker_images() { echo "Pulling and generating docker images" - _build_from=$COMMIT_ID - [ -z "$_build_from" ] && _build_from="master" - - echo "OSM Docker images generated from $_build_from" - BUILD_ARGS+=(--build-arg REPOSITORY="$REPOSITORY") - BUILD_ARGS+=(--build-arg RELEASE="$RELEASE") - BUILD_ARGS+=(--build-arg REPOSITORY_KEY="$REPOSITORY_KEY") - BUILD_ARGS+=(--build-arg REPOSITORY_BASE="$REPOSITORY_BASE") + echo "Pulling docker images" if [ -z "$TO_REBUILD" ] || echo $TO_REBUILD | grep -q KAFKA ; then sg docker -c "docker pull wurstmeister/zookeeper" || FATAL "cannot get zookeeper docker image" @@ -538,84 +549,66 @@ function generate_docker_images() { fi if [ -n "$PULL_IMAGES" ]; then - sg docker -c "docker pull ${DOCKER_USER}/mon:${OSM_DOCKER_TAG}" || FATAL "cannot pull MON docker image" - elif [ -z "$TO_REBUILD" ] || echo $TO_REBUILD | grep -q MON ; then - git -C ${LWTEMPDIR} clone https://osm.etsi.org/gerrit/osm/MON - git -C ${LWTEMPDIR}/MON checkout ${COMMIT_ID} - sg docker -c "docker build ${LWTEMPDIR}/MON -f ${LWTEMPDIR}/MON/docker/Dockerfile -t ${DOCKER_USER}/mon --no-cache" || FATAL "cannot build MON docker image" - fi - - if [ -n "$PULL_IMAGES" ]; then - sg docker -c "docker pull ${DOCKER_USER}/pol:${OSM_DOCKER_TAG}" || FATAL "cannot pull POL docker image" - elif [ -z "$TO_REBUILD" ] || echo $TO_REBUILD | grep -q POL ; then - git -C ${LWTEMPDIR} clone https://osm.etsi.org/gerrit/osm/POL - git -C ${LWTEMPDIR}/POL checkout ${COMMIT_ID} - sg docker -c "docker build ${LWTEMPDIR}/POL -f ${LWTEMPDIR}/POL/docker/Dockerfile -t ${DOCKER_USER}/pol --no-cache" || FATAL "cannot build POL docker image" - fi - - if [ -n "$PULL_IMAGES" -a -n "$INSTALL_PLA" ]; then - sg docker -c "docker pull ${DOCKER_USER}/pla:${OSM_DOCKER_TAG}" || FATAL "cannot pull PLA docker image" - elif [ -z "$TO_REBUILD" -a -n "$INSTALL_PLA" ] || echo $TO_REBUILD | grep -q PLA ; then - git -C ${LWTEMPDIR} clone https://osm.etsi.org/gerrit/osm/PLA - git -C ${LWTEMPDIR}/PLA checkout ${COMMIT_ID} - sg docker -c "docker build ${LWTEMPDIR}/PLA -f ${LWTEMPDIR}/PLA/docker/Dockerfile -t ${DOCKER_USER}/pla --no-cache" || FATAL "cannot build PLA docker image" - fi - - if [ -n "$PULL_IMAGES" ]; then - sg docker -c "docker pull ${DOCKER_USER}/nbi:${OSM_DOCKER_TAG}" || FATAL "cannot pull NBI docker image" - sg docker -c "docker pull ${DOCKER_USER}/keystone:${OSM_DOCKER_TAG}" || FATAL "cannot pull KEYSTONE docker image" - elif [ -z "$TO_REBUILD" ] || echo $TO_REBUILD | grep -q NBI ; then - git -C ${LWTEMPDIR} clone https://osm.etsi.org/gerrit/osm/NBI - git -C ${LWTEMPDIR}/NBI checkout ${COMMIT_ID} - sg docker -c "docker build ${LWTEMPDIR}/NBI -f ${LWTEMPDIR}/NBI/Dockerfile.local -t ${DOCKER_USER}/nbi --no-cache" || FATAL "cannot build NBI docker image" - sg docker -c "docker build ${LWTEMPDIR}/NBI/keystone -f ${LWTEMPDIR}/NBI/keystone/Dockerfile -t ${DOCKER_USER}/keystone --no-cache" || FATAL "cannot build KEYSTONE docker image" - fi - - if [ -n "$PULL_IMAGES" ]; then - sg docker -c "docker pull ${DOCKER_USER}/ro:${OSM_DOCKER_TAG}" || FATAL "cannot pull RO docker image" - elif [ -z "$TO_REBUILD" ] || echo $TO_REBUILD | grep -q RO ; then - git -C ${LWTEMPDIR} clone https://osm.etsi.org/gerrit/osm/RO - git -C ${LWTEMPDIR}/RO checkout ${COMMIT_ID} - sg docker -c "docker build ${LWTEMPDIR}/RO -f ${LWTEMPDIR}/RO/Dockerfile-local -t ${DOCKER_USER}/ro --no-cache" || FATAL "cannot build RO docker image" - fi - - if [ -n "$PULL_IMAGES" ]; then - sg docker -c "docker pull ${DOCKER_USER}/lcm:${OSM_DOCKER_TAG}" || FATAL "cannot pull LCM RO docker image" - elif [ -z "$TO_REBUILD" ] || echo $TO_REBUILD | grep -q LCM ; then - git -C ${LWTEMPDIR} clone https://osm.etsi.org/gerrit/osm/LCM - git -C ${LWTEMPDIR}/LCM checkout ${COMMIT_ID} - sg docker -c "docker build ${LWTEMPDIR}/LCM -f ${LWTEMPDIR}/LCM/Dockerfile.local -t ${DOCKER_USER}/lcm --no-cache" || FATAL "cannot build LCM docker image" - fi - - if [ -n "$NGUI" ]; then - if [ -n "$PULL_IMAGES" ]; then - sg docker -c "docker pull ${DOCKER_USER}/ng-ui:${OSM_DOCKER_TAG}" || FATAL "cannot pull ng-ui docker image" - elif [ -z "$TO_REBUILD" ] || echo $TO_REBUILD | grep -q NG-UI ; then - git -C ${LWTEMPDIR} clone https://osm.etsi.org/gerrit/osm/NG-UI - git -C ${LWTEMPDIR}/NG-UI checkout ${COMMIT_ID} - sg docker -c "docker build ${LWTEMPDIR}/NG-UI -f ${LWTEMPDIR}/NG-UI/docker/Dockerfile -t ${DOCKER_USER}/ng-ui --no-cache" || FATAL "cannot build NG-UI docker image" - fi + echo "Pulling OSM docker images" + for module in MON POL NBI KEYSTONE RO LCM NG-UI LW-UI PLA osmclient; do + module_lower=${module,,} + if [ $module == "LW-UI" ]; then + if [ -n "$NGUI" ]; then + continue + else + module_lower="light-ui" + fi + fi + if [ $module == "NG-UI" -a ! -n "$NGUI" ]; then + continue + fi + if [ $module == "PLA" -a ! -n "$INSTALL_PLA" ]; then + continue + fi + module_tag="${OSM_DOCKER_TAG}" + if [ -n "${MODULE_DOCKER_TAG}" ] && echo $TO_REBUILD | grep -q $module ; then + module_tag="${MODULE_DOCKER_TAG}" + fi + echo "Pulling ${DOCKER_REGISTRY_URL}${DOCKER_USER}/${module_lower}:${module_tag} docker image" + sg docker -c "docker pull ${DOCKER_REGISTRY_URL}${DOCKER_USER}/${module_lower}:${module_tag}" || FATAL "cannot pull $module docker image" + done else - if [ -n "$PULL_IMAGES" ]; then - sg docker -c "docker pull ${DOCKER_USER}/light-ui:${OSM_DOCKER_TAG}" || FATAL "cannot pull light-ui docker image" - elif [ -z "$TO_REBUILD" ] || echo $TO_REBUILD | grep -q LW-UI ; then - git -C ${LWTEMPDIR} clone https://osm.etsi.org/gerrit/osm/LW-UI - git -C ${LWTEMPDIR}/LW-UI checkout ${COMMIT_ID} - sg docker -c "docker build ${LWTEMPDIR}/LW-UI -f ${LWTEMPDIR}/LW-UI/docker/Dockerfile -t ${DOCKER_USER}/light-ui --no-cache" || FATAL "cannot build LW-UI docker image" + _build_from=$COMMIT_ID + [ -z "$_build_from" ] && _build_from="latest" + echo "OSM Docker images generated from $_build_from" + + for module in MON POL NBI KEYSTONE RO LCM NG-UI LW-UI PLA; do + if [ -z "$TO_REBUILD" ] || echo $TO_REBUILD | grep -q ${module} ; then + module_lower=${module,,} + if [ $module == "LW-UI" ]; then + if [ -n "$NGUI" ]; then + continue + else + module_lower="light-ui" + fi + fi + if [ $module == "NG-UI" -a ! -n "$NGUI" ]; then + continue + fi + if [ $module == "PLA" -a ! -n "$INSTALL_PLA" ]; then + continue + fi + git -C ${LWTEMPDIR} clone https://osm.etsi.org/gerrit/osm/$module + git -C ${LWTEMPDIR}/${module} checkout ${COMMIT_ID} + sg docker -c "docker build ${LWTEMPDIR}/${module} -f ${LWTEMPDIR}/${module}/docker/Dockerfile -t ${DOCKER_USER}/${module_lower} --no-cache" || FATAL "cannot build ${module} docker image" + fi + done + if [ -z "$TO_REBUILD" ] || echo $TO_REBUILD | grep -q osmclient; then + BUILD_ARGS+=(--build-arg REPOSITORY="$REPOSITORY") + BUILD_ARGS+=(--build-arg RELEASE="$RELEASE") + BUILD_ARGS+=(--build-arg REPOSITORY_KEY="$REPOSITORY_KEY") + BUILD_ARGS+=(--build-arg REPOSITORY_BASE="$REPOSITORY_BASE") + sg docker -c "docker build -t ${DOCKER_USER}/osmclient ${BUILD_ARGS[@]} -f $OSM_DEVOPS/docker/osmclient ." fi - fi - - if [ -n "$PULL_IMAGES" ]; then - sg docker -c "docker pull ${DOCKER_USER}/osmclient:${OSM_DOCKER_TAG}" || FATAL "cannot pull osmclient docker image" - elif [ -z "$TO_REBUILD" ] || echo $TO_REBUILD | grep -q LW-osmclient; then - sg docker -c "docker build -t ${DOCKER_USER}/osmclient ${BUILD_ARGS[@]} -f $OSM_DEVOPS/docker/osmclient ." - fi - - if [ -z "$TO_REBUILD" ] || echo $TO_REBUILD | grep -q PROMETHEUS ; then - sg docker -c "docker pull google/cadvisor:${PROMETHEUS_CADVISOR_TAG}" || FATAL "cannot get prometheus cadvisor docker image" + echo "Finished generation of docker images" fi - echo "Finished generation of docker images" + echo "Finished pulling and generating docker images" } function cmp_overwrite() { @@ -710,9 +703,9 @@ function generate_docker_env_files() { fi if ! grep -Fq "OSMLCM_VCA_CACERT" $OSM_DOCKER_WORK_DIR/lcm.env; then - echo "OSMLCM_VCA_CACERT=${OSM_VCA_CACERT}" | $WORKDIR_SUDO tee -a $OSM_DOCKER_WORK_DIR/lcm.env + echo "OSMLCM_VCA_CACERT=${OSM_VCA_CACERT}" | $WORKDIR_SUDO tee -a $OSM_DOCKER_WORK_DIR/lcm.env else - $WORKDIR_SUDO sed -i "s|OSMLCM_VCA_CACERT.*|OSMLCM_VCA_CACERT=${OSM_VCA_CACERT}|g" $OSM_DOCKER_WORK_DIR/lcm.env + $WORKDIR_SUDO sed -i "s|OSMLCM_VCA_CACERT.*|OSMLCM_VCA_CACERT=${OSM_VCA_CACERT}|g" $OSM_DOCKER_WORK_DIR/lcm.env fi if [ -n "$OSM_VCA_APIPROXY" ]; then @@ -798,9 +791,9 @@ function generate_docker_env_files() { fi if ! grep -Fq "OSMMON_VCA_CACERT" $OSM_DOCKER_WORK_DIR/mon.env; then - echo "OSMMON_VCA_CACERT=${OSM_VCA_CACERT}" | $WORKDIR_SUDO tee -a $OSM_DOCKER_WORK_DIR/mon.env + echo "OSMMON_VCA_CACERT=${OSM_VCA_CACERT}" | $WORKDIR_SUDO tee -a $OSM_DOCKER_WORK_DIR/mon.env else - $WORKDIR_SUDO sed -i "s|OSMMON_VCA_CACERT.*|OSMMON_VCA_CACERT=${OSM_VCA_CACERT}|g" $OSM_DOCKER_WORK_DIR/mon.env + $WORKDIR_SUDO sed -i "s|OSMMON_VCA_CACERT.*|OSMMON_VCA_CACERT=${OSM_VCA_CACERT}|g" $OSM_DOCKER_WORK_DIR/mon.env fi @@ -818,7 +811,7 @@ function generate_docker_env_files() { } function generate_osmclient_script () { - echo "docker run -ti --network net${OSM_STACK_NAME} ${DOCKER_USER}/osmclient:${OSM_DOCKER_TAG}" | $WORKDIR_SUDO tee $OSM_DOCKER_WORK_DIR/osm + echo "docker run -ti --network net${OSM_STACK_NAME} ${DOCKER_REGISTRY_URL}${DOCKER_USER}/osmclient:${OSM_DOCKER_TAG}" | $WORKDIR_SUDO tee $OSM_DOCKER_WORK_DIR/osm $WORKDIR_SUDO chmod +x "$OSM_DOCKER_WORK_DIR/osm" echo "osmclient sidecar container can be found at: $OSM_DOCKER_WORK_DIR/osm" } @@ -974,12 +967,41 @@ function install_helm() { } function parse_yaml() { - osm_services="nbi lcm ro pol mon light-ui ng-ui keystone" TAG=$1 - for osm in $osm_services; do - $WORKDIR_SUDO sed -i "s/opensourcemano\/$osm:.*/$DOCKER_USER\/$osm:$TAG/g" $OSM_K8S_WORK_DIR/$osm.yaml + shift + services=$@ + for module in $services; do + if [ "$module" == "pla" ]; then + if [ -n "$INSTALL_PLA" ]; then + echo "Updating K8s manifest file from opensourcemano\/${module}:.* to ${DOCKER_REGISTRY_URL}${DOCKER_USER}\/${module}:${TAG}" + $WORKDIR_SUDO sed -i "s/opensourcemano\/pla:.*/${DOCKER_REGISTRY_URL}${DOCKER_USER}\/\/pla:${OSM_DOCKER_TAG}/g" ${OSM_DOCKER_WORK_DIR}/osm_pla/pla.yaml + fi + else + echo "Updating K8s manifest file from opensourcemano\/${module}:.* to ${DOCKER_REGISTRY_URL}${DOCKER_USER}\/${module}:${TAG}" + $WORKDIR_SUDO sed -i "s/opensourcemano\/${module}:.*/${DOCKER_REGISTRY_URL}${DOCKER_USER}\/${module}:${TAG}/g" ${OSM_K8S_WORK_DIR}/${module}.yaml + fi + done +} + +function update_manifest_files() { + osm_services="nbi lcm ro pol mon light-ui ng-ui keystone pla" + list_of_services="" + for module in $osm_services; do + module_upper="${module^^}" + if [ "$module_upper" == "LIGHT-UI" ]; then + module_upper="LW-UI" + fi + if ! echo $TO_REBUILD | grep -q $module_upper ; then + list_of_services="$list_of_services $module" + fi done - $WORKDIR_SUDO sed -i "s/opensourcemano\/pla:.*/$DOCKER_USER\/\/pla:$OSM_DOCKER_TAG/g" $OSM_DOCKER_WORK_DIR/osm_pla/pla.yaml + list_of_services_to_rebuild=$(echo ${TO_REBUILD,,} |sed "s/lw-ui/light-ui/g") + if [ ! "$OSM_DOCKER_TAG" == "8" ]; then + parse_yaml $OSM_DOCKER_TAG $list_of_services + fi + if [ -n "$MODULE_DOCKER_TAG" ]; then + parse_yaml $MODULE_DOCKER_TAG $list_of_services_to_rebuild + fi } function namespace_vol() { @@ -1322,7 +1344,7 @@ EOF if [ -n "$KUBERNETES" ]; then deploy_charmed_services kube_secrets - [ ! $OSM_DOCKER_TAG == "8" ] && parse_yaml $OSM_DOCKER_TAG + update_manifest_files namespace_vol deploy_osm_services if [ -n "$INSTALL_PLA"]; then @@ -1491,6 +1513,8 @@ function dump_vars(){ echo "PULL_IMAGES=$PULL_IMAGES" echo "KUBERNETES=$KUBERNETES" echo "NGUI=$NGUI" + echo "DOCKER_REGISTRY_URL=$DOCKER_REGISTRY_URL" + echo "DOCKER_PROXY_URL=$DOCKER_PROXY_URL" echo "SHOWOPTS=$SHOWOPTS" echo "Install from specific refspec (-b): $COMMIT_ID" } @@ -1574,8 +1598,11 @@ ELASTIC_CURATOR_VERSION=5.5.4 POD_NETWORK_CIDR=10.244.0.0/16 K8S_MANIFEST_DIR="/etc/kubernetes/manifests" RE_CHECK='^[a-z0-9]([-a-z0-9]*[a-z0-9])?$' +DOCKER_REGISTRY_URL= +DOCKER_PROXY_URL= +MODULE_DOCKER_TAG= -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 +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:d:p:T:-: hy" o; do case "${o}" in b) COMMIT_ID=${OPTARG} @@ -1632,11 +1659,14 @@ 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 ;; m) [ "${OPTARG}" == "LW-UI" ] && TO_REBUILD="$TO_REBUILD LW-UI" && continue + [ "${OPTARG}" == "NG-UI" ] && TO_REBUILD="$TO_REBUILD NG-UI" && continue [ "${OPTARG}" == "NBI" ] && TO_REBUILD="$TO_REBUILD NBI" && continue [ "${OPTARG}" == "LCM" ] && TO_REBUILD="$TO_REBUILD LCM" && continue [ "${OPTARG}" == "RO" ] && TO_REBUILD="$TO_REBUILD RO" && continue [ "${OPTARG}" == "MON" ] && TO_REBUILD="$TO_REBUILD MON" && continue [ "${OPTARG}" == "POL" ] && TO_REBUILD="$TO_REBUILD POL" && continue + [ "${OPTARG}" == "PLA" ] && TO_REBUILD="$TO_REBUILD PLA" && continue + [ "${OPTARG}" == "osmclient" ] && TO_REBUILD="$TO_REBUILD osmclient" && continue [ "${OPTARG}" == "KAFKA" ] && TO_REBUILD="$TO_REBUILD KAFKA" && continue [ "${OPTARG}" == "MONGO" ] && TO_REBUILD="$TO_REBUILD MONGO" && continue [ "${OPTARG}" == "PROMETHEUS" ] && TO_REBUILD="$TO_REBUILD PROMETHEUS" && continue @@ -1644,7 +1674,6 @@ 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}" == "KEYSTONE-DB" ] && TO_REBUILD="$TO_REBUILD KEYSTONE-DB" && continue [ "${OPTARG}" == "GRAFANA" ] && TO_REBUILD="$TO_REBUILD GRAFANA" && continue [ "${OPTARG}" == "NONE" ] && TO_REBUILD="$TO_REBUILD NONE" && continue - [ "${OPTARG}" == "PLA" ] && TO_REBUILD="$TO_REBUILD PLA" && continue ;; H) OSM_VCA_HOST="${OPTARG}" @@ -1682,6 +1711,15 @@ 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 K) CONTROLLER_NAME="${OPTARG}" ;; + d) + DOCKER_REGISTRY_URL="${OPTARG}" + ;; + p) + DOCKER_PROXY_URL="${OPTARG}" + ;; + T) + MODULE_DOCKER_TAG="${OPTARG}" + ;; -) [ "${OPTARG}" == "help" ] && usage && exit 0 [ "${OPTARG}" == "source" ] && INSTALL_FROM_SOURCE="y" && PULL_IMAGES="" && continue diff --git a/installers/install_osm.sh b/installers/install_osm.sh index d5df8b12..1d5affab 100755 --- a/installers/install_osm.sh +++ b/installers/install_osm.sh @@ -21,6 +21,8 @@ function usage(){ echo -e "usage: $0 [OPTIONS]" echo -e "Install OSM from binaries or source code (by default, from binaries)" echo -e " OPTIONS" + echo -e " -h / --help: print this help" + echo -e " -y: do not prompt for confirmation, assumes yes" echo -e " -r : use specified repository name for osm packages" echo -e " -R : use specified release for osm binaries (deb packages, lxd images, ...)" echo -e " -u : use specified repository url for osm packages" @@ -51,6 +53,8 @@ function usage(){ echo -e " -l: LXD cloud yaml file" echo -e " -L: LXD credentials yaml file" echo -e " -K: Specifies the name of the controller to use - The controller must be already bootstrapped" + echo -e " -d use docker registry URL instead of dockerhub" + echo -e " -p set docker proxy URL as part of docker CE configuration" echo -e " --nolxd: do not install and configure LXD, allowing unattended installations (assumes LXD is already installed and confifured)" echo -e " --nodocker: do not install docker, do not initialize a swarm (assumes docker is already installed and a swarm has been initialized)" echo -e " --nojuju: do not juju, assumes already installed" @@ -64,8 +68,6 @@ function usage(){ echo -e " --k8s_monitor: install the OSM kubernetes monitoring with prometheus and grafana" echo -e " --volume: create a VM volume when installing to OpenStack" echo -e " --showopts: print chosen options and exit (only for debugging)" - echo -e " -y: do not prompt for confirmation, assumes yes" - echo -e " -h / --help: print this help" echo -e " --charmed: Deploy and operate OSM with Charms on k8s" echo -e " [--bundle ]: Specify with which bundle to deploy OSM with charms (--charmed option)" echo -e " [--k8s ]: Specify with which kubernetes to deploy OSM with charms (--charmed option)" @@ -112,7 +114,7 @@ if [ $? -eq 0 ]; then fi } -while getopts ":b:r:c:n:k:u:R:l:L:K:p:D:o:O:m:N:H:S:s:w:t:U:P:A:-: hy" o; do +while getopts ":b:r:c:n:k:u:R:l:L:K:p:D:o:O:m:N:H:S:s:w:t:U:P:A:d:p:-: hy" o; do case "${o}" in r) REPOSITORY="${OPTARG}" diff --git a/jenkins/ci-pipelines/ci_stage_3.groovy b/jenkins/ci-pipelines/ci_stage_3.groovy index 6b57f153..f851fc0a 100644 --- a/jenkins/ci-pipelines/ci_stage_3.groovy +++ b/jenkins/ci-pipelines/ci_stage_3.groovy @@ -47,7 +47,7 @@ properties([ string(defaultValue: '/home/jenkins/hive/robot-systest.cfg', description: '', name: 'ROBOT_VIM'), string(defaultValue: '/home/jenkins/hive/kubeconfig.yaml', description: '', name: 'KUBECONFIG'), string(defaultValue: '/home/jenkins/hive/clouds.yaml', description: '', name: 'CLOUDS'), - string(defaultValue: 'Charmed', description: '', name: 'INSTALLER'), + string(defaultValue: 'Default', description: '', name: 'INSTALLER'), ]) ]) @@ -124,7 +124,18 @@ def archive_logs(remote) { done ''' } else { - // collect logs from k8s based installer... + sshCommand remote: remote, command: ''' + for deployment in `kubectl -n osm get deployments | grep -v operator | grep -v NAME| awk '{print $1}'`; do + echo "Extracting log for $deployment" + kubectl -n osm logs deployments/$deployment --all-containers 2>&1 > logs/$deployment.log + done + ''' + sshCommand remote: remote, command: ''' + for statefulset in `kubectl -n osm get statefulsets | grep -v operator | grep -v NAME| awk '{print $1}'`; do + echo "Extracting log for $statefulset" + kubectl -n osm logs statefulsets/$statefulset --all-containers 2>&1 > logs/$statefulset.log + done + ''' } sh "rm -rf logs" @@ -148,6 +159,7 @@ def get_value(key, output) { node("${params.NODE}") { INTERNAL_DOCKER_REGISTRY = 'osm.etsi.org:5050/devops/cicd/' + INTERNAL_DOCKER_PROXY = 'http://172.21.1.1:5000' SSH_KEY = '~/hive/cicd_rsa' sh 'env' @@ -407,10 +419,22 @@ node("${params.NODE}") { prometheusPort = 80 osmHostname = "nbi."+IP_ADDRESS+".xip.io:443" } else { - // Run -k8s installer here - // Update to use 172.21.1.1 as the dockerhub proxy - // Specify registry to use for installer - // set osmHostname, prometheusHostname, prometheusPort as needed + // Run -k8s installer here specifying internal docker registry and docker proxy + withCredentials([[$class: 'UsernamePasswordMultiBinding', credentialsId: 'gitlab-registry', + usernameVariable: 'USERNAME', passwordVariable: 'PASSWORD']]) { + sshCommand remote: remote, command: """ + ./install_osm.sh -y \ + ${repo_base_url} \ + ${repo_key_name} \ + ${release} -r unstable \ + -d ${USERNAME}:${PASSWORD}@${INTERNAL_DOCKER_REGISTRY} \ + -p ${INTERNAL_DOCKER_PROXY} \ + -t ${container_name} + """ + } + prometheusHostname = IP_ADDRESS + prometheusPort = 9091 + osmHostname = IP_ADDRESS } } }