From 1017dfb6ee22283a3069d7f9badb8a3212a1a10f Mon Sep 17 00:00:00 2001 From: gkatsikas <gkatsikas@ubitech.eu> Date: Fri, 5 Aug 2022 11:40:17 +0300 Subject: [PATCH] refactor: fix tutorial deployment issues Signed-off-by: gkatsikas <gkatsikas@ubitech.eu> --- expose_ingress_grpc.sh | 3 ++- .../old/open_dashboard.sh | 2 +- open_webui.sh => scripts/old/open_webui.sh | 21 +++++++++---------- scripts/show_logs_automation.sh | 2 +- scripts/show_logs_compute.sh | 2 +- scripts/show_logs_context.sh | 2 +- scripts/show_logs_device.sh | 2 +- scripts/show_logs_monitoring.sh | 2 +- scripts/show_logs_service.sh | 2 +- scripts/show_logs_webui.sh | 2 +- show_deploy.sh | 2 +- tutorial/1-2-install-microk8s.md | 11 +++++++++- tutorial/2-1-python-environment.md | 14 +++++++++++++ 13 files changed, 45 insertions(+), 22 deletions(-) rename open_dashboard.sh => scripts/old/open_dashboard.sh (96%) rename open_webui.sh => scripts/old/open_webui.sh (70%) diff --git a/expose_ingress_grpc.sh b/expose_ingress_grpc.sh index 8a4c83740..e2667247a 100755 --- a/expose_ingress_grpc.sh +++ b/expose_ingress_grpc.sh @@ -18,7 +18,7 @@ ######################################################################################################################## # If not already set, set the name of the Kubernetes namespace to deploy to. -export TFS_K8S_NAMESPACE=${TFS_K8S_NAMESPACE:-"tfs-dev"} +export TFS_K8S_NAMESPACE=${TFS_K8S_NAMESPACE:-"tfs"} # If not already set, set the list of components you want to build images for, and deploy. export TFS_COMPONENTS=${TFS_COMPONENTS:-"context device automation policy service compute monitoring dbscanserving opticalattackmitigator opticalcentralizedattackdetector webui"} @@ -32,6 +32,7 @@ for COMPONENT in $TFS_COMPONENTS; do echo "Processing '$COMPONENT' component..." SERVICE_GRPC_PORT=$(kubectl get service ${COMPONENT}service --namespace $TFS_K8S_NAMESPACE -o 'jsonpath={.spec.ports[?(@.name=="grpc")].port}') + echo " '$COMPONENT' service port: $SERVICE_GRPC_PORT" if [ -z "${SERVICE_GRPC_PORT}" ]; then printf "\n" continue; diff --git a/open_dashboard.sh b/scripts/old/open_dashboard.sh similarity index 96% rename from open_dashboard.sh rename to scripts/old/open_dashboard.sh index 8291a22c7..a3864d2d0 100755 --- a/open_dashboard.sh +++ b/scripts/old/open_dashboard.sh @@ -16,7 +16,7 @@ # this script opens the dashboard -K8S_NAMESPACE=${K8S_NAMESPACE:-'tf-dev'} +K8S_NAMESPACE=${K8S_NAMESPACE:-'tfs'} GRAFANA_IP=$(kubectl get service/webuiservice -n ${K8S_NAMESPACE} -o jsonpath='{.spec.clusterIP}') GRAFANA_PORT=$(kubectl get service webuiservice-public --namespace $K8S_NAMESPACE -o 'jsonpath={.spec.ports[?(@.port==3000)].nodePort}') diff --git a/open_webui.sh b/scripts/old/open_webui.sh similarity index 70% rename from open_webui.sh rename to scripts/old/open_webui.sh index e4dfdb709..2d4659bf6 100755 --- a/open_webui.sh +++ b/scripts/old/open_webui.sh @@ -14,10 +14,9 @@ # this script opens the webui -K8S_NAMESPACE=${K8S_NAMESPACE:-'tf-dev'} +K8S_NAMESPACE=${K8S_NAMESPACE:-'tfs'} -WEBUI_SERVICE_NAME="webuiservice-public" -WEBUI_PROTO=`kubectl get service ${WEBUI_SERVICE_NAME} -n ${K8S_NAMESPACE} -o jsonpath='{.spec.ports[0].name}'` +WEBUI_SERVICE_NAME="webuiservice" WEBUI_IP=`kubectl get service ${WEBUI_SERVICE_NAME} -n ${K8S_NAMESPACE} -o jsonpath='{.spec.clusterIP}'` # WEBUI_PORT=$(kubectl get service ${WEBUI_SERVICE_NAME} --namespace $K8S_NAMESPACE -o 'jsonpath={.spec.ports[?(@.port==8004)].nodePort}') WEBUI_PORT=8004 @@ -25,13 +24,13 @@ WEBUI_PORT=8004 GRAFANA_PORT=3000 # Open WebUI -URL=${WEBUI_PROTO}://${WEBUI_IP}:${WEBUI_PORT} -echo Opening web UI on URL ${URL} -# curl -kL ${URL} -python3 -m webbrowser ${URL} +UI_URL="http://${WEBUI_IP}:${WEBUI_PORT}" +echo "Opening web UI on URL ${UI_URL}" +# curl -kL ${UI_URL} +python3 -m webbrowser ${UI_URL} # Open Dashboard -URL=${WEBUI_PROTO}://${WEBUI_IP}:${GRAFANA_PORT} -echo Opening Dashboard on URL ${URL} -# curl -kL ${URL} -python3 -m webbrowser ${URL} +DASHB_URL="http://${WEBUI_IP}:${GRAFANA_PORT}" +echo "Opening Dashboard on URL ${DASHB_URL}" +# curl -kL ${DASHB_URL} +python3 -m webbrowser ${DASHB_URL} diff --git a/scripts/show_logs_automation.sh b/scripts/show_logs_automation.sh index 8823f29c0..0c0615d99 100755 --- a/scripts/show_logs_automation.sh +++ b/scripts/show_logs_automation.sh @@ -18,7 +18,7 @@ ######################################################################################################################## # If not already set, set the name of the Kubernetes namespace to deploy to. -export TFS_K8S_NAMESPACE=${TFS_K8S_NAMESPACE:-"tfs-dev"} +export TFS_K8S_NAMESPACE=${TFS_K8S_NAMESPACE:-"tfs"} ######################################################################################################################## # Automated steps start here diff --git a/scripts/show_logs_compute.sh b/scripts/show_logs_compute.sh index 5e061bb9e..759918f11 100755 --- a/scripts/show_logs_compute.sh +++ b/scripts/show_logs_compute.sh @@ -18,7 +18,7 @@ ######################################################################################################################## # If not already set, set the name of the Kubernetes namespace to deploy to. -export TFS_K8S_NAMESPACE=${TFS_K8S_NAMESPACE:-"tfs-dev"} +export TFS_K8S_NAMESPACE=${TFS_K8S_NAMESPACE:-"tfs"} ######################################################################################################################## # Automated steps start here diff --git a/scripts/show_logs_context.sh b/scripts/show_logs_context.sh index ece545a7e..f4b6c620b 100755 --- a/scripts/show_logs_context.sh +++ b/scripts/show_logs_context.sh @@ -18,7 +18,7 @@ ######################################################################################################################## # If not already set, set the name of the Kubernetes namespace to deploy to. -export TFS_K8S_NAMESPACE=${TFS_K8S_NAMESPACE:-"tfs-dev"} +export TFS_K8S_NAMESPACE=${TFS_K8S_NAMESPACE:-"tfs"} ######################################################################################################################## # Automated steps start here diff --git a/scripts/show_logs_device.sh b/scripts/show_logs_device.sh index e1c2e4aa8..d3ef781c9 100755 --- a/scripts/show_logs_device.sh +++ b/scripts/show_logs_device.sh @@ -18,7 +18,7 @@ ######################################################################################################################## # If not already set, set the name of the Kubernetes namespace to deploy to. -export TFS_K8S_NAMESPACE=${TFS_K8S_NAMESPACE:-"tfs-dev"} +export TFS_K8S_NAMESPACE=${TFS_K8S_NAMESPACE:-"tfs"} ######################################################################################################################## # Automated steps start here diff --git a/scripts/show_logs_monitoring.sh b/scripts/show_logs_monitoring.sh index 597803512..bd37d0d14 100755 --- a/scripts/show_logs_monitoring.sh +++ b/scripts/show_logs_monitoring.sh @@ -18,7 +18,7 @@ ######################################################################################################################## # If not already set, set the name of the Kubernetes namespace to deploy to. -export TFS_K8S_NAMESPACE=${TFS_K8S_NAMESPACE:-"tfs-dev"} +export TFS_K8S_NAMESPACE=${TFS_K8S_NAMESPACE:-"tfs"} ######################################################################################################################## # Automated steps start here diff --git a/scripts/show_logs_service.sh b/scripts/show_logs_service.sh index 251add7e1..6089d0ac6 100755 --- a/scripts/show_logs_service.sh +++ b/scripts/show_logs_service.sh @@ -18,7 +18,7 @@ ######################################################################################################################## # If not already set, set the name of the Kubernetes namespace to deploy to. -export TFS_K8S_NAMESPACE=${TFS_K8S_NAMESPACE:-"tfs-dev"} +export TFS_K8S_NAMESPACE=${TFS_K8S_NAMESPACE:-"tfs"} ######################################################################################################################## # Automated steps start here diff --git a/scripts/show_logs_webui.sh b/scripts/show_logs_webui.sh index c73f5f51a..38cffd624 100755 --- a/scripts/show_logs_webui.sh +++ b/scripts/show_logs_webui.sh @@ -18,7 +18,7 @@ ######################################################################################################################## # If not already set, set the name of the Kubernetes namespace to deploy to. -export TFS_K8S_NAMESPACE=${TFS_K8S_NAMESPACE:-"tfs-dev"} +export TFS_K8S_NAMESPACE=${TFS_K8S_NAMESPACE:-"tfs"} ######################################################################################################################## # Automated steps start here diff --git a/show_deploy.sh b/show_deploy.sh index e894d44f3..68a5659aa 100755 --- a/show_deploy.sh +++ b/show_deploy.sh @@ -18,7 +18,7 @@ ######################################################################################################################## # If not already set, set the name of the Kubernetes namespace to deploy to. -export TFS_K8S_NAMESPACE=${TFS_K8S_NAMESPACE:-"tfs-dev"} +export TFS_K8S_NAMESPACE=${TFS_K8S_NAMESPACE:-"tfs"} ######################################################################################################################## # Automated steps start here diff --git a/tutorial/1-2-install-microk8s.md b/tutorial/1-2-install-microk8s.md index 09e0b41a3..327c6af9e 100644 --- a/tutorial/1-2-install-microk8s.md +++ b/tutorial/1-2-install-microk8s.md @@ -70,7 +70,16 @@ sudo ufw default allow routed ```bash sudo usermod -a -G docker $USER sudo usermod -a -G microk8s $USER -sudo chown -f -R $USER ~/.kube +sudo chown -f -R $USER $HOME/.kube +sudo reboot +``` + +In case that the .kube file is not automatically provisioned into your home folder, you may follow the steps below: + +```bash +mkdir -p $HOME/.kube +sudo chown -f -R $USER $HOME/.kube +microk8s config > $HOME/.kube/config sudo reboot ``` diff --git a/tutorial/2-1-python-environment.md b/tutorial/2-1-python-environment.md index 4a818e9e7..e03e3daff 100644 --- a/tutorial/2-1-python-environment.md +++ b/tutorial/2-1-python-environment.md @@ -32,6 +32,13 @@ eval "$(pyenv init -)" eval "$(pyenv virtualenv-init -)" ``` +In case .bashrc is not linked properly to your profile, you may need to append the following line into your local .profile file: + +```bash +# Open ~/.profile and append this line: ++source "$HOME"/.bashrc +``` + ## 2.1.4. Restart the VM Restart the VM for all the changes to take effect. @@ -58,6 +65,13 @@ pyenv virtualenv 3.9.13 tfs pyenv local 3.9.13/envs/tfs ``` +In case that the correct pyenv does not get automatically activated when you change to the tfs-ctrl/ folder, then execute the following command: + +```bash +cd ~/tfs-ctrl +pyenv activate 3.9.13/envs/tfs +``` + After completing these commands, you should see in your prompt that now you're within the virtual environment `3.9.13/envs/tfs` on folder `~/tfs-ctrl`: ``` -- GitLab