From: beierlm Date: Thu, 2 Jul 2020 18:21:09 +0000 (-0400) Subject: Charmed Install Updates from v7.0 X-Git-Tag: v8.0.0rc2~7 X-Git-Url: https://osm.etsi.org/gitweb/?a=commitdiff_plain;h=dfd428878a1fd20d24080e97213d0a70d98792bd;p=osm%2Fdevops.git Charmed Install Updates from v7.0 Removal of iptables manipulation from charmed installer Expose juju controller using metallb Pin version of juju Change-Id: I3853dfe1d3b264311bed1f3a805397a9197b10bc Signed-off-by: beierlm (cherry picked from commit 3749e31006f1e6a84533d6a2b616b22f0220d822) --- diff --git a/docker/LCM/Dockerfile b/docker/LCM/Dockerfile index d9da408b..301582b7 100644 --- a/docker/LCM/Dockerfile +++ b/docker/LCM/Dockerfile @@ -47,7 +47,7 @@ RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y git make && python3 -m pip install -U pip \ && python3 -m pip install -U aiokafka lxml six enum34 \ && python3 -m pip install requests \ - && python3 -m pip install -U juju \ + && python3 -m pip install -U juju==2.8.1 \ && rm -rf /var/lib/apt/lists/* # RUN git clone https://osm.etsi.org/gerrit/osm/N2VC.git \ diff --git a/docker/MON/Dockerfile b/docker/MON/Dockerfile index 95050342..22451fcc 100644 --- a/docker/MON/Dockerfile +++ b/docker/MON/Dockerfile @@ -61,7 +61,7 @@ RUN curl ${REPOSITORY_BASE}/${RELEASE}/${REPOSITORY_KEY} | apt-key add - \ python3-n2vc${N2VC_VERSION} -RUN python3 -m pip install -U juju +RUN python3 -m pip install -U "juju==2.8.1" COPY scripts/ scripts/ diff --git a/installers/charmed_install.sh b/installers/charmed_install.sh index d2156084..3ebf1795 100755 --- a/installers/charmed_install.sh +++ b/installers/charmed_install.sh @@ -16,6 +16,7 @@ # set -eux K8S_CLOUD_NAME="k8s-cloud" +KUBECTL="microk8s.kubectl" IMAGES_OVERLAY_FILE=~/.osm/images-overlay.yaml function check_arguments(){ while [ $# -gt 0 ] ; do @@ -45,8 +46,9 @@ function bootstrap_k8s_lxd(){ if [ -v KUBECFG ]; then cat $KUBECFG | juju add-k8s $K8S_CLOUD_NAME $ADD_K8S_OPTS - [ -v BOOTSTRAP_NEEDED ] && juju bootstrap $K8S_CLOUD_NAME $CONTROLLER_NAME + [ -v BOOTSTRAP_NEEDED ] && juju bootstrap $K8S_CLOUD_NAME $CONTROLLER_NAME --config controller-service-type=loadbalancer else + sg microk8s -c "echo ${DEFAULT_IP}-${DEFAULT_IP} | microk8s.enable metallb" sg microk8s -c "microk8s.enable storage dns" while true do @@ -58,7 +60,7 @@ function bootstrap_k8s_lxd(){ done [ ! -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 @@ -168,12 +170,12 @@ function create_overlay() { local HOME=/home/$USER local vca_user=$(cat $HOME/.local/share/juju/accounts.yaml | yq --arg CONTROLLER_NAME $CONTROLLER_NAME '.controllers[$CONTROLLER_NAME].user') local vca_password=$(cat $HOME/.local/share/juju/accounts.yaml | yq --arg CONTROLLER_NAME $CONTROLLER_NAME '.controllers[$CONTROLLER_NAME].password') - local vca_host=$(cat $HOME/.local/share/juju/controllers.yaml | yq --arg CONTROLLER_NAME $CONTROLLER_NAME '.controllers[$CONTROLLER_NAME]["api-endpoints"][0]' | cut -d ":" -f 1 | cut -d "\"" -f 2) - local vca_port=$(cat $HOME/.local/share/juju/controllers.yaml | yq --arg CONTROLLER_NAME $CONTROLLER_NAME '.controllers[$CONTROLLER_NAME]["api-endpoints"][0]' | cut -d ":" -f 2 | cut -d "\"" -f 1) + local vca_host=$(cat $HOME/.local/share/juju/controllers.yaml | yq --arg CONTROLLER_NAME $CONTROLLER_NAME '.controllers[$CONTROLLER_NAME]["api-endpoints"][0]' --raw-output | cut -d ":" -f 1) + local vca_port=$(cat $HOME/.local/share/juju/controllers.yaml | yq --arg CONTROLLER_NAME $CONTROLLER_NAME '.controllers[$CONTROLLER_NAME]["api-endpoints"][0]' --raw-output | cut -d ":" -f 2) local vca_pubkey=\"$(cat $HOME/.local/share/juju/ssh/juju_id_rsa.pub)\" local vca_cloud="lxd-cloud" # Get the VCA Certificate - local vca_cacert=$(cat $HOME/.local/share/juju/controllers.yaml | yq --arg CONTROLLER_NAME $CONTROLLER_NAME '.controllers[$CONTROLLER_NAME]["ca-cert"]' | base64 | tr -d \\n) + local vca_cacert=$(cat $HOME/.local/share/juju/controllers.yaml | yq --arg CONTROLLER_NAME $CONTROLLER_NAME '.controllers[$CONTROLLER_NAME]["ca-cert"]' --raw-output | base64 | tr -d \\n) # Calculate the default route of this machine local DEFAULT_IF=`ip route list match 0.0.0.0 | awk '{print $5}'` @@ -235,24 +237,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 @@ -289,9 +273,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 a3101774..ef2b293c 100755 --- a/installers/charmed_uninstall.sh +++ b/installers/charmed_uninstall.sh @@ -12,27 +12,8 @@ # 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 --destroy-storage -y juju destroy-model test --destroy-storage -y sudo snap unalias osm