diff --git a/common/common_helper.sh b/common/common_helper.sh index 155fe54..2a15d04 100755 --- a/common/common_helper.sh +++ b/common/common_helper.sh @@ -766,11 +766,15 @@ function kruize_local_demo_setup() { benchmarks_install ${APP_NAMESPACE} ${bench} fi echo "" - elif [ ${demo} == "bulk" ]; then - setup_workload fi fi - kruize_local_patch + if [ ${THANOS} == 0 ]; then + kruize_local_patch + else + echo "Invoking thanos patch..." + kruize_local_thanos_patch + fi + kruize_install echo # port forward the urls in case of kind @@ -875,3 +879,31 @@ function kruize_local_disable() { fi } +# +# Update thanos datasource details in the manifest +# +function kruize_local_thanos_patch() { + CRC_DIR="./manifests/crc/default-db-included-installation" + KRUIZE_CRC_DEPLOY_MANIFEST_OPENSHIFT="${CRC_DIR}/openshift/kruize-crc-openshift.yaml" + KRUIZE_CRC_DEPLOY_MANIFEST_MINIKUBE="${CRC_DIR}/minikube/kruize-crc-minikube.yaml" + + pushd autotune >/dev/null + # Checkout mvp_demo to get the latest mvp_demo release version + git checkout mvp_demo >/dev/null 2>/dev/null + + if [ ${CLUSTER_TYPE} == "kind" ]; then + sed -i 's/"local": "false"/"local": "true"/' ${KRUIZE_CRC_DEPLOY_MANIFEST_MINIKUBE} + elif [ ${CLUSTER_TYPE} == "minikube" ]; then + sed -i 's/"local": "false"/"local": "true"/' ${KRUIZE_CRC_DEPLOY_MANIFEST_MINIKUBE} + elif [ ${CLUSTER_TYPE} == "openshift" ]; then + sed -i 's/"name": "prometheus-1"/"name": "thanos"/' ${KRUIZE_CRC_DEPLOY_MANIFEST_OPENSHIFT} + #sed -i 's/"serviceName": "prometheus-k8s"/"serviceName": "thanos-query-frontend"/' ${KRUIZE_CRC_DEPLOY_MANIFEST_OPENSHIFT} + #sed -i 's/"namespace": "openshift-monitoring"/"namespace": "thanos-bench"/' ${KRUIZE_CRC_DEPLOY_MANIFEST_OPENSHIFT} + #sed -i 's/"url": "https:\/\/prometheus-k8s.openshift-monitoring.svc.cluster.local:9091"/"url": "https:\/\/thanos-query-frontend-thanos-bench.apps.kruize-scalelab.h0b5.p1.openshiftapps.com"/' ${KRUIZE_CRC_DEPLOY_MANIFEST_OPENSHIFT} + sed -i 's/"serviceName": "prometheus-k8s"/"serviceName": ""/' ${KRUIZE_CRC_DEPLOY_MANIFEST_OPENSHIFT} + sed -i 's/"namespace": "openshift-monitoring"/"namespace": ""/' ${KRUIZE_CRC_DEPLOY_MANIFEST_OPENSHIFT} + sed -i 's#"url": ""#"url": "http://thanos-query-frontend.thanos-bench.svc.cluster.local:9090/"#' ${KRUIZE_CRC_DEPLOY_MANIFEST_OPENSHIFT} + fi + popd >/dev/null +} + diff --git a/monitoring/local_monitoring/bulk_demo/bulk_service_demo.sh b/monitoring/local_monitoring/bulk_demo/bulk_service_demo.sh index 7979eaf..51cbe2b 100755 --- a/monitoring/local_monitoring/bulk_demo/bulk_service_demo.sh +++ b/monitoring/local_monitoring/bulk_demo/bulk_service_demo.sh @@ -35,6 +35,7 @@ KRUIZE_UI_PORT=8081 TECHEMPOWER_PORT=8082 PYTHON_CMD=python3 +export LOG_FILE="${current_dir}/kruize-bulk-demo.log" function usage() { echo "Usage: $0 [-s|-t] [-c cluster-type] [-l] [-p] [-r] [-i kruize-image] [-u kruize-ui-image]" @@ -69,11 +70,12 @@ export KRUIZE_DOCKER_IMAGE="" export prometheus=0 export kruize_restart=0 export start_demo=1 +export THANOS=0 export APP_NAMESPACE="default" export LOAD_DURATION="1200" # Iterate through the commandline options -while getopts c:i:n:d:lprstu: gopts +while getopts c:i:n:d:lprstzu: gopts do case "${gopts}" in c) @@ -97,6 +99,9 @@ do t) start_demo=0 ;; + z) + THANOS=1 + ;; u) KRUIZE_UI_DOCKER_IMAGE="${OPTARG}" ;; @@ -112,6 +117,7 @@ do done export demo="bulk" +echo | tee "${LOG_FILE}" if [ ${start_demo} -eq 1 ]; then kruize_local_demo_setup elif [ ${start_demo} -eq 2 ]; then diff --git a/monitoring/local_monitoring/common.sh b/monitoring/local_monitoring/common.sh index 23d1416..1ed9617 100755 --- a/monitoring/local_monitoring/common.sh +++ b/monitoring/local_monitoring/common.sh @@ -22,6 +22,11 @@ function kruize_local() { export DATASOURCE="prometheus-1" export CLUSTER_NAME="default" + if [ ${THANOS} == 1 ]; then + export DATASOURCE="thanos" + export CLUSTER_NAME="eu-1" + fi + # Metric Profile JSON if [ ${CLUSTER_TYPE} == "minikube" ]; then resource_optimization_local_monitoring="${current_dir}/autotune/manifests/autotune/performance-profiles/resource_optimization_local_monitoring_norecordingrules.json" @@ -39,19 +44,28 @@ function kruize_local() { echo echo "######################################################" - echo "# Import metadata from prometheus-1 datasource" + echo "# Import metadata from $DATASOURCE datasource" echo "######################################################" echo - curl --location http://"${KRUIZE_URL}"/dsmetadata \ - --header 'Content-Type: application/json' \ - --data '{ - "version": "v1.0", - "datasource_name": "prometheus-1" - }' + if [ ${THANOS} == 0 ]; then + curl --location http://"${KRUIZE_URL}"/dsmetadata \ + --header 'Content-Type: application/json' \ + --data '{ + "version": "v1.0", + "datasource_name": "prometheus-1" + }' + else + curl --location http://"${KRUIZE_URL}"/dsmetadata \ + --header 'Content-Type: application/json' \ + --data '{ + "version": "v1.0", + "datasource_name": "thanos" + }' + fi echo echo "######################################################" - echo "# Display metadata from prometheus-1 datasource" + echo "# Display metadata from ${DATASOURCE} datasource" echo "######################################################" echo curl "http://${KRUIZE_URL}/dsmetadata?datasource=${DATASOURCE}&verbose=true" @@ -72,6 +86,42 @@ function kruize_local() { echo curl -X POST http://${KRUIZE_URL}/createMetricProfile -d @$resource_optimization_local_monitoring echo + + if [ ${THANOS} == 1 ]; then + echo + echo "######################################################" + echo "# Create kruize experiment" + echo "######################################################" + echo + echo "curl -X POST http://${KRUIZE_URL}/createExperiment -d @./experiments/create_thanos_exp.json" + curl -X POST http://${KRUIZE_URL}/createExperiment -d @./experiments/create_thanos_exp.json + echo + + echo "Sleeping for 30s before generating the recommendations!" + sleep 30s + + echo + echo "######################################################" + echo "# Generate recommendations for every experiment" + echo "######################################################" + echo + curl -X POST "http://${KRUIZE_URL}/generateRecommendations?experiment_name=monitor_tfb_benchmark" + echo "" + + echo + echo "######################################################" + echo + echo "Generate fresh recommendations using" + echo "curl -X POST http://${KRUIZE_URL}/generateRecommendations?experiment_name=monitor_tfb_benchmark" + echo + echo "List Recommendations using " + echo "curl http://${KRUIZE_URL}/listRecommendations?experiment_name=monitor_tfb_benchmark" + echo + echo "######################################################" + echo + fi + + } >> "${LOG_FILE}" 2>&1 } diff --git a/monitoring/local_monitoring/local_monitoring_demo.sh b/monitoring/local_monitoring/local_monitoring_demo.sh index 96fc480..5fa106a 100755 --- a/monitoring/local_monitoring/local_monitoring_demo.sh +++ b/monitoring/local_monitoring/local_monitoring_demo.sh @@ -69,8 +69,10 @@ export APP_NAMESPACE="default" export LOAD_DURATION="1200" export BENCHMARK_MANIFESTS="resource_provisioning_manifests" export EXPERIMENT_TYPE="" +export THANOS=0 + # Iterate through the commandline options -while getopts c:i:e:n:d:m:g:lbprstu: gopts +while getopts c:i:e:n:d:m:g:lbprstzu: gopts do case "${gopts}" in c) @@ -96,6 +98,9 @@ do r) kruize_restart=1 ;; + z) + THANOS=1 + ;; s) start_demo=1 ;;