K8S_CLOUD_NAME="k8s-cloud"
KUBECTL="microk8s.kubectl"
MICROK8S_VERSION=1.19
+OSMCLIENT_VERSION=9.0
IMAGES_OVERLAY_FILE=~/.osm/images-overlay.yaml
PATH=/snap/bin:${PATH}
OSM_BUNDLE=cs:osm-54
OSM_HA_BUNDLE=cs:osm-ha-40
+TAG=9
function check_arguments(){
while [ $# -gt 0 ] ; do
function install_snaps(){
if [ ! -v KUBECFG ]; then
sudo snap install microk8s --classic --channel=${MICROK8S_VERSION}/stable
+ cat /var/snap/microk8s/current/args/kube-apiserver | grep advertise-address || (
+ echo "--advertise-address $DEFAULT_IP" | sudo tee -a /var/snap/microk8s/current/args/kube-apiserver
+ microk8s.stop
+ microk8s.start
+ )
sudo usermod -a -G microk8s `whoami`
mkdir -p ~/.kube
sudo chown -f -R `whoami` ~/.kube
KUBEGRP="microk8s"
sg ${KUBEGRP} -c "microk8s status --wait-ready"
KUBECONFIG=~/.osm/microk8s-config.yaml
- sg ${KUBEGRP} -c "microk8s config" > ${KUBECONFIG}
+ sg ${KUBEGRP} -c "microk8s config" | tee ${KUBECONFIG}
else
KUBECTL="kubectl"
sudo snap install kubectl --classic
mv /tmp/images-overlay.yaml $IMAGES_OVERLAY_FILE
}
+function refresh_osmclient_snap() {
+ osmclient_snap_install_refresh refresh
+}
+
+function install_osm_client_snap() {
+ osmclient_snap_install_refresh install
+}
+
+function osmclient_snap_install_refresh() {
+ channel_preference="stable candidate beta edge"
+ for channel in $channel_preference; do
+ echo "Trying to install osmclient from channel $OSMCLIENT_VERSION/$channel"
+ sudo snap $1 osmclient --channel $OSMCLIENT_VERSION/$channel 2> /dev/null && echo osmclient snap installed && break
+ done
+}
function install_osmclient() {
- sudo snap install osmclient
- sudo snap alias osmclient.osm osm
+ snap info osmclient | grep -E ^installed: && refresh_osmclient_snap || install_osm_client_snap
}
function add_local_k8scluster() {