From: David Garcia Date: Wed, 20 May 2020 16:48:35 +0000 (+0200) Subject: Fix bug 1072: Expose juju controller using metallb X-Git-Tag: v7.1.0rc2~1 X-Git-Url: https://osm.etsi.org/gitweb/?a=commitdiff_plain;h=4298d1447275684a7651e8c63e67326dfaaa4c7a;p=osm%2Fdevops.git Fix bug 1072: Expose juju controller using metallb Change-Id: Iaac170c3a4d163ea07a595b15141481bb11d9c3a Signed-off-by: David Garcia --- diff --git a/installers/charmed_install.sh b/installers/charmed_install.sh index 40da2c2d..dad9f481 100755 --- a/installers/charmed_install.sh +++ b/installers/charmed_install.sh @@ -46,10 +46,11 @@ function bootstrap_k8s_lxd(){ cat $KUBECFG | juju add-k8s $K8S_CLOUD_NAME $ADD_K8S_OPTS [ -v BOOTSTRAP_NEEDED ] && juju bootstrap $K8S_CLOUD_NAME $CONTROLLER_NAME else + sg microk8s -c "echo ${DEFAULT_IP}-${DEFAULT_IP} | microk8s.enable metallb" sg microk8s -c "microk8s.enable storage dns" [ ! -v BOOTSTRAP_NEEDED ] && sg microk8s -c "microk8s.config" | juju add-k8s $K8S_CLOUD_NAME $ADD_K8S_OPTS - [ -v BOOTSTRAP_NEEDED ] && sg microk8s -c "juju bootstrap microk8s $CONTROLLER_NAME" && K8S_CLOUD_NAME=microk8s + [ -v BOOTSTRAP_NEEDED ] && sg microk8s -c "juju bootstrap microk8s $CONTROLLER_NAME --config controller-service-type=loadbalancer" && K8S_CLOUD_NAME=microk8s fi if [ -v LXD_CLOUD ]; then @@ -222,24 +223,6 @@ function install_osmclient() { sudo snap alias osmclient.osm osm } -function create_iptables() { - check_install_iptables_persistent - - if ! sudo iptables -t nat -C PREROUTING -p tcp -m tcp -d $DEFAULT_IP --dport 17070 -j DNAT --to-destination $OSM_VCA_HOST; then - sudo iptables -t nat -A PREROUTING -p tcp -m tcp -d $DEFAULT_IP --dport 17070 -j DNAT --to-destination $OSM_VCA_HOST - sudo netfilter-persistent save - fi -} - -function check_install_iptables_persistent(){ - echo -e "\nChecking required packages: iptables-persistent" - if ! dpkg -l iptables-persistent &>/dev/null; then - echo -e " Not installed.\nInstalling iptables-persistent requires root privileges" - echo iptables-persistent iptables-persistent/autosave_v4 boolean true | sudo debconf-set-selections - echo iptables-persistent iptables-persistent/autosave_v6 boolean true | sudo debconf-set-selections - sudo apt-get -yq install iptables-persistent - fi -} function install_microstack() { sudo snap install microstack --classic --beta @@ -276,9 +259,9 @@ DEFAULT_IP=`ip -o -4 a |grep ${DEFAULT_IF}|awk '{split($4,a,"/"); print a[1]}'` check_arguments $@ mkdir -p ~/.osm install_snaps +sleep 5 bootstrap_k8s_lxd deploy_charmed_osm -[ ! -v CONTROLLER ] && create_iptables install_osmclient if [ -v MICROSTACK ]; then install_microstack diff --git a/installers/charmed_uninstall.sh b/installers/charmed_uninstall.sh index 6cee999f..3242446f 100755 --- a/installers/charmed_uninstall.sh +++ b/installers/charmed_uninstall.sh @@ -12,28 +12,9 @@ # See the License for the specific language governing permissions and # limitations under the License. # -function remove_iptables() { - stack=$1 - if [ -z "$OSM_VCA_HOST" ]; then - OSM_VCA_HOST=`sg lxd -c "juju show-controller controller"|grep api-endpoints|awk -F\' '{print $2}'|awk -F\: '{print $1}'` - [ -z "$OSM_VCA_HOST" ] && FATAL "Cannot obtain juju controller IP address" - fi - if [ -z "$DEFAULT_IP" ]; then - DEFAULT_IF=`route -n |awk '$1~/^0.0.0.0/ {print $8}'` - [ -z "$DEFAULT_IF" ] && FATAL "Not possible to determine the interface with the default route 0.0.0.0" - DEFAULT_IP=`ip -o -4 a |grep ${DEFAULT_IF}|awk '{split($4,a,"/"); print a[1]}'` - [ -z "$DEFAULT_IP" ] && FATAL "Not possible to determine the IP address of the interface with the default route" - fi - if sudo iptables -t nat -C PREROUTING -p tcp -m tcp -d $DEFAULT_IP --dport 17070 -j DNAT --to-destination $OSM_VCA_HOST; then - sudo iptables -t nat -D PREROUTING -p tcp -m tcp -d $DEFAULT_IP --dport 17070 -j DNAT --to-destination $OSM_VCA_HOST - sudo netfilter-persistent save - fi -} - -remove_iptables -juju destroy-model osm-on-k8s --destroy-storage +juju destroy-model osm --destroy-storage juju destroy-model test --destroy-storage sudo snap unalias osm sudo snap remove osmclient