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