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
--microstack) MICROSTACK=y ;;
--ha) BUNDLE="cs:osm-ha" ;;
--tag) TAG="$2" ;;
+ --registry) REGISTRY_INFO="$2" ;;
esac
shift
done
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
}
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
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
}
function generate_images_overlay(){
+ if [ ! -z "$REGISTRY_USERNAME" ] ; then
+ REGISTRY_CREDENTIALS=$(cat <<EOF
+
+ image_username: $REGISTRY_USERNAME
+ image_password: $REGISTRY_PASSWORD
+EOF
+ );
+fi
+
cat << EOF > /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
}
echo -e " [--lxd-cred <yaml path>]: 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)"
}
[ "${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