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