X-Git-Url: https://osm.etsi.org/gitweb/?a=blobdiff_plain;f=installers%2Fcharmed_install.sh;h=0f895cd6c9d82eb376d0823133a359b14e616dc4;hb=499b442f67119589220a1ff144e3b26a9b7714ed;hp=a011ef1a4e0016925de57ad4ea88d93d058aef6f;hpb=3bc9b393dbf37b5adaeb4cd8e7590610057b04ce;p=osm%2Fdevops.git diff --git a/installers/charmed_install.sh b/installers/charmed_install.sh index a011ef1a..0f895cd6 100755 --- a/installers/charmed_install.sh +++ b/installers/charmed_install.sh @@ -15,18 +15,26 @@ # set -eux -JUJU_AGENT_VERSION=2.8.9 +LXD_VERSION=4.0 +JUJU_VERSION=2.9 +JUJU_AGENT_VERSION=2.9.17 K8S_CLOUD_NAME="k8s-cloud" KUBECTL="microk8s.kubectl" -MICROK8S_VERSION=1.19 -OSMCLIENT_VERSION=9.0 +MICROK8S_VERSION=1.20 +OSMCLIENT_VERSION=10.0 IMAGES_OVERLAY_FILE=~/.osm/images-overlay.yaml PATH=/snap/bin:${PATH} MODEL_NAME=osm -OSM_BUNDLE=cs:osm-66 -OSM_HA_BUNDLE=cs:osm-ha-51 +# Latest bundles using old mongodb-k8s +# OSM_BUNDLE=cs:osm-68 +# OSM_HA_BUNDLE=cs:osm-ha-54 +# The charm store does not support referencing charms from CharmHub, +# therefore we will point to the local bundles until we migrate all +# charms to CharmHub. +OSM_BUNDLE=/usr/share/osm-devops/installers/charm/bundles/osm/bundle.yaml +OSM_HA_BUNDLE=/usr/share/osm-devops/installers/charm/bundles/osm-ha/bundle.yaml TAG=testing-daily function check_arguments(){ @@ -71,7 +79,7 @@ function install_snaps(){ export KUBECONFIG=${KUBECFG} KUBEGRP=$(id -g -n) fi - sudo snap install juju --classic --channel=2.8/stable + sudo snap install juju --classic --channel=$JUJU_VERSION/stable } function bootstrap_k8s_lxd(){ @@ -151,7 +159,7 @@ EOF sudo sysctl --system # Install LXD snap sudo apt-get remove --purge -y liblxc1 lxc-common lxcfs lxd lxd-client - sudo snap install lxd + sudo snap install lxd --channel $LXD_VERSION/stable # Configure LXD sudo usermod -a -G lxd `whoami` cat /usr/share/osm-devops/installers/lxd-preseed.conf | sed 's/^config: {}/config:\n core.https_address: '$LXDENDPOINT':8443/' | sg lxd -c "lxd init --preseed" @@ -278,6 +286,10 @@ function deploy_charmed_osm(){ echo "Waiting for deployment to finish..." check_osm_deployed + grafana_leader=`juju status -m $MODEL_NAME grafana | grep "*" | cut -d "*" -f 1` + grafana_admin_password=`juju run -m $MODEL_NAME --unit $grafana_leader "echo \\$GF_SECURITY_ADMIN_PASSWORD"` + juju config -m $MODEL_NAME mon grafana_password=$grafana_admin_password + check_osm_deployed echo "OSM with charms deployed" } @@ -410,36 +422,78 @@ function add_local_k8scluster() { } function install_microstack() { - sudo snap install microstack --classic --beta - sudo microstack.init --auto - wget https://cloud-images.ubuntu.com/releases/16.04/release/ubuntu-16.04-server-cloudimg-amd64-disk1.img -P ~/.osm/ - microstack.openstack image create \ - --public \ - --disk-format qcow2 \ - --container-format bare \ - --file ~/.osm/ubuntu-16.04-server-cloudimg-amd64-disk1.img \ - ubuntu1604 - ssh-keygen -t rsa -N "" -f ~/.ssh/microstack - microstack.openstack keypair create --public-key ~/.ssh/microstack.pub microstack - export OSM_HOSTNAME=`juju status -m $MODEL_NAME --format json | jq -rc '.applications."nbi".address'` - osm vim-create --name microstack-site \ - --user admin \ - --password keystone \ - --auth_url http://10.20.20.1:5000/v3 \ - --tenant admin \ - --account_type openstack \ - --config='{security_groups: default, - keypair: microstack, - project_name: admin, - user_domain_name: default, - region_name: microstack, - insecure: True, - availability_zone: nova, - version: 3}' + + sudo snap install microstack --beta --devmode + + CHECK=$(microstack.openstack server list) + if [ $? -ne 0 ] ; then + if [[ $CHECK == *"not initialized"* ]]; then + echo "Setting MicroStack dashboard to listen to port 8080" + sudo snap set microstack config.network.ports.dashboard=8080 + echo "Initializing MicroStack. This can take several minutes" + sudo microstack.init --auto --control + fi + fi + + sudo snap alias microstack.openstack openstack + + echo "Updating default security group in MicroStack to allow all access" + + for i in $(microstack.openstack security group list | awk '/default/{ print $2 }'); do + for PROTO in icmp tcp udp ; do + echo " $PROTO ingress" + CHECK=$(microstack.openstack security group rule create $i --protocol $PROTO --remote-ip 0.0.0.0/0 2>&1) + if [ $? -ne 0 ] ; then + if [[ $CHECK != *"409"* ]]; then + echo "Error creating ingress rule for $PROTO" + echo $CHECK + fi + fi + done + done + + microstack.openstack network show osm-ext &>/dev/null + if [ $? -ne 0 ]; then + echo "Creating osm-ext network with router to bridge to MicroStack external network" + microstack.openstack network create --enable --no-share osm-ext + microstack.openstack subnet create osm-ext-subnet --network osm-ext --dns-nameserver 8.8.8.8 \ + --subnet-range 172.30.0.0/24 + microstack.openstack router create external-router + microstack.openstack router add subnet external-router osm-ext-subnet + microstack.openstack router set --external-gateway external external-router + fi + + microstack.openstack image list | grep ubuntu20.04 &> /dev/null + if [ $? -ne 0 ] ; then + echo "Fetching Ubuntu 20.04 image and upLoading to MicroStack" + wget -q -O- https://cloud-images.ubuntu.com/focal/current/focal-server-cloudimg-amd64.img \ + | microstack.openstack image create --public --container-format=bare \ + --disk-format=qcow2 ubuntu20.04 | grep status + fi + + if [ ! -f ~/.ssh/microstack ]; then + ssh-keygen -t rsa -N "" -f ~/.ssh/microstack + microstack.openstack keypair create --public-key ~/.ssh/microstack.pub microstack + fi + + echo "Creating VIM microstack-site in OSM" + . /var/snap/microstack/common/etc/microstack.rc + + osm vim-create \ + --name microstack-site \ + --user "$OS_USERNAME" \ + --password "$OS_PASSWORD" \ + --auth_url "$OS_AUTH_URL" \ + --tenant "$OS_USERNAME" \ + --account_type openstack \ + --config='{use_floating_ip: True, + insecure: True, + keypair: microstack, + management_network_name: osm-ext}' } -DEFAULT_IF=`ip route list match 0.0.0.0 | awk '{print $5}'` -DEFAULT_IP=`ip -o -4 a |grep ${DEFAULT_IF}|awk '{split($4,a,"/"); print a[1]}'` +DEFAULT_IF=`ip route list match 0.0.0.0 | awk '{print $5; exit}'` +DEFAULT_IP=`ip -o -4 a |grep ${DEFAULT_IF}|awk '{split($4,a,"/"); print a[1]; exit}'` check_arguments $@ mkdir -p ~/.osm @@ -458,7 +512,7 @@ if [ -v ONLY_VCA ]; then hostname=`cat /etc/hostname` echo "Use the following command to register the installed VCA to your OSM:" - echo -e " osm vca-add --endpoints $vca_host:$vca_port \ \n --user $vca_user \ \n --secret $vca_secret \ \n --cacert $vca_cacert \ \n --lxd-cloud lxd-cloud \ \n --lxd-credentials lxd-cloud \ \n --k8s-cloud microk8s \ \n --k8s-credentials microk8s\ \n $hostname-vca" + echo -e " osm vca-add --endpoints $vca_host:$vca_port \\\n --user $vca_user \\\n --secret $vca_secret \\\n --cacert $vca_cacert \\\n --lxd-cloud lxd-cloud \\\n --lxd-credentials lxd-cloud \\\n --k8s-cloud microk8s \\\n --k8s-credentials microk8s\\\n $hostname-vca" else deploy_charmed_osm install_osmclient