| Dominik Fleischmann | 5e4a751 | 2020-03-06 14:05:06 +0100 | [diff] [blame] | 1 | #! /bin/bash |
| 2 | # |
| 3 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | # you may not use this file except in compliance with the License. |
| 5 | # You may obtain a copy of the License at |
| 6 | # |
| 7 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | # |
| 9 | # Unless required by applicable law or agreed to in writing, software |
| 10 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | # See the License for the specific language governing permissions and |
| 13 | # limitations under the License. |
| 14 | # |
| David Garcia | 4237521 | 2020-04-27 19:07:49 +0200 | [diff] [blame] | 15 | |
| 16 | # set -eux |
| 17 | |
| garciadeblas | e38e8b1 | 2022-09-27 16:49:31 +0200 | [diff] [blame] | 18 | LXD_VERSION=5.0 |
| David Garcia | d68e0b4 | 2021-06-28 16:50:42 +0200 | [diff] [blame] | 19 | JUJU_VERSION=2.9 |
| Mark Beierl | 1903805 | 2022-10-13 09:03:04 -0400 | [diff] [blame] | 20 | JUJU_AGENT_VERSION=2.9.34 |
| David Garcia | 4237521 | 2020-04-27 19:07:49 +0200 | [diff] [blame] | 21 | K8S_CLOUD_NAME="k8s-cloud" |
| beierlm | 3749e31 | 2020-07-02 14:21:09 -0400 | [diff] [blame] | 22 | KUBECTL="microk8s.kubectl" |
| Patricia Reinoso | 57b89ae | 2023-03-14 16:06:32 +0000 | [diff] [blame] | 23 | MICROK8S_VERSION=1.26 |
| David Garcia | 53a09d8 | 2022-02-01 16:39:44 +0100 | [diff] [blame] | 24 | OSMCLIENT_VERSION=latest |
| David Garcia | 69388c2 | 2020-05-07 12:14:19 +0200 | [diff] [blame] | 25 | IMAGES_OVERLAY_FILE=~/.osm/images-overlay.yaml |
| aticig | 6eb3928 | 2022-02-24 00:34:52 +0300 | [diff] [blame] | 26 | PASSWORD_OVERLAY_FILE=~/.osm/password-overlay.yaml |
| beierlm | f2782c5 | 2020-11-05 17:04:05 -0500 | [diff] [blame] | 27 | PATH=/snap/bin:${PATH} |
| beierlm | ce7b460 | 2022-04-13 08:19:40 -0400 | [diff] [blame] | 28 | OSM_DEVOPS="$( cd "$( dirname "${BASH_SOURCE[0]}" )"/.. &> /dev/null && pwd )" |
| Patricia Reinoso | 58ac3a5 | 2022-09-01 15:18:13 +0200 | [diff] [blame] | 29 | INSTALL_PLA="" |
| 30 | PLA_OVERLAY_FILE=~/.osm/pla-overlay.yaml |
| 31 | |
| beierlm | ce7b460 | 2022-04-13 08:19:40 -0400 | [diff] [blame] | 32 | if [ -f ${OSM_DEVOPS}/common/all_funcs ] ; then |
| 33 | source ${OSM_DEVOPS}/common/all_funcs |
| 34 | else |
| 35 | function track(){ |
| 36 | true |
| 37 | } |
| 38 | function FATAL_TRACK(){ |
| 39 | exit 1 |
| 40 | } |
| 41 | fi |
| beierlm | f2782c5 | 2020-11-05 17:04:05 -0500 | [diff] [blame] | 42 | |
| David Garcia | ef349d9 | 2020-12-10 21:16:12 +0100 | [diff] [blame] | 43 | MODEL_NAME=osm |
| 44 | |
| David Garcia | 4a0db7c | 2022-02-21 11:48:11 +0100 | [diff] [blame] | 45 | OSM_BUNDLE=ch:osm |
| 46 | OSM_HA_BUNDLE=ch:osm-ha |
| aticig | abef99c | 2022-08-23 15:13:23 +0300 | [diff] [blame] | 47 | CHARMHUB_CHANNEL=latest/beta |
| David Garcia | 4a0db7c | 2022-02-21 11:48:11 +0100 | [diff] [blame] | 48 | unset TAG |
| David Garcia | ab11f84 | 2020-12-16 17:25:15 +0100 | [diff] [blame] | 49 | |
| Dominik Fleischmann | 5e4a751 | 2020-03-06 14:05:06 +0100 | [diff] [blame] | 50 | function check_arguments(){ |
| 51 | while [ $# -gt 0 ] ; do |
| David Garcia | 4237521 | 2020-04-27 19:07:49 +0200 | [diff] [blame] | 52 | case $1 in |
| 53 | --bundle) BUNDLE="$2" ;; |
| David Garcia | 4bd2bf0 | 2021-05-05 19:01:43 +0200 | [diff] [blame] | 54 | --overlay) OVERLAY="$2" ;; |
| Dominik Fleischmann | 7a97a4c | 2020-06-04 10:52:05 +0200 | [diff] [blame] | 55 | --k8s) KUBECFG="$2" ;; |
| 56 | --vca) CONTROLLER="$2" ;; |
| aticig | 5d19ac2 | 2022-05-06 13:46:22 +0300 | [diff] [blame] | 57 | --small-profile) INSTALL_NOLXD=y;; |
| Dominik Fleischmann | 7a97a4c | 2020-06-04 10:52:05 +0200 | [diff] [blame] | 58 | --lxd) LXD_CLOUD="$2" ;; |
| 59 | --lxd-cred) LXD_CREDENTIALS="$2" ;; |
| David Garcia | 69388c2 | 2020-05-07 12:14:19 +0200 | [diff] [blame] | 60 | --microstack) MICROSTACK=y ;; |
| David Garcia | ab11f84 | 2020-12-16 17:25:15 +0100 | [diff] [blame] | 61 | --ha) BUNDLE=$OSM_HA_BUNDLE ;; |
| David Garcia | 69388c2 | 2020-05-07 12:14:19 +0200 | [diff] [blame] | 62 | --tag) TAG="$2" ;; |
| beierlm | f2782c5 | 2020-11-05 17:04:05 -0500 | [diff] [blame] | 63 | --registry) REGISTRY_INFO="$2" ;; |
| David Garcia | 1bc7102 | 2021-05-03 18:27:18 +0200 | [diff] [blame] | 64 | --only-vca) ONLY_VCA=y ;; |
| Patricia Reinoso | 58ac3a5 | 2022-09-01 15:18:13 +0200 | [diff] [blame] | 65 | --pla) INSTALL_PLA=y ;; |
| David Garcia | 4237521 | 2020-04-27 19:07:49 +0200 | [diff] [blame] | 66 | esac |
| 67 | shift |
| Dominik Fleischmann | 5e4a751 | 2020-03-06 14:05:06 +0100 | [diff] [blame] | 68 | done |
| 69 | |
| David Garcia | 4237521 | 2020-04-27 19:07:49 +0200 | [diff] [blame] | 70 | # echo $BUNDLE $KUBECONFIG $LXDENDPOINT |
| Dominik Fleischmann | 5e4a751 | 2020-03-06 14:05:06 +0100 | [diff] [blame] | 71 | } |
| beierlm | a4a37f7 | 2020-06-26 12:55:01 -0400 | [diff] [blame] | 72 | |
| Dominik Fleischmann | 5e4a751 | 2020-03-06 14:05:06 +0100 | [diff] [blame] | 73 | function install_snaps(){ |
| beierlm | a4a37f7 | 2020-06-26 12:55:01 -0400 | [diff] [blame] | 74 | if [ ! -v KUBECFG ]; then |
| beierlm | ce7b460 | 2022-04-13 08:19:40 -0400 | [diff] [blame] | 75 | KUBEGRP="microk8s" |
| 76 | sudo snap install microk8s --classic --channel=${MICROK8S_VERSION}/stable || |
| 77 | FATAL_TRACK k8scluster "snap install microk8s ${MICROK8S_VERSION}/stable failed" |
| 78 | sudo usermod -a -G microk8s `whoami` |
| David Garcia | 9a59e3d | 2021-02-08 15:18:27 +0100 | [diff] [blame] | 79 | sudo cat /var/snap/microk8s/current/args/kube-apiserver | grep advertise-address || ( |
| David Garcia | 107010b | 2021-01-15 12:58:59 +0100 | [diff] [blame] | 80 | echo "--advertise-address $DEFAULT_IP" | sudo tee -a /var/snap/microk8s/current/args/kube-apiserver |
| beierlm | ce7b460 | 2022-04-13 08:19:40 -0400 | [diff] [blame] | 81 | sg ${KUBEGRP} -c microk8s.stop |
| 82 | sg ${KUBEGRP} -c microk8s.start |
| David Garcia | 107010b | 2021-01-15 12:58:59 +0100 | [diff] [blame] | 83 | ) |
| beierlm | a4a37f7 | 2020-06-26 12:55:01 -0400 | [diff] [blame] | 84 | mkdir -p ~/.kube |
| 85 | sudo chown -f -R `whoami` ~/.kube |
| beierlm | f2782c5 | 2020-11-05 17:04:05 -0500 | [diff] [blame] | 86 | sg ${KUBEGRP} -c "microk8s status --wait-ready" |
| beierlm | df6de3d | 2020-12-16 08:46:40 -0500 | [diff] [blame] | 87 | KUBECONFIG=~/.osm/microk8s-config.yaml |
| David Garcia | 107010b | 2021-01-15 12:58:59 +0100 | [diff] [blame] | 88 | sg ${KUBEGRP} -c "microk8s config" | tee ${KUBECONFIG} |
| beierlm | ce7b460 | 2022-04-13 08:19:40 -0400 | [diff] [blame] | 89 | track k8scluster k8scluster_ok |
| beierlm | a4a37f7 | 2020-06-26 12:55:01 -0400 | [diff] [blame] | 90 | else |
| 91 | KUBECTL="kubectl" |
| 92 | sudo snap install kubectl --classic |
| 93 | export KUBECONFIG=${KUBECFG} |
| 94 | KUBEGRP=$(id -g -n) |
| 95 | fi |
| beierlm | ce7b460 | 2022-04-13 08:19:40 -0400 | [diff] [blame] | 96 | sudo snap install juju --classic --channel=$JUJU_VERSION/stable || |
| 97 | FATAL_TRACK juju "snap install juju ${JUJU_VERSION}/stable failed" |
| 98 | track juju juju_ok |
| Dominik Fleischmann | 5e4a751 | 2020-03-06 14:05:06 +0100 | [diff] [blame] | 99 | } |
| 100 | |
| 101 | function bootstrap_k8s_lxd(){ |
| David Garcia | 4237521 | 2020-04-27 19:07:49 +0200 | [diff] [blame] | 102 | [ -v CONTROLLER ] && ADD_K8S_OPTS="--controller ${CONTROLLER}" && CONTROLLER_NAME=$CONTROLLER |
| beierlm | a4a37f7 | 2020-06-26 12:55:01 -0400 | [diff] [blame] | 103 | [ ! -v CONTROLLER ] && ADD_K8S_OPTS="--client" && BOOTSTRAP_NEEDED="yes" && CONTROLLER_NAME="osm-vca" |
| 104 | |
| 105 | if [ -v BOOTSTRAP_NEEDED ]; then |
| 106 | CONTROLLER_PRESENT=$(juju controllers 2>/dev/null| grep ${CONTROLLER_NAME} | wc -l) |
| 107 | if [ $CONTROLLER_PRESENT -ge 1 ]; then |
| 108 | cat << EOF |
| 109 | Threre is already a VCA present with the installer reserved name of "${CONTROLLER_NAME}". |
| 110 | You may either explicitly use this VCA with the "--vca ${CONTROLLER_NAME}" option, or remove it |
| 111 | using this command: |
| 112 | |
| 113 | juju destroy-controller --release-storage --destroy-all-models -y ${CONTROLLER_NAME} |
| 114 | |
| 115 | Please retry the installation once this conflict has been resolved. |
| 116 | EOF |
| beierlm | ce7b460 | 2022-04-13 08:19:40 -0400 | [diff] [blame] | 117 | FATAL_TRACK bootstrap_k8s "VCA already present" |
| beierlm | a4a37f7 | 2020-06-26 12:55:01 -0400 | [diff] [blame] | 118 | fi |
| beierlm | 9afb0ef | 2020-10-16 12:53:51 -0400 | [diff] [blame] | 119 | else |
| 120 | CONTROLLER_PRESENT=$(juju controllers 2>/dev/null| grep ${CONTROLLER_NAME} | wc -l) |
| 121 | if [ $CONTROLLER_PRESENT -le 0 ]; then |
| 122 | cat << EOF |
| 123 | Threre is no VCA present with the name "${CONTROLLER_NAME}". Please specify a VCA |
| 124 | that exists, or remove the --vca ${CONTROLLER_NAME} option. |
| 125 | |
| 126 | Please retry the installation with one of the solutions applied. |
| 127 | EOF |
| beierlm | ce7b460 | 2022-04-13 08:19:40 -0400 | [diff] [blame] | 128 | FATAL_TRACK bootstrap_k8s "Requested VCA not present" |
| beierlm | 9afb0ef | 2020-10-16 12:53:51 -0400 | [diff] [blame] | 129 | fi |
| beierlm | a4a37f7 | 2020-06-26 12:55:01 -0400 | [diff] [blame] | 130 | fi |
| David Garcia | 4237521 | 2020-04-27 19:07:49 +0200 | [diff] [blame] | 131 | |
| 132 | if [ -v KUBECFG ]; then |
| 133 | cat $KUBECFG | juju add-k8s $K8S_CLOUD_NAME $ADD_K8S_OPTS |
| beierlm | 2634cd3 | 2020-09-15 16:00:34 -0400 | [diff] [blame] | 134 | [ -v BOOTSTRAP_NEEDED ] && juju bootstrap $K8S_CLOUD_NAME $CONTROLLER_NAME \ |
| 135 | --config controller-service-type=loadbalancer \ |
| David Garcia | a137601 | 2020-10-19 15:42:42 +0200 | [diff] [blame] | 136 | --agent-version=$JUJU_AGENT_VERSION |
| Dominik Fleischmann | 5e4a751 | 2020-03-06 14:05:06 +0100 | [diff] [blame] | 137 | else |
| beierlm | a4a37f7 | 2020-06-26 12:55:01 -0400 | [diff] [blame] | 138 | sg ${KUBEGRP} -c "echo ${DEFAULT_IP}-${DEFAULT_IP} | microk8s.enable metallb" |
| beierlm | 9afb0ef | 2020-10-16 12:53:51 -0400 | [diff] [blame] | 139 | sg ${KUBEGRP} -c "microk8s.enable ingress" |
| Patricia Reinoso | 57b89ae | 2023-03-14 16:06:32 +0000 | [diff] [blame] | 140 | sg ${KUBEGRP} -c "microk8s.enable hostpath-storage dns" |
| beierlm | a4a37f7 | 2020-06-26 12:55:01 -0400 | [diff] [blame] | 141 | TIME_TO_WAIT=30 |
| 142 | start_time="$(date -u +%s)" |
| Dominik Fleischmann | c57296f | 2020-06-09 11:45:08 +0200 | [diff] [blame] | 143 | while true |
| 144 | do |
| beierlm | a4a37f7 | 2020-06-26 12:55:01 -0400 | [diff] [blame] | 145 | now="$(date -u +%s)" |
| 146 | if [[ $(( now - start_time )) -gt $TIME_TO_WAIT ]];then |
| 147 | echo "Microk8s storage failed to enable" |
| 148 | sg ${KUBEGRP} -c "microk8s.status" |
| beierlm | ce7b460 | 2022-04-13 08:19:40 -0400 | [diff] [blame] | 149 | FATAL_TRACK bootstrap_k8s "Microk8s storage failed to enable" |
| beierlm | a4a37f7 | 2020-06-26 12:55:01 -0400 | [diff] [blame] | 150 | fi |
| 151 | storage_status=`sg ${KUBEGRP} -c "microk8s.status -a storage"` |
| 152 | if [[ $storage_status == "enabled" ]]; then |
| Dominik Fleischmann | c57296f | 2020-06-09 11:45:08 +0200 | [diff] [blame] | 153 | break |
| 154 | fi |
| 155 | sleep 1 |
| 156 | done |
| David Garcia | 4237521 | 2020-04-27 19:07:49 +0200 | [diff] [blame] | 157 | |
| beierlm | a4a37f7 | 2020-06-26 12:55:01 -0400 | [diff] [blame] | 158 | [ ! -v BOOTSTRAP_NEEDED ] && sg ${KUBEGRP} -c "microk8s.config" | juju add-k8s $K8S_CLOUD_NAME $ADD_K8S_OPTS |
| beierlm | 2634cd3 | 2020-09-15 16:00:34 -0400 | [diff] [blame] | 159 | [ -v BOOTSTRAP_NEEDED ] && sg ${KUBEGRP} -c \ |
| David Garcia | a137601 | 2020-10-19 15:42:42 +0200 | [diff] [blame] | 160 | "juju bootstrap microk8s $CONTROLLER_NAME --config controller-service-type=loadbalancer --agent-version=$JUJU_AGENT_VERSION" \ |
| beierlm | 2634cd3 | 2020-09-15 16:00:34 -0400 | [diff] [blame] | 161 | && K8S_CLOUD_NAME=microk8s |
| Dominik Fleischmann | 5e4a751 | 2020-03-06 14:05:06 +0100 | [diff] [blame] | 162 | fi |
| beierlm | ce7b460 | 2022-04-13 08:19:40 -0400 | [diff] [blame] | 163 | track bootstrap_k8s bootstrap_k8s_ok |
| Dominik Fleischmann | 5e4a751 | 2020-03-06 14:05:06 +0100 | [diff] [blame] | 164 | |
| aticig | 5d19ac2 | 2022-05-06 13:46:22 +0300 | [diff] [blame] | 165 | if [ ! -v INSTALL_NOLXD ]; then |
| 166 | if [ -v LXD_CLOUD ]; then |
| 167 | if [ ! -v LXD_CREDENTIALS ]; then |
| 168 | echo "The installer needs the LXD server certificate if the LXD is external" |
| 169 | FATAL_TRACK bootstrap_lxd "No LXD certificate supplied" |
| 170 | fi |
| 171 | else |
| 172 | LXDENDPOINT=$DEFAULT_IP |
| 173 | LXD_CLOUD=~/.osm/lxd-cloud.yaml |
| 174 | LXD_CREDENTIALS=~/.osm/lxd-credentials.yaml |
| 175 | # Apply sysctl production values for optimal performance |
| 176 | sudo cp /usr/share/osm-devops/installers/60-lxd-production.conf /etc/sysctl.d/60-lxd-production.conf |
| 177 | sudo sysctl --system |
| 178 | # Install LXD snap |
| 179 | sudo apt-get remove --purge -y liblxc1 lxc-common lxcfs lxd lxd-client |
| garciadeblas | e38e8b1 | 2022-09-27 16:49:31 +0200 | [diff] [blame] | 180 | snap info lxd | grep installed > /dev/null |
| 181 | if [ $? -eq 0 ]; then |
| 182 | sudo snap refresh lxd --channel $LXD_VERSION/stable |
| 183 | else |
| 184 | sudo snap install lxd --channel $LXD_VERSION/stable |
| 185 | fi |
| aticig | 5d19ac2 | 2022-05-06 13:46:22 +0300 | [diff] [blame] | 186 | # Configure LXD |
| 187 | sudo usermod -a -G lxd `whoami` |
| 188 | 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" |
| 189 | sg lxd -c "lxd waitready" |
| 190 | DEFAULT_MTU=$(ip addr show $DEFAULT_IF | perl -ne 'if (/mtu\s(\d+)/) {print $1;}') |
| 191 | sg lxd -c "lxc profile device set default eth0 mtu $DEFAULT_MTU" |
| 192 | sg lxd -c "lxc network set lxdbr0 bridge.mtu $DEFAULT_MTU" |
| Dominik Fleischmann | 5e4a751 | 2020-03-06 14:05:06 +0100 | [diff] [blame] | 193 | |
| aticig | 5d19ac2 | 2022-05-06 13:46:22 +0300 | [diff] [blame] | 194 | cat << EOF > $LXD_CLOUD |
| Dominik Fleischmann | 5e4a751 | 2020-03-06 14:05:06 +0100 | [diff] [blame] | 195 | clouds: |
| 196 | lxd-cloud: |
| 197 | type: lxd |
| 198 | auth-types: [certificate] |
| 199 | endpoint: "https://$LXDENDPOINT:8443" |
| 200 | config: |
| 201 | ssl-hostname-verification: false |
| 202 | EOF |
| aticig | 5d19ac2 | 2022-05-06 13:46:22 +0300 | [diff] [blame] | 203 | openssl req -nodes -new -x509 -keyout ~/.osm/client.key -out ~/.osm/client.crt -days 365 -subj "/C=FR/ST=Nice/L=Nice/O=ETSI/OU=OSM/CN=osm.etsi.org" |
| aticig | 5d19ac2 | 2022-05-06 13:46:22 +0300 | [diff] [blame] | 204 | cat << EOF > $LXD_CREDENTIALS |
| Dominik Fleischmann | 5e4a751 | 2020-03-06 14:05:06 +0100 | [diff] [blame] | 205 | credentials: |
| 206 | lxd-cloud: |
| David Garcia | 4237521 | 2020-04-27 19:07:49 +0200 | [diff] [blame] | 207 | lxd-cloud: |
| Dominik Fleischmann | 5e4a751 | 2020-03-06 14:05:06 +0100 | [diff] [blame] | 208 | auth-type: certificate |
| David Garcia | f82897c | 2022-06-01 13:01:43 +0200 | [diff] [blame] | 209 | server-cert: /var/snap/lxd/common/lxd/server.crt |
| 210 | client-cert: ~/.osm/client.crt |
| 211 | client-key: ~/.osm/client.key |
| Dominik Fleischmann | 5e4a751 | 2020-03-06 14:05:06 +0100 | [diff] [blame] | 212 | EOF |
| aticig | 5d19ac2 | 2022-05-06 13:46:22 +0300 | [diff] [blame] | 213 | lxc config trust add local: ~/.osm/client.crt |
| 214 | fi |
| Dominik Fleischmann | 5e4a751 | 2020-03-06 14:05:06 +0100 | [diff] [blame] | 215 | |
| aticig | 5d19ac2 | 2022-05-06 13:46:22 +0300 | [diff] [blame] | 216 | juju add-cloud -c $CONTROLLER_NAME lxd-cloud $LXD_CLOUD --force |
| 217 | juju add-credential -c $CONTROLLER_NAME lxd-cloud -f $LXD_CREDENTIALS |
| 218 | sg lxd -c "lxd waitready" |
| 219 | juju controller-config features=[k8s-operators] |
| 220 | track bootstrap_lxd bootstrap_lxd_ok |
| 221 | fi |
| Dominik Fleischmann | 5e4a751 | 2020-03-06 14:05:06 +0100 | [diff] [blame] | 222 | } |
| 223 | |
| 224 | function deploy_charmed_osm(){ |
| beierlm | f2782c5 | 2020-11-05 17:04:05 -0500 | [diff] [blame] | 225 | if [ -v REGISTRY_INFO ] ; then |
| 226 | registry_parts=(${REGISTRY_INFO//@/ }) |
| 227 | if [ ${#registry_parts[@]} -eq 1 ] ; then |
| 228 | # No credentials supplied |
| 229 | REGISTRY_USERNAME="" |
| 230 | REGISTRY_PASSWORD="" |
| 231 | REGISTRY_URL=${registry_parts[0]} |
| 232 | else |
| 233 | credentials=${registry_parts[0]} |
| 234 | credential_parts=(${credentials//:/ }) |
| 235 | REGISTRY_USERNAME=${credential_parts[0]} |
| 236 | REGISTRY_PASSWORD=${credential_parts[1]} |
| 237 | REGISTRY_URL=${registry_parts[1]} |
| 238 | fi |
| 239 | # Ensure the URL ends with a / |
| 240 | case $REGISTRY_URL in |
| 241 | */) ;; |
| 242 | *) REGISTRY_URL=${REGISTRY_URL}/ |
| 243 | esac |
| 244 | fi |
| 245 | |
| Dominik Fleischmann | 5e4a751 | 2020-03-06 14:05:06 +0100 | [diff] [blame] | 246 | echo "Creating OSM model" |
| David Garcia | 4237521 | 2020-04-27 19:07:49 +0200 | [diff] [blame] | 247 | if [ -v KUBECFG ]; then |
| David Garcia | ef349d9 | 2020-12-10 21:16:12 +0100 | [diff] [blame] | 248 | juju add-model $MODEL_NAME $K8S_CLOUD_NAME |
| Dominik Fleischmann | 5e4a751 | 2020-03-06 14:05:06 +0100 | [diff] [blame] | 249 | else |
| David Garcia | ef349d9 | 2020-12-10 21:16:12 +0100 | [diff] [blame] | 250 | sg ${KUBEGRP} -c "juju add-model $MODEL_NAME $K8S_CLOUD_NAME" |
| Dominik Fleischmann | 5e4a751 | 2020-03-06 14:05:06 +0100 | [diff] [blame] | 251 | fi |
| 252 | echo "Deploying OSM with charms" |
| beierlm | a4a37f7 | 2020-06-26 12:55:01 -0400 | [diff] [blame] | 253 | images_overlay="" |
| beierlm | f2782c5 | 2020-11-05 17:04:05 -0500 | [diff] [blame] | 254 | if [ -v REGISTRY_URL ]; then |
| 255 | [ ! -v TAG ] && TAG='latest' |
| 256 | fi |
| beierlm | a4a37f7 | 2020-06-26 12:55:01 -0400 | [diff] [blame] | 257 | [ -v TAG ] && generate_images_overlay && images_overlay="--overlay $IMAGES_OVERLAY_FILE" |
| beierlm | f2782c5 | 2020-11-05 17:04:05 -0500 | [diff] [blame] | 258 | |
| David Garcia | 4bd2bf0 | 2021-05-05 19:01:43 +0200 | [diff] [blame] | 259 | if [ -v OVERLAY ]; then |
| 260 | extra_overlay="--overlay $OVERLAY" |
| 261 | fi |
| aticig | 6eb3928 | 2022-02-24 00:34:52 +0300 | [diff] [blame] | 262 | echo "Creating Password Overlay" |
| 263 | |
| 264 | generate_password_overlay && secret_overlay="--overlay $PASSWORD_OVERLAY_FILE" |
| David Garcia | 4bd2bf0 | 2021-05-05 19:01:43 +0200 | [diff] [blame] | 265 | |
| Patricia Reinoso | 58ac3a5 | 2022-09-01 15:18:13 +0200 | [diff] [blame] | 266 | [ -n "$INSTALL_PLA" ] && create_pla_overlay && pla_overlay="--overlay $PLA_OVERLAY_FILE" |
| 267 | |
| David Garcia | 4237521 | 2020-04-27 19:07:49 +0200 | [diff] [blame] | 268 | if [ -v BUNDLE ]; then |
| Patricia Reinoso | 58ac3a5 | 2022-09-01 15:18:13 +0200 | [diff] [blame] | 269 | juju deploy --trust --channel $CHARMHUB_CHANNEL -m $MODEL_NAME $BUNDLE $images_overlay $extra_overlay $secret_overlay $pla_overlay |
| Dominik Fleischmann | 5e4a751 | 2020-03-06 14:05:06 +0100 | [diff] [blame] | 270 | else |
| Patricia Reinoso | 58ac3a5 | 2022-09-01 15:18:13 +0200 | [diff] [blame] | 271 | juju deploy --trust --channel $CHARMHUB_CHANNEL -m $MODEL_NAME $OSM_BUNDLE $images_overlay $extra_overlay $secret_overlay $pla_overlay |
| Dominik Fleischmann | 5e4a751 | 2020-03-06 14:05:06 +0100 | [diff] [blame] | 272 | fi |
| beierlm | a4a37f7 | 2020-06-26 12:55:01 -0400 | [diff] [blame] | 273 | |
| beierlm | a4a37f7 | 2020-06-26 12:55:01 -0400 | [diff] [blame] | 274 | if [ ! -v KUBECFG ]; then |
| beierlm | a4a37f7 | 2020-06-26 12:55:01 -0400 | [diff] [blame] | 275 | API_SERVER=${DEFAULT_IP} |
| 276 | else |
| 277 | API_SERVER=$(kubectl config view --minify | grep server | cut -f 2- -d ":" | tr -d " ") |
| 278 | proto="$(echo $API_SERVER | grep :// | sed -e's,^\(.*://\).*,\1,g')" |
| 279 | url="$(echo ${API_SERVER/$proto/})" |
| 280 | user="$(echo $url | grep @ | cut -d@ -f1)" |
| 281 | hostport="$(echo ${url/$user@/} | cut -d/ -f1)" |
| 282 | API_SERVER="$(echo $hostport | sed -e 's,:.*,,g')" |
| 283 | fi |
| aticig | abef99c | 2022-08-23 15:13:23 +0300 | [diff] [blame] | 284 | # Configure VCA Integrator |
| Guillermo Calvino | ba6b4e5 | 2023-01-05 12:20:24 +0100 | [diff] [blame] | 285 | if [ ! -v INSTALL_NOLXD ]; then |
| 286 | juju config vca \ |
| 287 | k8s-cloud=microk8s \ |
| 288 | lxd-cloud=lxd-cloud:lxd-cloud \ |
| 289 | controllers="`cat ~/.local/share/juju/controllers.yaml`" \ |
| 290 | accounts="`cat ~/.local/share/juju/accounts.yaml`" \ |
| 291 | public-key="`cat ~/.local/share/juju/ssh/juju_id_rsa.pub`" |
| 292 | else |
| 293 | juju config vca \ |
| 294 | k8s-cloud=microk8s \ |
| 295 | controllers="`cat ~/.local/share/juju/controllers.yaml`" \ |
| 296 | accounts="`cat ~/.local/share/juju/accounts.yaml`" \ |
| 297 | public-key="`cat ~/.local/share/juju/ssh/juju_id_rsa.pub`" |
| 298 | fi |
| David Garcia | de5fc1d | 2020-09-02 11:40:12 +0200 | [diff] [blame] | 299 | # Expose OSM services |
| aticig | abef99c | 2022-08-23 15:13:23 +0300 | [diff] [blame] | 300 | juju config -m $MODEL_NAME nbi external-hostname=nbi.${API_SERVER}.nip.io |
| 301 | juju config -m $MODEL_NAME ng-ui external-hostname=ui.${API_SERVER}.nip.io |
| David Garcia | c395a45 | 2021-05-05 14:22:26 +0200 | [diff] [blame] | 302 | juju config -m $MODEL_NAME grafana site_url=https://grafana.${API_SERVER}.nip.io |
| 303 | juju config -m $MODEL_NAME prometheus site_url=https://prometheus.${API_SERVER}.nip.io |
| David Garcia | ef349d9 | 2020-12-10 21:16:12 +0100 | [diff] [blame] | 304 | |
| David Garcia | 49379ce | 2021-02-24 13:48:22 +0100 | [diff] [blame] | 305 | echo "Waiting for deployment to finish..." |
| 306 | check_osm_deployed |
| David Garcia | c537fa6 | 2021-11-09 08:45:49 +0100 | [diff] [blame] | 307 | grafana_leader=`juju status -m $MODEL_NAME grafana | grep "*" | cut -d "*" -f 1` |
| 308 | grafana_admin_password=`juju run -m $MODEL_NAME --unit $grafana_leader "echo \\$GF_SECURITY_ADMIN_PASSWORD"` |
| aticig | abef99c | 2022-08-23 15:13:23 +0300 | [diff] [blame] | 309 | juju config -m $MODEL_NAME mon grafana-password=$grafana_admin_password |
| David Garcia | c537fa6 | 2021-11-09 08:45:49 +0100 | [diff] [blame] | 310 | check_osm_deployed |
| David Garcia | 49379ce | 2021-02-24 13:48:22 +0100 | [diff] [blame] | 311 | echo "OSM with charms deployed" |
| beierlm | 9afb0ef | 2020-10-16 12:53:51 -0400 | [diff] [blame] | 312 | } |
| Dominik Fleischmann | 5e4a751 | 2020-03-06 14:05:06 +0100 | [diff] [blame] | 313 | |
| 314 | function check_osm_deployed() { |
| beierlm | a4a37f7 | 2020-06-26 12:55:01 -0400 | [diff] [blame] | 315 | TIME_TO_WAIT=600 |
| 316 | start_time="$(date -u +%s)" |
| Patricia Reinoso | 58ac3a5 | 2022-09-01 15:18:13 +0200 | [diff] [blame] | 317 | total_service_count=15 |
| 318 | [ -n "$INSTALL_PLA" ] && total_service_count=$((total_service_count + 1)) |
| beierlm | 7e54dfc | 2020-09-24 15:27:53 -0400 | [diff] [blame] | 319 | previous_count=0 |
| Dominik Fleischmann | 5e4a751 | 2020-03-06 14:05:06 +0100 | [diff] [blame] | 320 | while true |
| 321 | do |
| beierlm | 67a3447 | 2022-03-25 12:23:36 -0400 | [diff] [blame] | 322 | service_count=$(juju status --format json -m $MODEL_NAME | jq '.applications[]."application-status".current' | grep active | wc -l) |
| beierlm | a4a37f7 | 2020-06-26 12:55:01 -0400 | [diff] [blame] | 323 | echo "$service_count / $total_service_count services active" |
| 324 | if [ $service_count -eq $total_service_count ]; then |
| 325 | break |
| 326 | fi |
| beierlm | 7e54dfc | 2020-09-24 15:27:53 -0400 | [diff] [blame] | 327 | if [ $service_count -ne $previous_count ]; then |
| 328 | previous_count=$service_count |
| 329 | start_time="$(date -u +%s)" |
| 330 | fi |
| beierlm | a4a37f7 | 2020-06-26 12:55:01 -0400 | [diff] [blame] | 331 | now="$(date -u +%s)" |
| 332 | if [[ $(( now - start_time )) -gt $TIME_TO_WAIT ]];then |
| 333 | echo "Timed out waiting for OSM services to become ready" |
| beierlm | ce7b460 | 2022-04-13 08:19:40 -0400 | [diff] [blame] | 334 | FATAL_TRACK deploy_osm "Timed out waiting for services to become ready" |
| Dominik Fleischmann | 5e4a751 | 2020-03-06 14:05:06 +0100 | [diff] [blame] | 335 | fi |
| 336 | sleep 10 |
| 337 | done |
| 338 | } |
| 339 | |
| aticig | 6eb3928 | 2022-02-24 00:34:52 +0300 | [diff] [blame] | 340 | function generate_password_overlay() { |
| 341 | # prometheus |
| David Garcia | 8fa7807 | 2022-04-27 13:43:42 +0200 | [diff] [blame] | 342 | web_config_password=`openssl rand -hex 16` |
| aticig | 6eb3928 | 2022-02-24 00:34:52 +0300 | [diff] [blame] | 343 | # keystone |
| David Garcia | 8fa7807 | 2022-04-27 13:43:42 +0200 | [diff] [blame] | 344 | keystone_db_password=`openssl rand -hex 16` |
| 345 | keystone_admin_password=`openssl rand -hex 16` |
| 346 | keystone_service_password=`openssl rand -hex 16` |
| aticig | 6eb3928 | 2022-02-24 00:34:52 +0300 | [diff] [blame] | 347 | # mariadb |
| 348 | mariadb_password=`openssl rand -hex 16` |
| 349 | mariadb_root_password=`openssl rand -hex 16` |
| 350 | cat << EOF > /tmp/password-overlay.yaml |
| 351 | applications: |
| 352 | prometheus: |
| 353 | options: |
| 354 | web_config_password: $web_config_password |
| 355 | keystone: |
| 356 | options: |
| 357 | keystone-db-password: $keystone_db_password |
| 358 | admin-password: $keystone_admin_password |
| 359 | service-password: $keystone_service_password |
| 360 | mariadb: |
| 361 | options: |
| 362 | password: $mariadb_password |
| 363 | root_password: $mariadb_root_password |
| 364 | EOF |
| 365 | mv /tmp/password-overlay.yaml $PASSWORD_OVERLAY_FILE |
| 366 | } |
| 367 | |
| Patricia Reinoso | 58ac3a5 | 2022-09-01 15:18:13 +0200 | [diff] [blame] | 368 | function create_pla_overlay(){ |
| 369 | echo "Creating PLA Overlay" |
| 370 | [ $BUNDLE == $OSM_HA_BUNDLE ] && scale=3 || scale=1 |
| 371 | cat << EOF > /tmp/pla-overlay.yaml |
| 372 | applications: |
| 373 | pla: |
| 374 | charm: osm-pla |
| 375 | channel: latest/stable |
| 376 | scale: $scale |
| 377 | series: kubernetes |
| 378 | options: |
| 379 | log_level: DEBUG |
| 380 | resources: |
| 381 | image: opensourcemano/pla:testing-daily |
| 382 | relations: |
| 383 | - - pla:kafka |
| 384 | - kafka:kafka |
| 385 | - - pla:mongodb |
| 386 | - mongodb:database |
| 387 | EOF |
| 388 | mv /tmp/pla-overlay.yaml $PLA_OVERLAY_FILE |
| 389 | } |
| 390 | |
| David Garcia | 69388c2 | 2020-05-07 12:14:19 +0200 | [diff] [blame] | 391 | function generate_images_overlay(){ |
| David Garcia | 49379ce | 2021-02-24 13:48:22 +0100 | [diff] [blame] | 392 | echo "applications:" > /tmp/images-overlay.yaml |
| beierlm | f2782c5 | 2020-11-05 17:04:05 -0500 | [diff] [blame] | 393 | |
| Patricia Reinoso | 58ac3a5 | 2022-09-01 15:18:13 +0200 | [diff] [blame] | 394 | charms_with_resources="nbi lcm mon pol ng-ui ro" |
| 395 | [ -n "$INSTALL_PLA" ] && charms_with_resources+=" pla" |
| David Garcia | 49379ce | 2021-02-24 13:48:22 +0100 | [diff] [blame] | 396 | for charm in $charms_with_resources; do |
| 397 | cat << EOF > /tmp/${charm}_registry.yaml |
| 398 | registrypath: ${REGISTRY_URL}opensourcemano/${charm}:$TAG |
| beierlm | f2782c5 | 2020-11-05 17:04:05 -0500 | [diff] [blame] | 399 | EOF |
| David Garcia | 49379ce | 2021-02-24 13:48:22 +0100 | [diff] [blame] | 400 | if [ ! -z "$REGISTRY_USERNAME" ] ; then |
| 401 | echo username: $REGISTRY_USERNAME >> /tmp/${charm}_registry.yaml |
| 402 | echo password: $REGISTRY_PASSWORD >> /tmp/${charm}_registry.yaml |
| 403 | fi |
| beierlm | f2782c5 | 2020-11-05 17:04:05 -0500 | [diff] [blame] | 404 | |
| David Garcia | 49379ce | 2021-02-24 13:48:22 +0100 | [diff] [blame] | 405 | cat << EOF >> /tmp/images-overlay.yaml |
| 406 | ${charm}: |
| David Garcia | ef349d9 | 2020-12-10 21:16:12 +0100 | [diff] [blame] | 407 | resources: |
| Mark Beierl | efdc6d0 | 2022-10-12 13:05:21 -0400 | [diff] [blame] | 408 | ${charm}-image: /tmp/${charm}_registry.yaml |
| David Garcia | 49379ce | 2021-02-24 13:48:22 +0100 | [diff] [blame] | 409 | |
| David Garcia | 69388c2 | 2020-05-07 12:14:19 +0200 | [diff] [blame] | 410 | EOF |
| David Garcia | 49379ce | 2021-02-24 13:48:22 +0100 | [diff] [blame] | 411 | done |
| David Garcia | 53a09d8 | 2022-02-01 16:39:44 +0100 | [diff] [blame] | 412 | ch_charms_with_resources="keystone" |
| 413 | for charm in $ch_charms_with_resources; do |
| 414 | cat << EOF > /tmp/${charm}_registry.yaml |
| 415 | registrypath: ${REGISTRY_URL}opensourcemano/${charm}:$TAG |
| 416 | EOF |
| 417 | if [ ! -z "$REGISTRY_USERNAME" ] ; then |
| 418 | echo username: $REGISTRY_USERNAME >> /tmp/${charm}_registry.yaml |
| 419 | echo password: $REGISTRY_PASSWORD >> /tmp/${charm}_registry.yaml |
| 420 | fi |
| 421 | |
| 422 | cat << EOF >> /tmp/images-overlay.yaml |
| 423 | ${charm}: |
| 424 | resources: |
| 425 | ${charm}-image: /tmp/${charm}_registry.yaml |
| 426 | |
| 427 | EOF |
| 428 | done |
| David Garcia | 49379ce | 2021-02-24 13:48:22 +0100 | [diff] [blame] | 429 | |
| David Garcia | 69388c2 | 2020-05-07 12:14:19 +0200 | [diff] [blame] | 430 | mv /tmp/images-overlay.yaml $IMAGES_OVERLAY_FILE |
| 431 | } |
| 432 | |
| David Garcia | 107010b | 2021-01-15 12:58:59 +0100 | [diff] [blame] | 433 | function refresh_osmclient_snap() { |
| 434 | osmclient_snap_install_refresh refresh |
| 435 | } |
| 436 | |
| 437 | function install_osm_client_snap() { |
| 438 | osmclient_snap_install_refresh install |
| 439 | } |
| 440 | |
| 441 | function osmclient_snap_install_refresh() { |
| 442 | channel_preference="stable candidate beta edge" |
| 443 | for channel in $channel_preference; do |
| 444 | echo "Trying to install osmclient from channel $OSMCLIENT_VERSION/$channel" |
| 445 | sudo snap $1 osmclient --channel $OSMCLIENT_VERSION/$channel 2> /dev/null && echo osmclient snap installed && break |
| 446 | done |
| 447 | } |
| Dominik Fleischmann | 5e4a751 | 2020-03-06 14:05:06 +0100 | [diff] [blame] | 448 | function install_osmclient() { |
| David Garcia | 107010b | 2021-01-15 12:58:59 +0100 | [diff] [blame] | 449 | snap info osmclient | grep -E ^installed: && refresh_osmclient_snap || install_osm_client_snap |
| Dominik Fleischmann | 5e4a751 | 2020-03-06 14:05:06 +0100 | [diff] [blame] | 450 | } |
| 451 | |
| beierlm | df6de3d | 2020-12-16 08:46:40 -0500 | [diff] [blame] | 452 | function add_local_k8scluster() { |
| 453 | osm --all-projects vim-create \ |
| 454 | --name _system-osm-vim \ |
| 455 | --account_type dummy \ |
| 456 | --auth_url http://dummy \ |
| 457 | --user osm --password osm --tenant osm \ |
| 458 | --description "dummy" \ |
| 459 | --config '{management_network_name: mgmt}' |
| 460 | tmpfile=$(mktemp --tmpdir=${HOME}) |
| 461 | cp ${KUBECONFIG} ${tmpfile} |
| 462 | osm --all-projects k8scluster-add \ |
| 463 | --creds ${tmpfile} \ |
| 464 | --vim _system-osm-vim \ |
| 465 | --k8s-nets '{"net1": null}' \ |
| 466 | --version '1.19' \ |
| 467 | --description "OSM Internal Cluster" \ |
| 468 | _system-osm-k8s |
| 469 | rm -f ${tmpfile} |
| 470 | } |
| Dominik Fleischmann | 5e4a751 | 2020-03-06 14:05:06 +0100 | [diff] [blame] | 471 | |
| 472 | function install_microstack() { |
| beierlm | b403f06 | 2021-12-09 08:47:59 -0500 | [diff] [blame] | 473 | sudo snap install microstack --beta --devmode |
| 474 | |
| 475 | CHECK=$(microstack.openstack server list) |
| 476 | if [ $? -ne 0 ] ; then |
| 477 | if [[ $CHECK == *"not initialized"* ]]; then |
| 478 | echo "Setting MicroStack dashboard to listen to port 8080" |
| 479 | sudo snap set microstack config.network.ports.dashboard=8080 |
| 480 | echo "Initializing MicroStack. This can take several minutes" |
| 481 | sudo microstack.init --auto --control |
| 482 | fi |
| 483 | fi |
| 484 | |
| 485 | sudo snap alias microstack.openstack openstack |
| 486 | |
| 487 | echo "Updating default security group in MicroStack to allow all access" |
| 488 | |
| 489 | for i in $(microstack.openstack security group list | awk '/default/{ print $2 }'); do |
| 490 | for PROTO in icmp tcp udp ; do |
| 491 | echo " $PROTO ingress" |
| 492 | CHECK=$(microstack.openstack security group rule create $i --protocol $PROTO --remote-ip 0.0.0.0/0 2>&1) |
| 493 | if [ $? -ne 0 ] ; then |
| 494 | if [[ $CHECK != *"409"* ]]; then |
| 495 | echo "Error creating ingress rule for $PROTO" |
| 496 | echo $CHECK |
| 497 | fi |
| 498 | fi |
| 499 | done |
| 500 | done |
| 501 | |
| 502 | microstack.openstack network show osm-ext &>/dev/null |
| 503 | if [ $? -ne 0 ]; then |
| 504 | echo "Creating osm-ext network with router to bridge to MicroStack external network" |
| 505 | microstack.openstack network create --enable --no-share osm-ext |
| 506 | microstack.openstack subnet create osm-ext-subnet --network osm-ext --dns-nameserver 8.8.8.8 \ |
| 507 | --subnet-range 172.30.0.0/24 |
| 508 | microstack.openstack router create external-router |
| 509 | microstack.openstack router add subnet external-router osm-ext-subnet |
| 510 | microstack.openstack router set --external-gateway external external-router |
| 511 | fi |
| 512 | |
| 513 | microstack.openstack image list | grep ubuntu20.04 &> /dev/null |
| 514 | if [ $? -ne 0 ] ; then |
| 515 | echo "Fetching Ubuntu 20.04 image and upLoading to MicroStack" |
| 516 | wget -q -O- https://cloud-images.ubuntu.com/focal/current/focal-server-cloudimg-amd64.img \ |
| 517 | | microstack.openstack image create --public --container-format=bare \ |
| 518 | --disk-format=qcow2 ubuntu20.04 | grep status |
| 519 | fi |
| 520 | |
| 521 | if [ ! -f ~/.ssh/microstack ]; then |
| 522 | ssh-keygen -t rsa -N "" -f ~/.ssh/microstack |
| 523 | microstack.openstack keypair create --public-key ~/.ssh/microstack.pub microstack |
| 524 | fi |
| 525 | |
| 526 | echo "Creating VIM microstack-site in OSM" |
| 527 | . /var/snap/microstack/common/etc/microstack.rc |
| 528 | |
| 529 | osm vim-create \ |
| 530 | --name microstack-site \ |
| 531 | --user "$OS_USERNAME" \ |
| 532 | --password "$OS_PASSWORD" \ |
| 533 | --auth_url "$OS_AUTH_URL" \ |
| 534 | --tenant "$OS_USERNAME" \ |
| 535 | --account_type openstack \ |
| 536 | --config='{use_floating_ip: True, |
| 537 | insecure: True, |
| 538 | keypair: microstack, |
| 539 | management_network_name: osm-ext}' |
| Dominik Fleischmann | 5e4a751 | 2020-03-06 14:05:06 +0100 | [diff] [blame] | 540 | } |
| 541 | |
| beierlm | 4aad47b | 2021-12-07 16:15:53 -0500 | [diff] [blame] | 542 | DEFAULT_IF=`ip route list match 0.0.0.0 | awk '{print $5; exit}'` |
| 543 | DEFAULT_IP=`ip -o -4 a |grep ${DEFAULT_IF}|awk '{split($4,a,"/"); print a[1]; exit}'` |
| Dominik Fleischmann | 5e4a751 | 2020-03-06 14:05:06 +0100 | [diff] [blame] | 544 | |
| 545 | check_arguments $@ |
| David Garcia | 4237521 | 2020-04-27 19:07:49 +0200 | [diff] [blame] | 546 | mkdir -p ~/.osm |
| Dominik Fleischmann | 5e4a751 | 2020-03-06 14:05:06 +0100 | [diff] [blame] | 547 | install_snaps |
| 548 | bootstrap_k8s_lxd |
| David Garcia | 1bc7102 | 2021-05-03 18:27:18 +0200 | [diff] [blame] | 549 | if [ -v ONLY_VCA ]; then |
| 550 | HOME=/home/$USER |
| aticig | abef99c | 2022-08-23 15:13:23 +0300 | [diff] [blame] | 551 | k8scloud=microk8s |
| 552 | lxdcloud=lxd-cloud:lxd-cloud |
| 553 | controllers="`cat $HOME/.local/share/juju/controllers.yaml`" |
| 554 | accounts="`cat $HOME/.local/share/juju/accounts.yaml`" |
| 555 | publickey="`cat $HOME/.local/share/juju/ssh/juju_id_rsa.pub`" |
| 556 | echo "Use the following command to register the installed VCA to your OSM VCA integrator charm" |
| 557 | echo -e " juju config vca \\\n k8s-cloud=$k8scloud \\\n lxd-cloud=$lxdcloud \\\n controllers=$controllers \\\n accounts=$accounts \\\n public-key=$publickey" |
| beierlm | ce7b460 | 2022-04-13 08:19:40 -0400 | [diff] [blame] | 558 | track deploy_osm deploy_vca_only_ok |
| David Garcia | 1bc7102 | 2021-05-03 18:27:18 +0200 | [diff] [blame] | 559 | else |
| 560 | deploy_charmed_osm |
| beierlm | ce7b460 | 2022-04-13 08:19:40 -0400 | [diff] [blame] | 561 | track deploy_osm deploy_osm_services_k8s_ok |
| David Garcia | 1bc7102 | 2021-05-03 18:27:18 +0200 | [diff] [blame] | 562 | install_osmclient |
| beierlm | ce7b460 | 2022-04-13 08:19:40 -0400 | [diff] [blame] | 563 | track osmclient osmclient_ok |
| aticig | abef99c | 2022-08-23 15:13:23 +0300 | [diff] [blame] | 564 | export OSM_HOSTNAME=$(juju config -m $MODEL_NAME nbi external-hostname):443 |
| aticig | 6eb3928 | 2022-02-24 00:34:52 +0300 | [diff] [blame] | 565 | export OSM_PASSWORD=$keystone_admin_password |
| David Garcia | 1bc7102 | 2021-05-03 18:27:18 +0200 | [diff] [blame] | 566 | sleep 10 |
| 567 | add_local_k8scluster |
| beierlm | ce7b460 | 2022-04-13 08:19:40 -0400 | [diff] [blame] | 568 | track final_ops add_local_k8scluster_ok |
| David Garcia | 1bc7102 | 2021-05-03 18:27:18 +0200 | [diff] [blame] | 569 | if [ -v MICROSTACK ]; then |
| 570 | install_microstack |
| beierlm | ce7b460 | 2022-04-13 08:19:40 -0400 | [diff] [blame] | 571 | track final_ops install_microstack_ok |
| David Garcia | 1bc7102 | 2021-05-03 18:27:18 +0200 | [diff] [blame] | 572 | fi |
| 573 | |
| 574 | echo "Your installation is now complete, follow these steps for configuring the osmclient:" |
| 575 | echo |
| 576 | echo "1. Create the OSM_HOSTNAME environment variable with the NBI IP" |
| 577 | echo |
| 578 | echo "export OSM_HOSTNAME=$OSM_HOSTNAME" |
| aticig | 6eb3928 | 2022-02-24 00:34:52 +0300 | [diff] [blame] | 579 | echo "export OSM_PASSWORD=$OSM_PASSWORD" |
| David Garcia | 1bc7102 | 2021-05-03 18:27:18 +0200 | [diff] [blame] | 580 | echo |
| aticig | 6eb3928 | 2022-02-24 00:34:52 +0300 | [diff] [blame] | 581 | echo "2. Add the previous commands to your .bashrc for other Shell sessions" |
| David Garcia | 1bc7102 | 2021-05-03 18:27:18 +0200 | [diff] [blame] | 582 | echo |
| 583 | echo "echo \"export OSM_HOSTNAME=$OSM_HOSTNAME\" >> ~/.bashrc" |
| aticig | 6eb3928 | 2022-02-24 00:34:52 +0300 | [diff] [blame] | 584 | echo "echo \"export OSM_PASSWORD=$OSM_PASSWORD\" >> ~/.bashrc" |
| 585 | echo |
| 586 | echo "3. Login OSM GUI by using admin password: $OSM_PASSWORD" |
| David Garcia | 1bc7102 | 2021-05-03 18:27:18 +0200 | [diff] [blame] | 587 | echo |
| 588 | echo "DONE" |
| beierlm | ce7b460 | 2022-04-13 08:19:40 -0400 | [diff] [blame] | 589 | track end |
| Dominik Fleischmann | 5e4a751 | 2020-03-06 14:05:06 +0100 | [diff] [blame] | 590 | fi |
| beierlm | a4a37f7 | 2020-06-26 12:55:01 -0400 | [diff] [blame] | 591 | |