Skip to content

Add Support for Simulating Error Conditions and Handling by VPA & Kruize #132

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

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
31 changes: 31 additions & 0 deletions monitoring/local_monitoring/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,22 @@ function update_vpa_roles() {
fi
}

function apply_limitrange_and_namespace_quotas() {
echo "🔄 Applying LimitRange and Namespace Quotas..."

kubectl apply -f "${current_dir}/manifests/minimal_limit_range.yaml" -n demo-limitrange-violation
if [ $? -ne 0 ]; then
echo "❌ Error applying LimitRange manifest."
fi

kubectl apply -f "${current_dir}/manifests/minimal_ns_quota.yaml" -n demo-quota-violation
if [ $? -ne 0 ]; then
echo "❌ Error applying Namespace Quota manifest."
fi

echo "✅ LimitRange and Namespace Quotas applied!"
}

function kruize_local_demo_setup() {
bench=$1
# Start all the installs
Expand Down Expand Up @@ -409,6 +425,17 @@ function kruize_local_demo_setup() {
benchmarks_install ${APP_NAMESPACE} ${bench} >> "${LOG_FILE}" 2>&1
apply_benchmark_load ${APP_NAMESPACE} ${bench} >> "${LOG_FILE}" 2>&1
echo "✅ Completed!"

if [[ -n "${vpa_install_required}" && "${vpa_install_required}" -eq 1 && -n "${CREATE_ALL_EXPERIMENTS}" && "${CREATE_ALL_EXPERIMENTS}" -eq 1 ]]; then
echo -n "🔄 Creating additional namespaces and installing benchmarks..."
create_namespace "demo-quota-violation" >> "${LOG_FILE}" 2>&1
create_namespace "demo-limitrange-violation" >> "${LOG_FILE}" 2>&1
benchmarks_install "demo-quota-violation" ${bench} >> "${LOG_FILE}" 2>&1
apply_benchmark_load "demo-quota-violation" ${bench} >> "${LOG_FILE}" 2>&1
benchmarks_install "demo-limitrange-violation" ${bench} >> "${LOG_FILE}" 2>&1
apply_benchmark_load "demo-limitrange-violation" ${bench} >> "${LOG_FILE}" 2>&1
echo "✅ Completed!"
fi
fi
echo "" >> "${LOG_FILE}" 2>&1
fi
Expand Down Expand Up @@ -461,6 +488,10 @@ function kruize_local_demo_setup() {
echo -n "🔄 Updating cluser-roles for VPA..."
update_vpa_roles >> "${LOG_FILE}" 2>&1
echo "✅ Done!"

if [ "${CREATE_ALL_EXPERIMENTS:-}" == "1" ]; then
apply_limitrange_and_namespace_quotas
fi
}
fi

Expand Down
3 changes: 2 additions & 1 deletion monitoring/local_monitoring/vpa_demo/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ cd kruize-demos/monitoring/local_monitoring/vpa_demo
```

```
Usage: ./bulk_service_demo.sh [-s|-t] [-c cluster-type] [-l] [-p] [-r] [-i kruize-image] [-u kruize-ui-image]
Usage: ./bulk_service_demo.sh [-s|-t] [-c cluster-type] [-l] [-p] [-r] [-i kruize-image] [-u kruize-ui-image] [-a create-all-experiments]
a = create all experiments simulating error conditions demo
c = supports minikube, kind and openshift cluster-type
i = kruize image.
p = expose prometheus port
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
[{
"version": "v2.0",
"experiment_name": "vpa-limit-violation",
"cluster_name": "default",
"performance_profile": "resource-optimization-local-monitoring",
"metadata_profile": "cluster-metadata-local-monitoring",
"mode": "recreate",
"target_cluster": "local",
"datasource": "prometheus-1",
"kubernetes_objects": [
{
"type": "deployment",
"name": "sysbench",
"namespace": "demo-limitrange-violation",
"containers": [
{
"container_image_name": "quay.io/kruizehub/sysbench",
"container_name": "sysbench"
}
]
}
],
"trial_settings": {
"measurement_duration": "2min"
},
"recommendation_settings": {
"threshold": "0.1"
}
}]

Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
[{
"version": "v2.0",
"experiment_name": "vpa-quota-violation",
"cluster_name": "default",
"performance_profile": "resource-optimization-local-monitoring",
"metadata_profile": "cluster-metadata-local-monitoring",
"mode": "recreate",
"target_cluster": "local",
"datasource": "prometheus-1",
"kubernetes_objects": [
{
"type": "deployment",
"name": "sysbench",
"namespace": "demo-quota-violation",
"containers": [
{
"container_image_name": "quay.io/kruizehub/sysbench",
"container_name": "sysbench"
}
]
}
],
"trial_settings": {
"measurement_duration": "2min"
},
"recommendation_settings": {
"threshold": "0.1"
}
}]

Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
apiVersion: v1
kind: LimitRange
metadata:
name: minimum-limit-range
namespace: demo-limitrange-violation
spec:
limits:
- type: Container
min:
cpu: "500m"
memory: "24Mi"
max:
cpu: "1"
memory: "32Gi"
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
apiVersion: v1
kind: ResourceQuota
metadata:
name: minimal-quota
namespace: "demo-quota-violation"
spec:
hard:
pods: "20"
requests.cpu: "10m"
requests.memory: "0.2Mi"
limits.cpu: "10m"
limits.memory: "0.2Mi"
18 changes: 14 additions & 4 deletions monitoring/local_monitoring/vpa_demo/vpa_demo.sh
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ KRUIZE_UI_PORT=8081
TECHEMPOWER_PORT=8082

function usage() {
echo "Usage: $0 [-s|-t] [-c cluster-type] [-f] [-i kruize-image] [-u kruize-ui-image] [-e experiment_type] [ [-b] [-m benchmark-manifests] [-n namespace] [-l] [-d load-duration] ] [-p]"
echo "Usage: $0 [-s|-t] [-c cluster-type] [-f] [-i kruize-image] [-u kruize-ui-image] [-e experiment_type] [ [-b] [-m benchmark-manifests] [-n namespace] [-l] [-d load-duration] ] [-p] [-a]"
echo "s = start (default), t = terminate"
echo "c = supports minikube, kind, aks and openshift cluster-type"
echo "f = create environment setup if cluster-type is minikube, kind"
Expand All @@ -48,7 +48,7 @@ function usage() {
echo "l = Run a load against the benchmark"
echo "d = duration to run the benchmark load"
echo "p = expose prometheus port"

echo "a = creates all experiments including error scenarios"
exit 1
}

Expand All @@ -67,10 +67,15 @@ export APP_NAMESPACE="default"
export LOAD_DURATION="1200"
export BENCHMARK_MANIFESTS="resource_provisioning_manifests"
export EXPERIMENT_TYPE=""
export CREATE_ALL_EXPERIMENTS=0

# Iterate through the commandline options
while getopts bc:d:e:fi:lm:n:pstu: gopts
while getopts abc:d:e:fi:lm:n:pstu: gopts
do
case "${gopts}" in
a)
export CREATE_ALL_EXPERIMENTS=1
;;
b)
start_demo=2
benchmark=1
Expand Down Expand Up @@ -118,9 +123,14 @@ export demo="local"
export vpa_install_required="1"

EXPERIMENT_TYPE="container"
export EXPERIMENTS=("container_vpa_experiment_sysbench")
BENCHMARK="sysbench"

if [ ${CREATE_ALL_EXPERIMENTS} -eq 1 ]; then
export EXPERIMENTS=("container_vpa_experiment_sysbench" "container_vpa_experiment_quota_violation" "container_vpa_experiment_limitrange_violation")
else
export EXPERIMENTS=("container_vpa_experiment_sysbench")
fi


if [ ${start_demo} -eq 1 ]; then
echo > "${LOG_FILE}"
Expand Down