From: Dominik Fleischmann Date: Tue, 30 Jun 2020 12:25:19 +0000 (+0200) Subject: 8716 - K8s Proxy Charms X-Git-Tag: v8.0.0rc2~12 X-Git-Url: https://osm.etsi.org/gitweb/?a=commitdiff_plain;h=refs%2Fchanges%2F33%2F9233%2F3;p=osm%2Fdevops.git 8716 - K8s Proxy Charms This commit contains the following changes: - Changes to LCM Charm to configure vca k8s cloud - K8s installation: - Add storageclass to K8s - Add k8s to VCA - Configure lcm.env to pass k8s cloud name - Pass k8s cloud name to LCM Charm in charmed installation - Pin juju version tu 2.8/stable - Instal juju after Microk8s in charmed installation Change-Id: I62ae50e4f226eba3bbda7c4a310cfe52591de5b4 Signed-off-by: Dominik Fleischmann --- diff --git a/installers/charm/lcm-k8s/config.yaml b/installers/charm/lcm-k8s/config.yaml index c27377fc..04554874 100644 --- a/installers/charm/lcm-k8s/config.yaml +++ b/installers/charm/lcm-k8s/config.yaml @@ -44,6 +44,10 @@ options: type: string description: "The VCA lxd cloud name" default: "localhost" + vca_k8s_cloud: + type: string + description: "The VCA K8s cloud name" + default: "k8scloud" advertised-hostname: description: LCM Hostname type: string diff --git a/installers/charm/lcm-k8s/reactive/spec_template.yaml b/installers/charm/lcm-k8s/reactive/spec_template.yaml index 1a270965..82a76e09 100644 --- a/installers/charm/lcm-k8s/reactive/spec_template.yaml +++ b/installers/charm/lcm-k8s/reactive/spec_template.yaml @@ -47,3 +47,4 @@ containers: OSMLCM_VCA_CACERT: %(vca_cacert)s OSMLCM_VCA_APIPROXY: %(vca_apiproxy)s OSMLCM_VCA_CLOUD: %(vca_cloud)s + OSMLCM_VCA_K8S_CLOUD: %(vca_k8s_cloud)s diff --git a/installers/charmed_install.sh b/installers/charmed_install.sh index 49bf277b..d2156084 100755 --- a/installers/charmed_install.sh +++ b/installers/charmed_install.sh @@ -35,8 +35,8 @@ function check_arguments(){ # echo $BUNDLE $KUBECONFIG $LXDENDPOINT } function install_snaps(){ - sudo snap install juju --classic --channel=2.7/stable [ ! -v KUBECFG ] && sudo snap install microk8s --classic && sudo usermod -a -G microk8s `whoami` && mkdir -p ~/.kube && sudo chown -f -R `whoami` ~/.kube + sudo snap install juju --classic --channel=2.8/stable } function bootstrap_k8s_lxd(){ @@ -118,6 +118,7 @@ EOF juju add-credential -c $CONTROLLER_NAME lxd-cloud -f $LXD_CREDENTIALS sg lxd -c "lxd waitready" juju add-model test lxd-cloud || true + juju controller-config features=[k8s-operators] } function deploy_charmed_osm(){ @@ -191,6 +192,7 @@ applications: vca_cacert: $vca_cacert vca_apiproxy: $vca_apiproxy vca_cloud: $vca_cloud + vca_k8s_cloud: $K8S_CLOUD_NAME mon-k8s: options: vca_user: $vca_user diff --git a/installers/full_install_osm.sh b/installers/full_install_osm.sh index 15cd1f38..243b0cc7 100755 --- a/installers/full_install_osm.sh +++ b/installers/full_install_osm.sh @@ -412,7 +412,7 @@ function install_docker_compose() { function install_juju() { echo "Installing juju" - sudo snap install juju --classic --channel=2.7/stable + sudo snap install juju --classic --channel=2.8/stable [[ ":$PATH": != *":/snap/bin:"* ]] && PATH="/snap/bin:${PATH}" echo "Finished installation of juju" return 0 @@ -425,6 +425,11 @@ function juju_createcontroller() { sg lxd -c "juju bootstrap --bootstrap-series=xenial $OSM_VCA_CLOUDNAME $OSM_STACK_NAME" fi [ $(juju controllers | awk "/^${OSM_STACK_NAME}[\*| ]/{print $1}"|wc -l) -eq 1 ] || FATAL "Juju installation failed" + + if [ -n "$KUBERNETES" ]; then + cat .kube/config | juju add-k8s $OSM_VCA_K8S_CLOUDNAME --controller $OSM_STACK_NAME + fi + juju controller-config features=[k8s-operators] } function juju_createproxy() { @@ -664,6 +669,12 @@ function generate_docker_env_files() { $WORKDIR_SUDO sed -i "s|OSMLCM_VCA_CLOUD.*|OSMLCM_VCA_CLOUD=${OSM_VCA_CLOUDNAME}|g" $OSM_DOCKER_WORK_DIR/lcm.env fi + if ! grep -Fq "OSMLCM_VCA_K8S_CLOUD" $OSM_DOCKER_WORK_DIR/lcm.env; then + echo "OSMLCM_VCA_K8S_CLOUD=${OSM_VCA_K8S_CLOUDNAME}" | $WORKDIR_SUDO tee -a $OSM_DOCKER_WORK_DIR/lcm.env + else + $WORKDIR_SUDO sed -i "s|OSMLCM_VCA_K8S_CLOUD.*|OSMLCM_VCA_K8S_CLOUD=${OSM_VCA_K8S_CLOUDNAME}|g" $OSM_DOCKER_WORK_DIR/lcm.env + fi + # RO MYSQL_ROOT_PASSWORD=$(generate_secret) if [ ! -f $OSM_DOCKER_WORK_DIR/ro-db.env ]; then @@ -765,6 +776,11 @@ function kube_config_dir() { sudo chown $(id -u):$(id -g) $HOME/.kube/config } +function install_k8s_storageclass() { + kubectl apply -f https://openebs.github.io/charts/openebs-operator-1.6.0.yaml + kubectl patch storageclass openebs-hostpath -p '{"metadata": {"annotations":{"storageclass.kubernetes.io/is-default-class":"true"}}}' +} + #deploys flannel as daemonsets function deploy_cni_provider() { CNI_DIR="$(mktemp -d -q --tmpdir "flannel.XXXXXX")" @@ -1121,6 +1137,7 @@ EOF track install_k8s init_kubeadm $OSM_DOCKER_WORK_DIR/cluster-config.yaml kube_config_dir + install_k8s_storage_class track init_k8s else #install_docker_compose @@ -1347,6 +1364,7 @@ OSM_VCA_HOST= OSM_VCA_SECRET= OSM_VCA_PUBKEY= OSM_VCA_CLOUDNAME="localhost" +OSM_VCA_K8S_CLOUDNAME="k8scloud" OSM_STACK_NAME=osm NO_HOST_PORTS="" DOCKER_NOBUILD=""