echo -e " --elk_stack: additionally deploy an ELK docker stack for event logging"
echo -e " --pla: install the PLA module for placement support"
echo -e " -m <MODULE>: install OSM but only rebuild the specified docker images (LW-UI, NBI, LCM, RO, MON, POL, KAFKA, MONGO, PROMETHEUS, PROMETHEUS-CADVISOR, KEYSTONE-DB, PLA, NONE)"
- echo -e " -o <ADDON>: ONLY (un)installs one of the addons (vimemu, elk_stack)"
+ echo -e " -o <ADDON>: ONLY (un)installs one of the addons (vimemu, elk_stack, k8s_monitor)"
echo -e " -D <devops path> use local devops installation path"
echo -e " -w <work dir> Location to store runtime installation"
echo -e " -t <docker tag> specify osm docker tag (default is latest)"
echo -e " -l: LXD cloud yaml file"
echo -e " -L: LXD credentials yaml file"
+ echo -e " -K: Specifies the name of the controller to use - The controller must be already bootstrapped"
echo -e " --nolxd: do not install and configure LXD, allowing unattended installations (assumes LXD is already installed and confifured)"
echo -e " --nodocker: do not install docker, do not initialize a swarm (assumes docker is already installed and a swarm has been initialized)"
echo -e " --nojuju: do not juju, assumes already installed"
echo -e " --source: install OSM from source code using the latest stable tag"
echo -e " --develop: (deprecated, use '-b master') install OSM from source code using the master branch"
echo -e " --pullimages: pull/run osm images from docker.io/opensourcemano"
- echo -e " --k8s_monitor: install the OSM kubernetes moitoring with prometheus and grafana"
+ echo -e " --k8s_monitor: install the OSM kubernetes monitoring with prometheus and grafana"
# echo -e " --reconfigure: reconfigure the modules (DO NOT change NAT rules)"
# echo -e " --update: update to the latest stable release or to the latest commit if using a specific branch"
echo -e " --showopts: print chosen options and exit (only for debugging)"
echo -e " --charmed: install OSM with charms"
echo -e " --bundle <bundle path>: Specify with which bundle to deploy OSM with charms (--charmed option)"
echo -e " --kubeconfig <kubeconfig path>: Specify with which kubernetes to deploy OSM with charms (--charmed option)"
- echo -e " --lxdendpoint <lxd endpoint ip>: Specify with which LXD to deploy OSM with charms (--charmed option)"
- echo -e " --lxdcert <lxd cert path>: Specify external LXD cert to deploy OSM with charms (--charmed option)"
+ echo -e " --controller <name>: Specifies the name of the controller to use - The controller must be already bootstrapped (--charmed option)"
+ echo -e " --lxd-cloud <yaml path>: Takes a YAML file as a parameter with the LXD Cloud information (--charmed option)"
+ echo -e " --lxd-credentials <yaml path>: Takes a YAML file as a parameter with the LXD Credentials information (--charmed option)"
echo -e " --microstack: Installs microstack as a vim. (--charmed option)"
+ echo -e " --tag: Docker image tag"
}
fi
if [ -z "$DEFAULT_IP" ]; then
- DEFAULT_IF=`route -n |awk '$1~/^0.0.0.0/ {print $8}'`
+ DEFAULT_IF=$(ip route list|awk '$1=="default" {print $5; exit}')
+ [ -z "$DEFAULT_IF" ] && DEFAULT_IF=$(route -n |awk '$1~/^0.0.0.0/ {print $8; exit}')
[ -z "$DEFAULT_IF" ] && FATAL "Not possible to determine the interface with the default route 0.0.0.0"
DEFAULT_IP=`ip -o -4 a |grep ${DEFAULT_IF}|awk '{split($4,a,"/"); print a[1]}'`
[ -z "$DEFAULT_IP" ] && FATAL "Not possible to determine the IP address of the interface with the default route"
kubectl delete ns $1
}
+#removes helm only if there is nothing deployed in helm
+function remove_helm() {
+ if [ "$(helm ls -q)" == "" ] ; then
+ sudo helm reset --force
+ kubectl delete --namespace kube-system serviceaccount tiller
+ kubectl delete clusterrolebinding tiller-cluster-rule
+ sudo rm /usr/local/bin/helm
+ rm -rf $HOME/.helm
+ fi
+}
+
+#Uninstall osmclient
+function uninstall_osmclient() {
+ sudo apt-get remove --purge -y python-osmclient
+ sudo apt-get remove --purge -y python3-osmclient
+}
+
#Uninstall lightweight OSM: remove dockers
function uninstall_lightweight() {
if [ -n "$INSTALL_ONLY" ]; then
remove_volumes $OSM_STACK_NAME
remove_network $OSM_STACK_NAME
fi
- remove_iptables $OSM_STACK_NAME
+ [ -z "$CONTROLLER_NAME" ] && remove_iptables $OSM_STACK_NAME
echo "Removing $OSM_DOCKER_WORK_DIR"
$WORKDIR_SUDO rm -rf $OSM_DOCKER_WORK_DIR
- sg lxd -c "juju destroy-controller --destroy-all-models --yes $OSM_STACK_NAME"
+ [ -z "$CONTROLLER_NAME" ] && sg lxd -c "juju destroy-controller --destroy-all-models --yes $OSM_STACK_NAME"
fi
+ uninstall_osmclient
echo "Some docker images will be kept in case they are used by other docker stacks"
echo "To remove them, just run 'docker image prune' in a terminal"
return 0
# Install LXD snap
sudo apt-get remove --purge -y liblxc1 lxc-common lxcfs lxd lxd-client
- sudo snap install lxd --channel=3.0/stable
+ sudo snap install lxd
+ sudo apt-get install zfsutils-linux -y
# Configure LXD
sudo usermod -a -G lxd `whoami`
- cat /usr/share/osm-devops/installers/lxd-preseed.conf | sg lxd -c "lxd init --preseed"
+ cat /usr/share/osm-devops/installers/lxd-preseed.conf | sed 's/^config: {}/config:\n core.https_address: '$DEFAULT_IP':8443/' | sg lxd -c "lxd init --preseed"
sg lxd -c "lxd waitready"
- DEFAULT_INTERFACE=$(route -n | awk '$1~/^0.0.0.0/ {print $8}')
+ DEFAULT_INTERFACE=$(ip route list|awk '$1=="default" {print $5; exit}')
+ [ -z "$DEFAULT_INTERFACE" ] && DEFAULT_INTERFACE=$(route -n |awk '$1~/^0.0.0.0/ {print $8; exit}')
DEFAULT_MTU=$(ip addr show $DEFAULT_INTERFACE | perl -ne 'if (/mtu\s(\d+)/) {print $1;}')
sg lxd -c "lxc profile device set default eth0 mtu $DEFAULT_MTU"
#sudo systemctl stop lxd-bridge
echo "Creating user node_exporter"
sudo useradd --no-create-home --shell /bin/false node_exporter
fi
- sudo wget -q https://github.com/prometheus/node_exporter/releases/download/v$PROMETHEUS_NODE_EXPORTER_TAG/node_exporter-$PROMETHEUS_NODE_EXPORTER_TAG.linux-amd64.tar.gz -P /tmp/
+ wget -q https://github.com/prometheus/node_exporter/releases/download/v$PROMETHEUS_NODE_EXPORTER_TAG/node_exporter-$PROMETHEUS_NODE_EXPORTER_TAG.linux-amd64.tar.gz -P /tmp/
sudo tar -C /tmp -xf /tmp/node_exporter-$PROMETHEUS_NODE_EXPORTER_TAG.linux-amd64.tar.gz
sudo cp /tmp/node_exporter-$PROMETHEUS_NODE_EXPORTER_TAG.linux-amd64/node_exporter /usr/local/bin
sudo chown node_exporter:node_exporter /usr/local/bin/node_exporter
- sudo rm -rf node_exporter-$PROMETHEUS_NODE_EXPORTER_TAG.linux-amd64*
+ sudo rm -rf /tmp/node_exporter-$PROMETHEUS_NODE_EXPORTER_TAG.linux-amd64*
sudo cp ${OSM_DEVOPS}/installers/docker/prometheus/node_exporter.service /etc/systemd/system/node_exporter.service
sudo systemctl daemon-reload
sudo systemctl restart node_exporter
function juju_createcontroller() {
if ! juju show-controller $OSM_STACK_NAME &> /dev/null; then
# Not found created, create the controller
- [ -n "$LXD_CLOUD_FILE" ] && OSM_VCA_CLOUDNAME="lxd-cloud"
sudo usermod -a -G lxd ${USER}
sg lxd -c "juju bootstrap --bootstrap-series=xenial $OSM_VCA_CLOUDNAME $OSM_STACK_NAME"
fi
kubectl apply -n $OSM_STACK_NAME -f $OSM_DOCKER_WORK_DIR/osm_pla
}
+#Install helm and tiller
+function install_helm() {
+ helm > /dev/null 2>&1
+ if [ $? != 0 ] ; then
+ # Helm is not installed. Install helm
+ curl https://get.helm.sh/helm-v2.15.2-linux-amd64.tar.gz --output helm-v2.15.2.tar.gz
+ tar -zxvf helm-v2.15.2.tar.gz
+ sudo mv linux-amd64/helm /usr/local/bin/helm
+ rm -r linux-amd64
+ rm helm-v2.15.2.tar.gz
+ fi
+
+ # Checking if tiller has being configured
+ kubectl --namespace kube-system get serviceaccount tiller > /dev/null 2>&1
+ if [ $? == 1 ] ; then
+ # tiller account for kubernetes
+ kubectl --namespace kube-system create serviceaccount tiller
+ kubectl create clusterrolebinding tiller-cluster-rule --clusterrole=cluster-admin --serviceaccount=kube-system:tiller
+ # HELM initialization
+ helm init --service-account tiller
+
+ # Wait for Tiller to be up and running. If timeout expires, continue installing
+ tiller_timeout=120; counter=0
+ while (( counter < tiller_timeout ))
+ do
+ tiller_status=`kubectl -n kube-system get deployment.apps/tiller-deploy --no-headers | awk '{print $2'}`
+ ( [ ! -z "$tiller_status" ] && [ $tiller_status == "1/1" ] ) && break
+ num=$((counter + 2))
+ sleep 2
+ done
+ fi
+}
+
function parse_yaml() {
osm_services="nbi lcm ro pol mon light-ui keystone"
TAG=$1
echo "Installing lightweight build of OSM"
LWTEMPDIR="$(mktemp -d -q --tmpdir "installosmlight.XXXXXX")"
trap 'rm -rf "${LWTEMPDIR}"' EXIT
- DEFAULT_IF=`route -n |awk '$1~/^0.0.0.0/ {print $8}'`
+ DEFAULT_IF=$(ip route list|awk '$1=="default" {print $5; exit}')
+ [ -z "$DEFAULT_IF" ] && DEFAULT_IF=$(route -n |awk '$1~/^0.0.0.0/ {print $8; exit}')
[ -z "$DEFAULT_IF" ] && FATAL "Not possible to determine the interface with the default route 0.0.0.0"
- DEFAULT_IP=`ip -o -4 a |grep ${DEFAULT_IF}|awk '{split($4,a,"/"); print a[1]}'`
+ DEFAULT_IP=`ip -o -4 a |grep ${DEFAULT_IF} |awk '{split($4,a,"/"); print a[1]}'`
[ -z "$DEFAULT_IP" ] && FATAL "Not possible to determine the IP address of the interface with the default route"
DEFAULT_MTU=$(ip addr show ${DEFAULT_IF} | perl -ne 'if (/mtu\s(\d+)/) {print $1;}')
[ -z "$INSTALL_NOJUJU" ] && install_juju
track juju_install
-
- if [ -n "$LXD_CLOUD_FILE" ]; then
- [ -z "$LXD_CRED_FILE" ] && FATAL "The installer needs the LXD credential yaml if the LXD is external"
- juju add-cloud lxd-cloud $LXD_CLOUD_FILE --force || juju update-cloud lxd-cloud --client -f $LXD_CLOUD_FILE
- juju add-credential lxd-cloud -f $LXD_CRED_FILE || juju update-credential lxd-cloud lxd-cloud-creds -f $LXD_CRED_FILE
- fi
if [ -z "$OSM_VCA_HOST" ]; then
- juju_createcontroller
- OSM_VCA_HOST=`sg lxd -c "juju show-controller $OSM_STACK_NAME"|grep api-endpoints|awk -F\' '{print $2}'|awk -F\: '{print $1}'`
+ if [ -z "$CONTROLLER_NAME" ]; then
+ if [ -n "$LXD_CLOUD_FILE" ]; then
+ [ -z "$LXD_CRED_FILE" ] && FATAL "The installer needs the LXD credential yaml if the LXD is external"
+ OSM_VCA_CLOUDNAME="lxd-cloud"
+ juju add-cloud $OSM_VCA_CLOUDNAME $LXD_CLOUD_FILE --force || juju update-cloud $OSM_VCA_CLOUDNAME --client -f $LXD_CLOUD_FILE
+ juju add-credential $OSM_VCA_CLOUDNAME -f $LXD_CRED_FILE || juju update-credential $OSM_VCA_CLOUDNAME lxd-cloud-creds -f $LXD_CRED_FILE
+ fi
+ juju_createcontroller
+ else
+ OSM_VCA_CLOUDNAME="lxd-cloud"
+ if [ -n "$LXD_CLOUD_FILE" ]; then
+ [ -z "$LXD_CRED_FILE" ] && FATAL "The installer needs the LXD credential yaml if the LXD is external"
+ juju add-cloud -c $CONTROLLER_NAME $OSM_VCA_CLOUDNAME $LXD_CLOUD_FILE --force || juju update-cloud lxd-cloud -c $CONTROLLER_NAME -f $LXD_CLOUD_FILE
+ juju add-credential -c $CONTROLLER_NAME $OSM_VCA_CLOUDNAME -f $LXD_CRED_FILE || juju update-credential lxd-cloud -c $CONTROLLER_NAME -f $LXD_CRED_FILE
+ else
+ mkdir -p ~/.osm
+ cat << EOF > ~/.osm/lxd-cloud.yaml
+clouds:
+ lxd-cloud:
+ type: lxd
+ auth-types: [certificate]
+ endpoint: "https://$DEFAULT_IP:8443"
+ config:
+ ssl-hostname-verification: false
+EOF
+ 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"
+ local server_cert=`cat /var/snap/lxd/common/lxd/server.crt | sed 's/^/ /'`
+ local client_cert=`cat ~/.osm/client.crt | sed 's/^/ /'`
+ local client_key=`cat ~/.osm/client.key | sed 's/^/ /'`
+ cat << EOF > ~/.osm/lxd-credentials.yaml
+credentials:
+ lxd-cloud:
+ lxd-cloud:
+ auth-type: certificate
+ server-cert: |
+$server_cert
+ client-cert: |
+$client_cert
+ client-key: |
+$client_key
+EOF
+ lxc config trust add local: ~/.osm/client.crt
+ juju add-cloud -c $CONTROLLER_NAME $OSM_VCA_CLOUDNAME ~/.osm/lxd-cloud.yaml --force || juju update-cloud lxd-cloud -c $CONTROLLER_NAME -f ~/.osm/lxd-cloud.yaml
+ juju add-credential -c $CONTROLLER_NAME $OSM_VCA_CLOUDNAME -f ~/.osm/lxd-credentials.yaml || juju update-credential lxd-cloud -c $CONTROLLER_NAME -f ~/.osm/lxd-credentials.yaml
+ fi
+ fi
+ [ -z "$CONTROLLER_NAME" ] && OSM_VCA_HOST=`sg lxd -c "juju show-controller $OSM_STACK_NAME"|grep api-endpoints|awk -F\' '{print $2}'|awk -F\: '{print $1}'`
+ [ -n "$CONTROLLER_NAME" ] && OSM_VCA_HOST=`juju show-controller $CONTROLLER_NAME |grep api-endpoints|awk -F\' '{print $2}'|awk -F\: '{print $1}'`
[ -z "$OSM_VCA_HOST" ] && FATAL "Cannot obtain juju controller IP address"
fi
track juju_controller
if [ -z "$OSM_VCA_SECRET" ]; then
- OSM_VCA_SECRET=$(parse_juju_password $OSM_STACK_NAME)
+ [ -z "$CONTROLLER_NAME" ] && OSM_VCA_SECRET=$(parse_juju_password $OSM_STACK_NAME)
+ [ -n "$CONTROLLER_NAME" ] && OSM_VCA_SECRET=$(parse_juju_password $CONTROLLER_NAME)
[ -z "$OSM_VCA_SECRET" ] && FATAL "Cannot obtain juju secret"
fi
if [ -z "$OSM_VCA_PUBKEY" ]; then
[ -z "$OSM_VCA_PUBKEY" ] && FATAL "Cannot obtain juju public key"
fi
if [ -z "$OSM_VCA_CACERT" ]; then
- OSM_VCA_CACERT=$(juju controllers --format json | jq -r '.controllers["osm"]["ca-cert"]' | base64 | tr -d \\n)
+ [ -z "$CONTROLLER_NAME" ] && OSM_VCA_CACERT=$(juju controllers --format json | jq -r --arg controller $OSM_STACK_NAME '.controllers[$controller]["ca-cert"]' | base64 | tr -d \\n)
+ [ -n "$CONTROLLER_NAME" ] && OSM_VCA_CACERT=$(juju controllers --format json | jq -r --arg controller $CONTROLLER_NAME '.controllers[$controller]["ca-cert"]' | base64 | tr -d \\n)
[ -z "$OSM_VCA_CACERT" ] && FATAL "Cannot obtain juju CA certificate"
fi
if [ -z "$OSM_VCA_APIPROXY" ]; then
K8S_MANIFEST_DIR="/etc/kubernetes/manifests"
RE_CHECK='^[a-z0-9]([-a-z0-9]*[a-z0-9])?$'
-while getopts ":b:r:c:k:u:R:D:o:m:H:S:s:w:t:U:P:A:l:L:-: hy" o; do
+while getopts ":b:r:c:k:u:R:D:o:m:H:S:s:w:t:U:P:A:l:L:K:-: hy" o; do
case "${o}" in
b)
COMMIT_ID=${OPTARG}
L)
LXD_CRED_FILE="${OPTARG}"
;;
+ K)
+ CONTROLLER_NAME="${OPTARG}"
+ ;;
-)
[ "${OPTARG}" == "help" ] && usage && exit 0
[ "${OPTARG}" == "source" ] && INSTALL_FROM_SOURCE="y" && PULL_IMAGES="" && continue
[ "${OPTARG}" == "lxdendpoint" ] && continue
[ "${OPTARG}" == "lxdcert" ] && continue
[ "${OPTARG}" == "microstack" ] && continue
+ [ "${OPTARG}" == "tag" ] && continue
[ "${OPTARG}" == "pla" ] && INSTALL_PLA="y" && continue
echo -e "Invalid option: '--$OPTARG'\n" >&2
usage && exit 1
# if develop, we force master
[ -z "$COMMIT_ID" ] && [ -n "$DEVELOP" ] && COMMIT_ID="master"
-need_packages="git jq wget curl tar"
+need_packages="git wget curl tar"
echo -e "Checking required packages: $need_packages"
dpkg -l $need_packages &>/dev/null \
|| ! echo -e "One or several required packages are not installed. Updating apt cache requires root privileges." \
|| ! echo -e "Installing $need_packages requires root privileges." \
|| sudo apt-get install -y $need_packages \
|| FATAL "failed to install $need_packages"
-
+sudo snap install jq
if [ -z "$OSM_DEVOPS" ]; then
if [ -n "$TEST_INSTALLER" ]; then
echo -e "\nUsing local devops repo for OSM installation"
track end
echo -e "\nDONE"
+