Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated the demos to run with thanos datasource #99

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 35 additions & 1 deletion common/common_helper.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
}

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