blob: f0f729e67f3ec3d2bd031c68f6a4c3a7e642bd3a [file] [log] [blame]
Dominik Fleischmann5e4a7512020-03-06 14:05:06 +01001#! /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 Garcia42375212020-04-27 19:07:49 +020015
16# set -eux
17
18K8S_CLOUD_NAME="k8s-cloud"
beierlm3749e312020-07-02 14:21:09 -040019KUBECTL="microk8s.kubectl"
David Garcia69388c22020-05-07 12:14:19 +020020IMAGES_OVERLAY_FILE=~/.osm/images-overlay.yaml
Dominik Fleischmann5e4a7512020-03-06 14:05:06 +010021function check_arguments(){
22 while [ $# -gt 0 ] ; do
David Garcia42375212020-04-27 19:07:49 +020023 case $1 in
24 --bundle) BUNDLE="$2" ;;
Dominik Fleischmann7a97a4c2020-06-04 10:52:05 +020025 --k8s) KUBECFG="$2" ;;
26 --vca) CONTROLLER="$2" ;;
27 --lxd) LXD_CLOUD="$2" ;;
28 --lxd-cred) LXD_CREDENTIALS="$2" ;;
David Garcia69388c22020-05-07 12:14:19 +020029 --microstack) MICROSTACK=y ;;
David Garciacef05e92020-08-20 12:08:31 +020030 --ha) BUNDLE="cs:osm-ha" ;;
David Garcia69388c22020-05-07 12:14:19 +020031 --tag) TAG="$2" ;;
David Garcia42375212020-04-27 19:07:49 +020032 esac
33 shift
Dominik Fleischmann5e4a7512020-03-06 14:05:06 +010034 done
35
David Garcia42375212020-04-27 19:07:49 +020036 # echo $BUNDLE $KUBECONFIG $LXDENDPOINT
Dominik Fleischmann5e4a7512020-03-06 14:05:06 +010037}
beierlma4a37f72020-06-26 12:55:01 -040038
Dominik Fleischmann5e4a7512020-03-06 14:05:06 +010039function install_snaps(){
beierlma4a37f72020-06-26 12:55:01 -040040 if [ ! -v KUBECFG ]; then
41 sudo snap install microk8s --classic
42 sudo usermod -a -G microk8s `whoami`
43 mkdir -p ~/.kube
44 sudo chown -f -R `whoami` ~/.kube
45 KUBEGRP="microk8s"
beierlm9afb0ef2020-10-16 12:53:51 -040046 microk8s status --wait-ready
beierlma4a37f72020-06-26 12:55:01 -040047 else
48 KUBECTL="kubectl"
49 sudo snap install kubectl --classic
50 export KUBECONFIG=${KUBECFG}
51 KUBEGRP=$(id -g -n)
52 fi
53 sudo snap install juju --classic --channel=2.8/stable
Dominik Fleischmann5e4a7512020-03-06 14:05:06 +010054}
55
56function bootstrap_k8s_lxd(){
David Garcia42375212020-04-27 19:07:49 +020057 [ -v CONTROLLER ] && ADD_K8S_OPTS="--controller ${CONTROLLER}" && CONTROLLER_NAME=$CONTROLLER
beierlma4a37f72020-06-26 12:55:01 -040058 [ ! -v CONTROLLER ] && ADD_K8S_OPTS="--client" && BOOTSTRAP_NEEDED="yes" && CONTROLLER_NAME="osm-vca"
59
60 if [ -v BOOTSTRAP_NEEDED ]; then
61 CONTROLLER_PRESENT=$(juju controllers 2>/dev/null| grep ${CONTROLLER_NAME} | wc -l)
62 if [ $CONTROLLER_PRESENT -ge 1 ]; then
63 cat << EOF
64Threre is already a VCA present with the installer reserved name of "${CONTROLLER_NAME}".
65You may either explicitly use this VCA with the "--vca ${CONTROLLER_NAME}" option, or remove it
66using this command:
67
68 juju destroy-controller --release-storage --destroy-all-models -y ${CONTROLLER_NAME}
69
70Please retry the installation once this conflict has been resolved.
71EOF
72 exit 1
73 fi
beierlm9afb0ef2020-10-16 12:53:51 -040074 else
75 CONTROLLER_PRESENT=$(juju controllers 2>/dev/null| grep ${CONTROLLER_NAME} | wc -l)
76 if [ $CONTROLLER_PRESENT -le 0 ]; then
77 cat << EOF
78Threre is no VCA present with the name "${CONTROLLER_NAME}". Please specify a VCA
79that exists, or remove the --vca ${CONTROLLER_NAME} option.
80
81Please retry the installation with one of the solutions applied.
82EOF
83 exit 1
84 fi
beierlma4a37f72020-06-26 12:55:01 -040085 fi
David Garcia42375212020-04-27 19:07:49 +020086
87 if [ -v KUBECFG ]; then
88 cat $KUBECFG | juju add-k8s $K8S_CLOUD_NAME $ADD_K8S_OPTS
beierlm2634cd32020-09-15 16:00:34 -040089 [ -v BOOTSTRAP_NEEDED ] && juju bootstrap $K8S_CLOUD_NAME $CONTROLLER_NAME \
90 --config controller-service-type=loadbalancer \
91 --agent-version=2.8.1
Dominik Fleischmann5e4a7512020-03-06 14:05:06 +010092 else
beierlma4a37f72020-06-26 12:55:01 -040093 sg ${KUBEGRP} -c "echo ${DEFAULT_IP}-${DEFAULT_IP} | microk8s.enable metallb"
beierlm9afb0ef2020-10-16 12:53:51 -040094 sg ${KUBEGRP} -c "microk8s.enable ingress"
beierlma4a37f72020-06-26 12:55:01 -040095 sg ${KUBEGRP} -c "microk8s.enable storage dns"
96 TIME_TO_WAIT=30
97 start_time="$(date -u +%s)"
Dominik Fleischmannc57296f2020-06-09 11:45:08 +020098 while true
99 do
beierlma4a37f72020-06-26 12:55:01 -0400100 now="$(date -u +%s)"
101 if [[ $(( now - start_time )) -gt $TIME_TO_WAIT ]];then
102 echo "Microk8s storage failed to enable"
103 sg ${KUBEGRP} -c "microk8s.status"
104 exit 1
105 fi
106 storage_status=`sg ${KUBEGRP} -c "microk8s.status -a storage"`
107 if [[ $storage_status == "enabled" ]]; then
Dominik Fleischmannc57296f2020-06-09 11:45:08 +0200108 break
109 fi
110 sleep 1
111 done
David Garcia42375212020-04-27 19:07:49 +0200112
beierlma4a37f72020-06-26 12:55:01 -0400113 [ ! -v BOOTSTRAP_NEEDED ] && sg ${KUBEGRP} -c "microk8s.config" | juju add-k8s $K8S_CLOUD_NAME $ADD_K8S_OPTS
beierlm2634cd32020-09-15 16:00:34 -0400114 [ -v BOOTSTRAP_NEEDED ] && sg ${KUBEGRP} -c \
115 "juju bootstrap microk8s $CONTROLLER_NAME --config controller-service-type=loadbalancer --agent-version=2.8.1" \
116 && K8S_CLOUD_NAME=microk8s
Dominik Fleischmann5e4a7512020-03-06 14:05:06 +0100117 fi
118
David Garcia42375212020-04-27 19:07:49 +0200119 if [ -v LXD_CLOUD ]; then
120 if [ ! -v LXD_CREDENTIALS ]; then
Dominik Fleischmann5e4a7512020-03-06 14:05:06 +0100121 echo "The installer needs the LXD server certificate if the LXD is external"
122 exit 1
123 fi
124 else
125 LXDENDPOINT=$DEFAULT_IP
David Garcia42375212020-04-27 19:07:49 +0200126 LXD_CLOUD=~/.osm/lxd-cloud.yaml
127 LXD_CREDENTIALS=~/.osm/lxd-credentials.yaml
128 # Apply sysctl production values for optimal performance
129 sudo cp /usr/share/osm-devops/installers/60-lxd-production.conf /etc/sysctl.d/60-lxd-production.conf
130 sudo sysctl --system
131 # Install LXD snap
132 sudo apt-get remove --purge -y liblxc1 lxc-common lxcfs lxd lxd-client
133 sudo snap install lxd
David Garcia42375212020-04-27 19:07:49 +0200134 # Configure LXD
135 sudo usermod -a -G lxd `whoami`
136 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"
137 sg lxd -c "lxd waitready"
138 DEFAULT_MTU=$(ip addr show $DEFAULT_IF | perl -ne 'if (/mtu\s(\d+)/) {print $1;}')
139 sg lxd -c "lxc profile device set default eth0 mtu $DEFAULT_MTU"
David Garciad00e49c2020-06-19 10:33:37 +0200140 sg lxd -c "lxc network set lxdbr0 bridge.mtu $DEFAULT_MTU"
Dominik Fleischmann5e4a7512020-03-06 14:05:06 +0100141
David Garcia42375212020-04-27 19:07:49 +0200142 cat << EOF > $LXD_CLOUD
Dominik Fleischmann5e4a7512020-03-06 14:05:06 +0100143clouds:
144 lxd-cloud:
145 type: lxd
146 auth-types: [certificate]
147 endpoint: "https://$LXDENDPOINT:8443"
148 config:
149 ssl-hostname-verification: false
150EOF
David Garcia42375212020-04-27 19:07:49 +0200151 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"
152 local server_cert=`cat /var/snap/lxd/common/lxd/server.crt | sed 's/^/ /'`
153 local client_cert=`cat ~/.osm/client.crt | sed 's/^/ /'`
154 local client_key=`cat ~/.osm/client.key | sed 's/^/ /'`
Dominik Fleischmann5e4a7512020-03-06 14:05:06 +0100155
David Garcia42375212020-04-27 19:07:49 +0200156 cat << EOF > $LXD_CREDENTIALS
Dominik Fleischmann5e4a7512020-03-06 14:05:06 +0100157credentials:
158 lxd-cloud:
David Garcia42375212020-04-27 19:07:49 +0200159 lxd-cloud:
Dominik Fleischmann5e4a7512020-03-06 14:05:06 +0100160 auth-type: certificate
161 server-cert: |
162$server_cert
163 client-cert: |
164$client_cert
165 client-key: |
166$client_key
167EOF
David Garcia42375212020-04-27 19:07:49 +0200168 lxc config trust add local: ~/.osm/client.crt
169 fi
Dominik Fleischmann5e4a7512020-03-06 14:05:06 +0100170
David Garcia42375212020-04-27 19:07:49 +0200171 juju add-cloud -c $CONTROLLER_NAME lxd-cloud $LXD_CLOUD --force
172 juju add-credential -c $CONTROLLER_NAME lxd-cloud -f $LXD_CREDENTIALS
173 sg lxd -c "lxd waitready"
beierlma4a37f72020-06-26 12:55:01 -0400174 juju controller-config features=[k8s-operators]
175}
176
177function wait_for_port(){
178 SERVICE=$1
179 INDEX=$2
180 TIME_TO_WAIT=30
181 start_time="$(date -u +%s)"
182 while true
183 do
184 now="$(date -u +%s)"
185 if [[ $(( now - start_time )) -gt $TIME_TO_WAIT ]];then
186 echo "Failed to expose external ${SERVICE} interface port"
187 exit 1
188 fi
189
beierlm9afb0ef2020-10-16 12:53:51 -0400190 if [ $(sg ${KUBEGRP} -c "${KUBECTL} get ingresses.networking -n osm -o json | jq -r '.items[$INDEX].metadata.name'") == ${SERVICE} ] ; then
beierlma4a37f72020-06-26 12:55:01 -0400191 break
192 fi
193 sleep 1
194 done
Dominik Fleischmann5e4a7512020-03-06 14:05:06 +0100195}
196
197function deploy_charmed_osm(){
198 create_overlay
199 echo "Creating OSM model"
David Garcia42375212020-04-27 19:07:49 +0200200 if [ -v KUBECFG ]; then
201 juju add-model osm $K8S_CLOUD_NAME
Dominik Fleischmann5e4a7512020-03-06 14:05:06 +0100202 else
beierlma4a37f72020-06-26 12:55:01 -0400203 sg ${KUBEGRP} -c "juju add-model osm $K8S_CLOUD_NAME"
Dominik Fleischmann5e4a7512020-03-06 14:05:06 +0100204 fi
205 echo "Deploying OSM with charms"
beierlma4a37f72020-06-26 12:55:01 -0400206 images_overlay=""
207 [ -v TAG ] && generate_images_overlay && images_overlay="--overlay $IMAGES_OVERLAY_FILE"
David Garcia42375212020-04-27 19:07:49 +0200208 if [ -v BUNDLE ]; then
beierlma4a37f72020-06-26 12:55:01 -0400209 juju deploy $BUNDLE --overlay ~/.osm/vca-overlay.yaml $images_overlay
Dominik Fleischmann5e4a7512020-03-06 14:05:06 +0100210 else
David Garciacef05e92020-08-20 12:08:31 +0200211 juju deploy cs:osm --overlay ~/.osm/vca-overlay.yaml $images_overlay
Dominik Fleischmann5e4a7512020-03-06 14:05:06 +0100212 fi
beierlma4a37f72020-06-26 12:55:01 -0400213
Dominik Fleischmann5e4a7512020-03-06 14:05:06 +0100214 echo "Waiting for deployment to finish..."
beierlma4a37f72020-06-26 12:55:01 -0400215 check_osm_deployed
Dominik Fleischmann5e4a7512020-03-06 14:05:06 +0100216 echo "OSM with charms deployed"
beierlma4a37f72020-06-26 12:55:01 -0400217 if [ ! -v KUBECFG ]; then
beierlma4a37f72020-06-26 12:55:01 -0400218 API_SERVER=${DEFAULT_IP}
219 else
220 API_SERVER=$(kubectl config view --minify | grep server | cut -f 2- -d ":" | tr -d " ")
221 proto="$(echo $API_SERVER | grep :// | sed -e's,^\(.*://\).*,\1,g')"
222 url="$(echo ${API_SERVER/$proto/})"
223 user="$(echo $url | grep @ | cut -d@ -f1)"
224 hostport="$(echo ${url/$user@/} | cut -d/ -f1)"
225 API_SERVER="$(echo $hostport | sed -e 's,:.*,,g')"
226 fi
227
David Garciade5fc1d2020-09-02 11:40:12 +0200228 # Expose OSM services
beierlm9afb0ef2020-10-16 12:53:51 -0400229 # Expose Grafana
230 juju config grafana-k8s juju-external-hostname=grafana.${API_SERVER}.xip.io
231 juju expose grafana-k8s
232 wait_for_port grafana-k8s 0
233
David Garciade5fc1d2020-09-02 11:40:12 +0200234 # Expose NBI
beierlma4a37f72020-06-26 12:55:01 -0400235 juju config nbi-k8s juju-external-hostname=nbi.${API_SERVER}.xip.io
236 juju expose nbi-k8s
beierlm9afb0ef2020-10-16 12:53:51 -0400237 wait_for_port nbi-k8s 1
beierlma4a37f72020-06-26 12:55:01 -0400238
David Garciade5fc1d2020-09-02 11:40:12 +0200239 # Expose NG UI
beierlma4a37f72020-06-26 12:55:01 -0400240 juju config ng-ui juju-external-hostname=ui.${API_SERVER}.xip.io
241 juju expose ng-ui
beierlm9afb0ef2020-10-16 12:53:51 -0400242 wait_for_port ng-ui 2
243
244 # Expose Prometheus
245 juju config prometheus-k8s juju-external-hostname=prometheus.${API_SERVER}.xip.io
246 juju expose prometheus-k8s
247 wait_for_port prometheus-k8s 3
beierlma4a37f72020-06-26 12:55:01 -0400248
David Garciade5fc1d2020-09-02 11:40:12 +0200249 # Expose UI
beierlma4a37f72020-06-26 12:55:01 -0400250 juju config ui-k8s juju-external-hostname=osm.${API_SERVER}.xip.io
Dominik Fleischmann5e4a7512020-03-06 14:05:06 +0100251 juju expose ui-k8s
beierlm9afb0ef2020-10-16 12:53:51 -0400252 wait_for_port ui-k8s 4
David Garciade5fc1d2020-09-02 11:40:12 +0200253
254 # Apply annotations
beierlm9afb0ef2020-10-16 12:53:51 -0400255 sg ${KUBEGRP} -c "${KUBECTL} annotate ingresses.networking nginx.ingress.kubernetes.io/backend-protocol=HTTPS -n osm -l juju-app=nbi-k8s"
256 sg ${KUBEGRP} -c "${KUBECTL} annotate ingresses.networking nginx.ingress.kubernetes.io/proxy-body-size=0 -n osm -l juju-app=nbi-k8s"
257 sg ${KUBEGRP} -c "${KUBECTL} annotate ingresses.networking nginx.ingress.kubernetes.io/proxy-body-size=0 -n osm -l juju-app=ng-ui"
258 sg ${KUBEGRP} -c "${KUBECTL} annotate ingresses.networking nginx.ingress.kubernetes.io/proxy-body-size=0 -n osm -l juju-app=ui-k8s"
259}
Dominik Fleischmann5e4a7512020-03-06 14:05:06 +0100260
261function check_osm_deployed() {
beierlma4a37f72020-06-26 12:55:01 -0400262 TIME_TO_WAIT=600
263 start_time="$(date -u +%s)"
beierlm7e54dfc2020-09-24 15:27:53 -0400264 total_service_count=15
265 previous_count=0
Dominik Fleischmann5e4a7512020-03-06 14:05:06 +0100266 while true
267 do
beierlma4a37f72020-06-26 12:55:01 -0400268 service_count=$(juju status | grep kubernetes | grep active | wc -l)
269 echo "$service_count / $total_service_count services active"
270 if [ $service_count -eq $total_service_count ]; then
271 break
272 fi
beierlm7e54dfc2020-09-24 15:27:53 -0400273 if [ $service_count -ne $previous_count ]; then
274 previous_count=$service_count
275 start_time="$(date -u +%s)"
276 fi
beierlma4a37f72020-06-26 12:55:01 -0400277 now="$(date -u +%s)"
278 if [[ $(( now - start_time )) -gt $TIME_TO_WAIT ]];then
279 echo "Timed out waiting for OSM services to become ready"
280 exit 1
Dominik Fleischmann5e4a7512020-03-06 14:05:06 +0100281 fi
282 sleep 10
283 done
284}
285
286function create_overlay() {
David Garcia42375212020-04-27 19:07:49 +0200287 sudo snap install jq
288 sudo apt install python3-pip -y
289 python3 -m pip install yq
290 PATH=$PATH:$HOME/.local/bin # make yq command available
Dominik Fleischmann5e4a7512020-03-06 14:05:06 +0100291 local HOME=/home/$USER
David Garcia42375212020-04-27 19:07:49 +0200292 local vca_user=$(cat $HOME/.local/share/juju/accounts.yaml | yq --arg CONTROLLER_NAME $CONTROLLER_NAME '.controllers[$CONTROLLER_NAME].user')
293 local vca_password=$(cat $HOME/.local/share/juju/accounts.yaml | yq --arg CONTROLLER_NAME $CONTROLLER_NAME '.controllers[$CONTROLLER_NAME].password')
beierlm3749e312020-07-02 14:21:09 -0400294 local vca_host=$(cat $HOME/.local/share/juju/controllers.yaml | yq --arg CONTROLLER_NAME $CONTROLLER_NAME '.controllers[$CONTROLLER_NAME]["api-endpoints"][0]' --raw-output | cut -d ":" -f 1)
295 local vca_port=$(cat $HOME/.local/share/juju/controllers.yaml | yq --arg CONTROLLER_NAME $CONTROLLER_NAME '.controllers[$CONTROLLER_NAME]["api-endpoints"][0]' --raw-output | cut -d ":" -f 2)
Dominik Fleischmann5e4a7512020-03-06 14:05:06 +0100296 local vca_pubkey=\"$(cat $HOME/.local/share/juju/ssh/juju_id_rsa.pub)\"
297 local vca_cloud="lxd-cloud"
298 # Get the VCA Certificate
beierlm3749e312020-07-02 14:21:09 -0400299 local vca_cacert=$(cat $HOME/.local/share/juju/controllers.yaml | yq --arg CONTROLLER_NAME $CONTROLLER_NAME '.controllers[$CONTROLLER_NAME]["ca-cert"]' --raw-output | base64 | tr -d \\n)
Dominik Fleischmann5e4a7512020-03-06 14:05:06 +0100300
301 # Calculate the default route of this machine
Dominik Fleischmannc57296f2020-06-09 11:45:08 +0200302 local DEFAULT_IF=`ip route list match 0.0.0.0 | awk '{print $5}'`
Dominik Fleischmann5e4a7512020-03-06 14:05:06 +0100303
304 # Generate a new overlay.yaml, overriding any existing one
David Garcia42375212020-04-27 19:07:49 +0200305 cat << EOF > /tmp/vca-overlay.yaml
Dominik Fleischmann5e4a7512020-03-06 14:05:06 +0100306applications:
307 lcm-k8s:
308 options:
309 vca_user: $vca_user
310 vca_password: $vca_password
311 vca_host: $vca_host
312 vca_port: $vca_port
313 vca_pubkey: $vca_pubkey
314 vca_cacert: $vca_cacert
Dominik Fleischmann5e4a7512020-03-06 14:05:06 +0100315 vca_cloud: $vca_cloud
beierlma4a37f72020-06-26 12:55:01 -0400316 vca_k8s_cloud: $K8S_CLOUD_NAME
Dominik Fleischmann5e4a7512020-03-06 14:05:06 +0100317 mon-k8s:
318 options:
319 vca_user: $vca_user
320 vca_password: $vca_password
321 vca_host: $vca_host
322 vca_cacert: $vca_cacert
323EOF
David Garcia42375212020-04-27 19:07:49 +0200324 mv /tmp/vca-overlay.yaml ~/.osm/
325 OSM_VCA_HOST=$vca_host
Dominik Fleischmann5e4a7512020-03-06 14:05:06 +0100326}
327
David Garcia69388c22020-05-07 12:14:19 +0200328function generate_images_overlay(){
329 cat << EOF > /tmp/images-overlay.yaml
330applications:
331 lcm-k8s:
332 options:
333 image: opensourcemano/lcm:$TAG
334 mon-k8s:
335 options:
336 image: opensourcemano/mon:$TAG
337 ro-k8s:
338 options:
339 image: opensourcemano/ro:$TAG
340 nbi-k8s:
341 options:
342 image: opensourcemano/nbi:$TAG
343 pol-k8s:
344 options:
345 image: opensourcemano/pol:$TAG
346 ui-k8s:
347 options:
348 image: opensourcemano/light-ui:$TAG
beierlma4a37f72020-06-26 12:55:01 -0400349 pla:
350 options:
351 image: opensourcemano/pla:$TAG
352 ng-ui:
353 options:
354 image: opensourcemano/ng-ui:$TAG
David Garcia009a5d62020-08-27 16:53:44 +0200355 keystone:
356 options:
357 image: opensourcemano/keystone:$TAG
David Garcia69388c22020-05-07 12:14:19 +0200358
359EOF
360 mv /tmp/images-overlay.yaml $IMAGES_OVERLAY_FILE
361}
362
Dominik Fleischmann5e4a7512020-03-06 14:05:06 +0100363function install_osmclient() {
364 sudo snap install osmclient
365 sudo snap alias osmclient.osm osm
366}
367
Dominik Fleischmann5e4a7512020-03-06 14:05:06 +0100368
369function install_microstack() {
370 sudo snap install microstack --classic --beta
371 sudo microstack.init --auto
372 wget https://cloud-images.ubuntu.com/releases/16.04/release/ubuntu-16.04-server-cloudimg-amd64-disk1.img -P ~/.osm/
373 microstack.openstack image create \
David Garcia42375212020-04-27 19:07:49 +0200374 --public \
375 --disk-format qcow2 \
376 --container-format bare \
377 --file ~/.osm/ubuntu-16.04-server-cloudimg-amd64-disk1.img \
378 ubuntu1604
Dominik Fleischmann5e4a7512020-03-06 14:05:06 +0100379 ssh-keygen -t rsa -N "" -f ~/.ssh/microstack
380 microstack.openstack keypair create --public-key ~/.ssh/microstack.pub microstack
Dominik Fleischmannc57296f2020-06-09 11:45:08 +0200381 export OSM_HOSTNAME=`juju status --format json | jq -rc '.applications."nbi-k8s".address'`
Dominik Fleischmann5e4a7512020-03-06 14:05:06 +0100382 osm vim-create --name microstack-site \
David Garcia42375212020-04-27 19:07:49 +0200383 --user admin \
384 --password keystone \
385 --auth_url http://10.20.20.1:5000/v3 \
386 --tenant admin \
387 --account_type openstack \
388 --config='{security_groups: default,
389 keypair: microstack,
390 project_name: admin,
391 user_domain_name: default,
392 region_name: microstack,
393 insecure: True,
394 availability_zone: nova,
395 version: 3}'
Dominik Fleischmann5e4a7512020-03-06 14:05:06 +0100396}
397
Dominik Fleischmannc57296f2020-06-09 11:45:08 +0200398DEFAULT_IF=`ip route list match 0.0.0.0 | awk '{print $5}'`
Dominik Fleischmann5e4a7512020-03-06 14:05:06 +0100399DEFAULT_IP=`ip -o -4 a |grep ${DEFAULT_IF}|awk '{split($4,a,"/"); print a[1]}'`
400
401check_arguments $@
David Garcia42375212020-04-27 19:07:49 +0200402mkdir -p ~/.osm
Dominik Fleischmann5e4a7512020-03-06 14:05:06 +0100403install_snaps
404bootstrap_k8s_lxd
405deploy_charmed_osm
Dominik Fleischmann5e4a7512020-03-06 14:05:06 +0100406install_osmclient
David Garcia42375212020-04-27 19:07:49 +0200407if [ -v MICROSTACK ]; then
Dominik Fleischmann5e4a7512020-03-06 14:05:06 +0100408 install_microstack
409fi
beierlma4a37f72020-06-26 12:55:01 -0400410
beierlm7e54dfc2020-09-24 15:27:53 -0400411OSM_HOSTNAME=$(juju config nbi-k8s juju-external-hostname):443
412
beierlma4a37f72020-06-26 12:55:01 -0400413echo "Your installation is now complete, follow these steps for configuring the osmclient:"
414echo
415echo "1. Create the OSM_HOSTNAME environment variable with the NBI IP"
416echo
beierlm7e54dfc2020-09-24 15:27:53 -0400417echo "export OSM_HOSTNAME=$OSM_HOSTNAME"
beierlma4a37f72020-06-26 12:55:01 -0400418echo
419echo "2. Add the previous command to your .bashrc for other Shell sessions"
420echo
beierlm7e54dfc2020-09-24 15:27:53 -0400421echo "echo \"export OSM_HOSTNAME=$OSM_HOSTNAME\" >> ~/.bashrc"
beierlma4a37f72020-06-26 12:55:01 -0400422echo
423echo "DONE"