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