diff --git a/common/common_helper.sh b/common/common_helper.sh index af1bf087..e77cc947 100755 --- a/common/common_helper.sh +++ b/common/common_helper.sh @@ -769,7 +769,13 @@ function kruize_local_demo_setup() { echo "" 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 @@ -874,3 +880,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 + # Specifying serviceName & namespace resolves the url to https and this doesn't seem to be working + #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/"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 b104b632..51cbe2bc 100755 --- a/monitoring/local_monitoring/bulk_demo/bulk_service_demo.sh +++ b/monitoring/local_monitoring/bulk_demo/bulk_service_demo.sh @@ -70,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) @@ -98,6 +99,9 @@ do t) start_demo=0 ;; + z) + THANOS=1 + ;; u) KRUIZE_UI_DOCKER_IMAGE="${OPTARG}" ;; diff --git a/monitoring/local_monitoring/common.sh b/monitoring/local_monitoring/common.sh index 23d14164..ab5d76a7 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 96fc480d..5fa106a2 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 ;;