Skip to content

Commit

Permalink
Updated the demos to run with thanos datasource
Browse files Browse the repository at this point in the history
Signed-off-by: Chandrakala Subramanyam <csubrama@redhat.com>
  • Loading branch information
chandrams committed Oct 28, 2024
1 parent f0b089e commit 86c1298
Show file tree
Hide file tree
Showing 4 changed files with 106 additions and 13 deletions.
38 changes: 35 additions & 3 deletions common/common_helper.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
}

8 changes: 7 additions & 1 deletion monitoring/local_monitoring/bulk_demo/bulk_service_demo.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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]"
Expand Down Expand Up @@ -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)
Expand All @@ -97,6 +99,9 @@ do
t)
start_demo=0
;;
z)
THANOS=1
;;
u)
KRUIZE_UI_DOCKER_IMAGE="${OPTARG}"
;;
Expand All @@ -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
Expand Down
66 changes: 58 additions & 8 deletions monitoring/local_monitoring/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"
Expand All @@ -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
}

Expand Down
7 changes: 6 additions & 1 deletion monitoring/local_monitoring/local_monitoring_demo.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -96,6 +98,9 @@ do
r)
kruize_restart=1
;;
z)
THANOS=1
;;
s)
start_demo=1
;;
Expand Down

0 comments on commit 86c1298

Please # to comment.