### Start Minikube with Resources - Shell Source: https://github.com/kruize/autotune/blob/master/docs/autotune_install.md Starts the Minikube local Kubernetes cluster with recommended resource allocations (8 CPUs and 16GB memory) for Autotune deployment. ```Shell $ minikube start --cpus=8 --memory=16384M ``` -------------------------------- ### Clone Kruize Benchmarks Repository - Shell Source: https://github.com/kruize/autotune/blob/master/docs/autotune_install.md Clones the Kruize Benchmarks repository from GitHub, which may be required for running tests or examples with Autotune. ```Shell $ git clone git@github.com:kruize/benchmarks.git ``` -------------------------------- ### Install Minikube Binary - Shell Source: https://github.com/kruize/autotune/blob/master/docs/autotune_install.md Installs the downloaded Minikube binary to a standard system path (/usr/local/bin), requiring superuser privileges. ```Shell $ sudo install minikube-linux-amd64 /usr/local/bin/minikube ``` -------------------------------- ### Install Prometheus on Minikube - Shell Source: https://github.com/kruize/autotune/blob/master/docs/autotune_install.md Executes a script from the autotune repository to install Prometheus and its dependencies (like cadvisor) onto the running Minikube cluster. The output shows the installation progress and status. ```Shell ./scripts/prometheus_on_minikube.sh -as Info: installing prometheus... Info: Checking pre requisites for prometheus... No resources found in monitoring namespace. Info: Downloading cadvisor git Info: Installing cadvisor namespace/cadvisor created serviceaccount/cadvisor created daemonset.apps/cadvisor created Info: Downloading prometheus git release - v0.8.0 Info: Installing prometheus namespace/monitoring created customresourcedefinition.apiextensions.k8s.io/alertmanagerconfigs.monitoring.coreos.com created customresourcedefinition.apiextensions.k8s.io/alertmanagers.monitoring.coreos.com created Info: Waiting for all Prometheus Pods to get spawned....done Info: Waiting for prometheus-k8s-1 to come up..... prometheus-k8s-1 0/2 ContainerCreating 0 70s prometheus-k8s-1 0/2 Pending 0 74s prometheus-k8s-1 2/2 Running 1 85s Info: prometheus-k8s-1 deploy succeeded: Running prometheus-k8s-1 2/2 Running 1 85s ``` -------------------------------- ### Verify kubectl Client Version - Shell Source: https://github.com/kruize/autotune/blob/master/docs/autotune_install.md Checks and displays the client version of the installed kubectl command-line tool to confirm successful installation. ```Shell $ kubectl version --client ``` -------------------------------- ### Clone Kruize Autotune Repository - Shell Source: https://github.com/kruize/autotune/blob/master/docs/autotune_install.md Clones the main Kruize Autotune source code repository from GitHub to your local workstation. ```Shell $ git clone git@github.com:kruize/autotune.git ``` -------------------------------- ### Download kubectl Binary - Shell Source: https://github.com/kruize/autotune/blob/master/docs/autotune_install.md Downloads the kubectl command-line tool binary for Linux AMD64 from the official Kubernetes release storage. ```Shell $ curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl ``` -------------------------------- ### Install kubectl to Path - Shell Source: https://github.com/kruize/autotune/blob/master/docs/autotune_install.md Moves the executable kubectl binary to a standard system directory (/usr/local/bin) that is typically included in the system's PATH, requiring superuser privileges. ```Shell $ sudo mv ./kubectl /usr/local/bin/kubectl ``` -------------------------------- ### Make kubectl Executable - Shell Source: https://github.com/kruize/autotune/blob/master/docs/autotune_install.md Grants execute permissions to the downloaded kubectl binary file, making it runnable. ```Shell $ chmod +x ./kubectl ``` -------------------------------- ### Example Command to Run Scale Test Source: https://github.com/kruize/autotune/blob/master/tests/scripts/remote_monitoring_tests/scalability_test.md Provides a concrete example of how to run the `remote_monitoring_scale_test_bulk.sh` script with specific parameters for image, number of experiments, days, clients, intervals, start date, and results directory. ```Shell cd /tests/scripts/remote_monitoring_tests/scale_test ./remote_monitoring_tests/scale_test/remote_monitoring_scale_test_bulk.sh -i quay.io/kruize/autotune_operator:0.0.20_mvp -u 250 -d 15 -n 20 -t 6 -q 10 -s 2023-01-10T00:00:00.000Z -r /tmp/scale_test_results ``` -------------------------------- ### Build Autotune Docker Image - Shell Source: https://github.com/kruize/autotune/blob/master/docs/autotune_install.md Runs the build script to create the autotune Docker image, tagging it as 'autotune:test'. The snippet also includes the usage options for the build script. ```Shell ./build.sh -i autotune:test Usage: ./build.sh [-d] [-v version_string] [-i autotune_docker_image] -d: build in dev friendly mode -i: build with specific autotune operator docker image name [Default - kruize/autotune_operator:] -v: build as specific autotune version ``` -------------------------------- ### Bulk API URL Configuration Examples (Shell) Source: https://github.com/kruize/autotune/blob/master/design/BulkAPI.md Examples showing the format for configuring the `recommendationsURL` and `experimentsURL` environment variables, specifying the service name, namespace, port, and path for Kruize's internal Bulk APIs. ```shell "recommendationsURL" : "http://kruize.openshift-tuning.svc.cluster.local:8080/generateRecommendations?experiment_name=%s" "experimentsURL" : "http://kruize.openshift-tuning.svc.cluster.local:8080/createExperiment" ``` -------------------------------- ### Push Autotune Docker Image - Shell Source: https://github.com/kruize/autotune/blob/master/docs/autotune_install.md Pushes the tagged autotune Docker image to the specified Docker registry under the user's namespace. ```Shell $ docker push username/autotune:test ``` -------------------------------- ### Tag Autotune Docker Image - Shell Source: https://github.com/kruize/autotune/blob/master/docs/autotune_install.md Retags the locally built 'autotune:test' image with a username and registry path, preparing it to be pushed to a specific Docker repository. ```Shell $ docker tag autotune:test docker.io/username/autotune:test ``` -------------------------------- ### Download Specific Minikube Version - Shell Source: https://github.com/kruize/autotune/blob/master/docs/autotune_install.md Downloads a specific version (v1.26.1) of the Minikube binary for Linux AMD64, which is recommended for compatibility with the specified Prometheus version. ```Shell $ curl -LO https://github.com/kubernetes/minikube/releases/download/v1.26.1/minikube-linux-amd64 ``` -------------------------------- ### Login to Docker Registry - Shell Source: https://github.com/kruize/autotune/blob/master/docs/autotune_install.md Initiates the process to log in to a Docker registry (like Docker Hub), which is required before pushing Docker images. ```Shell $ docker login ``` -------------------------------- ### Example Search Space Response Source: https://github.com/kruize/autotune/blob/master/design/ExperimentModeAPI.md This JSON object shows an example response from the `/searchSpace` endpoint, detailing the configuration for a specific experiment including objective function, HPO algorithm, tunables with their bounds and types, and optimization direction. ```json [ { "experiment_name": "galaxies-autotune-min-http-response-time", "experiment_id": "7c07cf4db16adcf76bad79394c9e7df2f3b8d8e6942cfa3f7b254b5aec1299b0", "objective_function": { "type": "expression", "expression": "request_sum/request_count" }, "hpo_algo_impl": "optuna_tpe", "tunables": [ { "value_type": "double", "lower_bound": "150.0Mi", "name": "memoryRequest", "step": 1, "upper_bound": "300.0Mi" }, { "value_type": "double", "lower_bound": "1.0", "name": "cpuRequest", "step": 0.01, "upper_bound": "3.0" }, { "value_type": "integer", "lower_bound": "9", "name": "MaxInlineLevel", "step": 1, "upper_bound": "50" }, { "value_type": "integer", "lower_bound": "1", "name": "quarkus.thread-pool.core-threads", "step": 1, "upper_bound": "10" }, { "value_type": "integer", "lower_bound": "1", "name": "quarkus.thread-pool.queue-size", "step": 1, "upper_bound": "100" }, { "value_type": "integer", "lower_bound": "1", "name": "quarkus.hibernate-orm.jdbc.statement-fetch-size", "step": 1, "upper_bound": "50" } ], "direction": "minimize" } ] ``` -------------------------------- ### Example Curl Request to List Metadata Profiles (Shell) Source: https://github.com/kruize/autotune/blob/master/design/MetadataProfileAPI.md An example `curl` command to retrieve the list of metadata profiles from the Kruize API. It uses the `GET` method on the `/listMetadataProfiles` endpoint and includes the `verbose=true` query parameter to get detailed information. The `Accept: application/json` header is set. ```shell curl -H 'Accept: application/json' http://:/listMetadataProfiles?verbose=true ``` -------------------------------- ### Run Local Monitoring Fault Tolerance Test (Example) Source: https://github.com/kruize/autotune/blob/master/tests/scripts/local_monitoring_tests/fault_tolerant_tests.md An example command demonstrating how to run the local monitoring fault tolerance test script. This specific example sets the results directory to '/tmp/fault-tolerant-test-results' and specifies a particular version of the 'kruize/autotune_operator' image for testing. ```bash /tests/scripts/local_monitoring_tests/fault_tolerant_tests/local_monitoring_fault_tolerant_tests.sh -r /tmp/fault-tolerant-test-results -i kruize/autotune_operator:0.0.23_mvp ``` -------------------------------- ### Deploying Autotune to Minikube using deploy.sh Source: https://github.com/kruize/autotune/blob/master/docs/autotune_install.md This snippet shows the command to execute the deploy.sh script to deploy Autotune. It specifies 'minikube' as the target cluster type and provides a custom docker image name 'autotune:test' for the Autotune operator. ```bash ./deploy.sh -c minikube -i autotune:test ``` -------------------------------- ### Example Response for List Kruize Tunables (JSON) Source: https://github.com/kruize/autotune/blob/master/design/ExperimentModeAPI.md An example of the JSON response returned by the /listKruizeTunables endpoint, showing the structure including layer details and associated tunables with their properties. ```JSON [ { "layer_id": "af07fd998199bf2d57f95dc18f2cc2311b72f6de11e7e949b566fcdc5ecb443b", "layer_level": 0, "tunables": [ { "value_type": "double", "lower_bound": "150.0Mi", "name": "memoryRequest", "step": 1, "query_url": "http://10.111.106.208:9090/api/v1/query?query=container_memory_working_set_bytes{container=\"\", pod=\"$POD$\"}", "upper_bound": "300.0Mi" }, { "value_type": "double", "lower_bound": "1.0", "name": "cpuRequest", "step": 0.01, "query_url": "http://10.111.106.208:9090/api/v1/query?query=(container_cpu_usage_seconds_total{container!=\"POD\", pod=\"$POD$\"}[1m])", "upper_bound": "3.0" } ], "layer_name": "container", "layer_details": "generic container tunables" }, { "layer_id": "63f4bd430913abffaa6c41a5e05015d5fea23134c99826470c904a7cfe56b40c", "layer_level": 1, "tunables": [{ "value_type": "integer", "lower_bound": "9", "name": "MaxInlineLevel", "step": 1, "query_url": "http://10.111.106.208:9090/api/v1/query?query=jvm_memory_used_bytes{area=\"heap\", container=\"\", pod=\"$POD$\"}", "upper_bound": "50" }], "layer_name": "hotspot", "layer_details": "hotspot tunables" }, { "layer_id": "3ec648860dd10049b2488f19ca6d80fc5b50acccdf4aafaedc2316c6eea66741", "layer_level": 2, "tunables": [ { "value_type": "integer", "lower_bound": "1", "name": "quarkus.thread-pool.core-threads", "step": 1, "query_url": "none", "upper_bound": "10" }, { "value_type": "integer", "lower_bound": "1", "name": "quarkus.thread-pool.queue-size", "step": 1, "query_url": "none", "upper_bound": "100" }, { "value_type": "integer", "lower_bound": "1", "name": "quarkus.hibernate-orm.jdbc.statement-fetch-size", "step": 1, "query_url": "none", "upper_bound": "50" } ], "layer_name": "quarkus", "layer_details": "quarkus tunables" } ] ``` -------------------------------- ### Example Bulk Recommendations API Response (JSON) Source: https://github.com/kruize/autotune/blob/master/design/BulkAPI.md This JSON snippet provides an example of the response received from the `/bulk` API call. It details recommendations for a specific container within an experiment, including version information, notifications (info, error, warning, critical), and a data section for recommendations. ```json { "experiments": { "prometheus-1|default|cadvisor|cadvisor(daemonset)|cadvisor": { "apis": { "recommendations": { "response": [ { "cluster_name": "default", "experiment_type": "container", "kubernetes_objects": [ { "type": "daemonset", "name": "cadvisor", "namespace": "cadvisor", "containers": [ { "container_image_name": "gcr.io/cadvisor/cadvisor:v0.45.0", "container_name": "cadvisor", "recommendations": { "version": "1.0", "notifications": { "111000": { "type": "info", "message": "Recommendations Are Available", "code": 111000 } }, "data": { "2025-02-04T06:49:47.000Z": { "notifications": { "111101": { "type": "info", "message": "Short Term Recommendations Available", "code": 111101 }, "223001": { "type": "error", "message": "Amount field is missing in the CPU Section", "code": 223001 }, "224001": { "type": "error", "message": "Amount field is missing in the Memory Section", "code": 224001 }, "423001": { "type": "warning", "message": "CPU Limit Not Set", "code": 423001 }, "523001": { "type": "critical", "message": "" } } } } } } ] } ] } ] } } } } } ``` -------------------------------- ### Resource Recommendations JSON Example Source: https://github.com/kruize/autotune/blob/master/design/APISamples.md Example JSON structure representing resource recommendations provided by Kruize Autotune for a Kubernetes object and its containers. Includes short-term and long-term recommendations for CPU and memory resources, along with associated notifications. ```json { "kubernetes_objects": [ { "type": "deployment", "name": "petclinic-deployment", "namespace": "petclinic", "containers": [ { "container_image_name": "spring-petclinic", "container_name": "spring-petclinic", "recommendations": { "resource": { "short_term": { "monitoring_start_time": "2023-06-14T00:57:51.561Z", "monitoring_end_time": "2023-06-15T00:57:51.561Z", "duration_in_hours": 24.0, "pods_count": 1, "confidence_level": 0.0, "requests": { "cpu": { "amount": 7.72, "format": "cores" }, "memory": { "amount": 1197.708, "format": "MiB" } }, "limits": { "cpu": { "amount": 7.72, "format": "cores" }, "memory": { "amount": 1197.708, "format": "MiB" } }, "notifications": { "120001": { "type": "info", "message": "There is not enough data available to generate a recommendation.", "code": 120001 } } }, "long_term": { "pods_count": 0, "confidence_level": 0.0, "notifications": { "120001": { "type": "info", "message": "There is not enough data available to generate a recommendation.", "code": 120001 } } } } } } ] } ], "version": "1.0", "experiment_name": "hilarious-shreya" } ``` -------------------------------- ### Experiment Name Format Example with Fewer Labels Source: https://github.com/kruize/autotune/blob/master/design/BulkAPI.md This snippet provides another example format string for `experimentNameFormat`, demonstrating how to include a subset of labels and other placeholders like `%label:org_id%`, `%namespace%`, etc., to customize the experiment name structure. ```Configuration "%label:org_id%|%namespace%|%workloadtype%|%workloadname%|%containername%" ``` -------------------------------- ### Example Bulk Endpoint Response (Summary) - JSON Source: https://github.com/kruize/autotune/blob/master/design/BulkAPI.md Provides an example JSON response structure when querying the /bulk endpoint with the default 'include=summary' parameter, showing job status, experiment counts, notifications, input details, and timestamps. ```json { "summary": { "status": "COMPLETED", "total_experiments": 23, "processed_experiments": 23, "notifications": null, "input": { "filter": null, "time_range": null, "datasource": "prometheus-1", "webhook": null }, "job_id": "ab803e6a-cb06-436a-9721-45a807a15f13", "job_start_time": "2025-02-04T06:39:45.165Z", "job_end_time": "2025-02-04T06:40:15.530Z" } } ``` -------------------------------- ### Example Command for Running Fault Tolerant Test - Shell Source: https://github.com/kruize/autotune/blob/master/tests/scripts/remote_monitoring_tests/fault_tolerant_tests.md This is a concrete example demonstrating how to run the remote monitoring fault tolerant test script with specific parameters. It sets the results directory, specifies a particular Kruize image version, and defines the number of experiments and restart iterations. ```shell /tests/scripts/remote_monitoring_tests/fault_tolerant_tests/remote_monitoring_fault_tolerant_tests.sh -r /tmp/fault-tolerant-test-results -i kruize/autotune_operator:0.0.12_mvp -u 3 -d 2 ``` -------------------------------- ### Cost Recommendations JSON Example Source: https://github.com/kruize/autotune/blob/master/design/APISamples.md Example JSON structure representing cost recommendations provided by Kruize Autotune for a Kubernetes object and its containers. Includes short-term cost recommendations based on current and recommended resource configurations. ```json { "cluster_name": "cluster-one-division-bell", "kubernetes_objects": [ { "type": "deployment", "name": "my-sample-deployment", "namespace": "default", "containers": [ { "container_image_name": "my-sample-image", "container_name": "my-sample-container", "recommendations": { "notifications": { "112101": { "type": "info", "message": "Cost Recommendations Available", "code": 112101 } }, "data": { "2023-06-15T00:57:51.561Z": { "cost": { "short_term": { "monitoring_start_time": "2023-06-14T00:57:51.561Z", "monitoring_end_time": "2023-06-15T00:57:51.561Z", "duration_in_hours": 24.0, "pods_count": 1, "confidence_level": 0.0, "current": { "requests": { "cpu": { "amount": 0.61, "format": "cores" } }, "limits": { "memory": { "amount": 615.15, "format": "MiB" }, "cpu": { "amount": 0.94, "format": "cores" } } }, "config": { "requests": { "memory": { "amount": 1197.708, "format": "MiB" }, "cpu": { "amount": 7.72, "format": "cores" } }, "limits": { "memory": { "amount": 1197.708, "format": "MiB" }, "cpu": { "amount": 7.72, "format": "cores" } } }, "variation": { "requests": { "memory": { } } } } } } } } } ] } ] } ``` -------------------------------- ### Example Command for Kruize Remote Monitoring Stress Test Source: https://github.com/kruize/autotune/blob/master/tests/scripts/remote_monitoring_tests/README.md An example demonstrating how to run the remote monitoring stress test script with specific values for the results directory, Kruize image, number of users, number of results to update, and timeout. ```bash /tests/scripts/remote_monitoring_tests/stress_test/remote_monitoring_stress_test.sh -r /tmp/stress-test-results -i kruize/autotune_operator:0.0.10_mvp -u 1000 -e 100 -t 900 ``` -------------------------------- ### Example Create Experiment Trial Request Body Source: https://github.com/kruize/autotune/blob/master/design/ExperimentModeAPI.md An example JSON payload structure used as the request body for the /createExperimentTrial API endpoint. It defines experiment settings, deployment details, and container configurations. ```json [ { "settings": { "trial_settings": { "measurement_cycles": "3", "warmup_duration": "1min", "warmup_cycles": "3", "measurement_duration": "1min", "iterations": "3" }, "deployment_settings": { "deployment_tracking": { "trackers": [ "training" ] }, "deployment_policy": { "type": "rollingUpdate" } } }, "experiment_name": "quarkus-resteasy-autotune-min-http-response-time-db", "deployments": { "training": { "pod_metrics": { "request_sum": { "datasource": "prometheus", "query": "rate(http_server_requests_seconds_sum{method=\"GET\",outcome=\"SUCCESS\",status=\"200\",uri=\"/db\",}[1m])", "name": "request_sum" }, "request_count": { "datasource": "prometheus", "query": "rate(http_server_requests_seconds_count{method=\"GET\",outcome=\"SUCCESS\",status=\"200\",uri=\"/db\",}[1m])", "name": "request_count" } }, "deployment_name": "tfb-qrh-sample", "namespace": "default", "containers": { "kruize/tfb-qrh:1.13.2.F_mm.v1": { "image_name": "kruize/tfb-qrh:1.13.2.F_mm.v1", "container_name": "tfb-server", "container_metrics": { "MaxInlineLevel": { "datasource": "prometheus", "query": "jvm_memory_used_bytes{area=\"heap\", $CONTAINER_LABEL$=\"\", $POD_LABEL$=\"$POD$\"}", "name": "MaxInlineLevel" }, "memoryRequest": { "datasource": "prometheus", "query": "container_memory_working_set_bytes{$CONTAINER_LABEL$=\"\", $POD_LABEL$=\"$POD$\"}", "name": "memoryRequest" }, "cpuRequest": { "datasource": "prometheus", "query": "(container_cpu_usage_seconds_total{$CONTAINER_LABEL$!=\"POD\", $POD_LABEL$=\"$POD$\"}[1m])", "name": "cpuRequest" } }, "config": { "0": { "requests": { "cpu": { "amount": "2.11", "format": "", "additionalProperties": {} }, "memory": { "amount": "160.0", "format": "", "additionalProperties": {} } }, "env": [ { "name": "JAVA_OPTIONS", "additionalProperties": {}, "value": " -server -XX:MaxRAMPercentage=70 -XX:+AllowParallelDefineClass -XX:MaxInlineLevel=21 -XX:+UseZGC -XX:+TieredCompilation -Dquarkus.thread-pool.queue-size=27 -Dquarkus.thread-pool.core-threads=9" }, { "name": "JDK_JAVA_OPTIONS", "additionalProperties": {}, "value": " -server -XX:MaxRAMPercentage=70 -XX:+AllowParallelDefineClass -XX:MaxInlineLevel=21 -XX:+UseZGC -XX:+TieredCompilation -Dquarkus.thread-pool.queue-size=27 -Dquarkus.thread-pool.core-threads=9" } ], "limits": { "cpu": { "amount": "2.11", "format": "", "additionalProperties": {} }, "memory": { "amount": "160.0", "format": "", "additionalProperties": {} } } } } } }, "type": "training" } } } ] ``` -------------------------------- ### Configuring Kafka Environment Variables Source: https://github.com/kruize/autotune/blob/master/design/KafkaDesign.md Examples of environment variables required to configure Kafka connectivity and topic names for the Kruize Kafka Producer. Includes settings for bootstrap servers, topics, and response filtering. ```Configuration - name: KAFKA_BOOTSTRAP_SERVERS value: "..svc.cluster.local:9092" - name: KAFKA_TOPICS value: "recommendations-topic,error-topic,summary-topic" - name: KAFKA_RESPONSE_FILTER_INCLUDE value: "summary" - name: KAFKA_RESPONSE_FILTER_EXCLUDE value: "experiment_name=abc" ``` -------------------------------- ### Example Kruize Metadata Profile Response (JSON) Source: https://github.com/kruize/autotune/blob/master/design/MetadataProfileAPI.md An example of the JSON response returned by the `/listMetadataProfiles` endpoint when the `verbose=true` parameter is used. It shows the structure of a metadata profile including API version, kind, metadata, profile version, Kubernetes type, datasource, and query variables with aggregation functions. ```json [ { "apiVersion": "recommender.com/v1", "kind": "KruizeMetadataProfile", "metadata": { "name": "cluster-metadata-local-monitoring" }, "profile_version": 1, "k8s_type": "openshift", "datasource": "prometheus", "query_variables": [ { "name": "namespacesAcrossCluster", "datasource": "prometheus", "value_type": "double", "kubernetes_object": "container", "aggregation_functions": [ { "function": "sum", "query": "sum by (namespace) (avg_over_time(kube_namespace_status_phase{namespace!=\"\"}[$MEASUREMENT_DURATION_IN_MIN$m]))" } ] }, { "name": "workloadsAcrossCluster", "datasource": "prometheus", "value_type": "double", "kubernetes_object": "container", "aggregation_functions": [ { "function": "sum", "query": "sum by (namespace, workload, workload_type) (avg_over_time(namespace_workload_pod:kube_pod_owner:relabel{workload!=\"\"}[$MEASUREMENT_DURATION_IN_MIN$m]))" } ] }, { "name": "containersAcrossCluster", "datasource": "prometheus", "value_type": "double", "kubernetes_object": "container", "aggregation_functions": [ { "function": "sum", "query": "sum by (container, image, workload, workload_type, namespace) (avg_over_time(kube_pod_container_info{container!=\"\"}[$MEASUREMENT_DURATION_IN_MIN$m]) * on (pod, namespace) group_left(workload, workload_type) avg_over_time(namespace_workload_pod:kube_pod_owner:relabel{workload!=\"\"}[$MEASUREMENT_DURATION_IN_MIN$m]))" } ] } ] } ] ``` -------------------------------- ### Call Create Experiment API (curl) Source: https://github.com/kruize/autotune/blob/master/design/AutoScalingModeAPI.md Example curl command to send a POST request to the /createExperiment endpoint, demonstrating how to include the JSON payload for creating a new experiment. ```bash curl -H 'Accept: application/json' -X POST --data 'copy paste below JSON' http://:/createExperiment ``` -------------------------------- ### Example Kruize Autotune Recommendation JSON Source: https://github.com/kruize/autotune/blob/master/design/BulkAPI.md This snippet provides a partial example of the JSON structure used by Kruize Autotune to convey recommendations. It includes sections for notifications (like critical errors or recommendation availability), monitoring timeframes, and details about recommendations generated by specific engines (cost, performance), including resource limits and requests. ```json "message": "CPU Request Not Set", "code": 523001 }, "524001": { "type": "critical", "message": "Memory Request Not Set", "code": 524001 }, "524002": { "type": "critical", "message": "Memory Limit Not Set", "code": 524002 } }, "monitoring_end_time": "2025-02-04T06:49:47.000Z", "current": {}, "recommendation_terms": { "short_term": { "duration_in_hours": 24, "notifications": { "112101": { "type": "info", "message": "Cost Recommendations Available", "code": 112101 }, "112102": { "type": "info", "message": "Performance Recommendations Available", "code": 112102 } }, "monitoring_start_time": "2025-02-03T06:49:47.000Z", "recommendation_engines": { "cost": { "pods_count": 1, "confidence_level": 0, "config": { "limits": { "cpu": { "amount": 0.247921867815971, "format": "cores" }, "memory": { "amount": 130137497.6, "format": "bytes" } }, "requests": { "cpu": { "amount": 0.247921867815971, "format": "cores" }, "memory": { "amount": 130137497.6, "format": "bytes" } } }, "variation": { "limits": { "cpu": { "amount": 0.247921867815971, "format": "cores" }, "memory": { "amount": 130137497.6, "format": "bytes" } }, "requests": { "cpu": { "amount": 0.247921867815971, "format": "cores" }, "memory": { "amount": 130137497.6, "format": "bytes" } } }, "notifications": {} }, "performance": { "pods_count": 1, "confidence_level": 0, "config": { "limits": { "cpu": { "amount": 0.247921867815971, "format": "cores" }, "memory": { "amount": 130137497.6, "format": "bytes" } ``` -------------------------------- ### Kruize Autotune Cost Recommendations JSON Example Source: https://github.com/kruize/autotune/blob/master/design/APISamples.md This JSON structure provides an example of cost recommendations within the Kruize Autotune data format, including cluster and Kubernetes object details, current resource configurations, and a notification about cost recommendations being available. ```json { "cluster_name": "cluster-one-division-bell", "kubernetes_objects": [ { "type": "deployment", "name": "my-sample-deployment", "namespace": "default", "containers": [ { "container_image_name": "my-sample-image", "container_name": "my-sample-container", "recommendations": { "notifications": { "112101": { "type": "info", "message": "Cost Recommendations Available", "code": 112101 } }, "data": { "2023-06-15T00:59:50.724Z": { "cost": { "short_term": { "monitoring_start_time": "2023-06-14T00:59:50.724Z", "monitoring_end_time": "2023-06-15T00:59:50.724Z", "duration_in_hours": 24.0, "pods_count": 0, "confidence_level": 0.0, "current": { "requests": { "memory": { "amount": 404.2, "format": "MiB" } }, "limits": { "memory": { "amount": 751.09, "format": "MiB" } } }, "config": { "requests": { "memory": { "amount": 1197.732 } } } } } } } } } ] } ], "version": "1.0", "experiment_name": "graceful-dinakar" } ``` -------------------------------- ### Configuring Datasource via ConfigMap (YAML) Source: https://github.com/kruize/autotune/blob/master/design/BulkAPI.md Example Kubernetes ConfigMap defining the datasource configuration for Kruize, specifying Prometheus as the provider and its service details within the openshift-monitoring namespace. ```yaml apiVersion: v1 kind: ConfigMap metadata: name: kruizeconfig namespace: openshift-tuning data: kruizeconfigjson: | { "datasource": [ { "name": "prometheus-1", "provider": "prometheus", "serviceName": "prometheus-k8s", "namespace": "openshift-monitoring", "url": "", "authentication": { "type": "bearer", "credentials": { "tokenFilePath": "/var/run/secrets/kubernetes.io/serviceaccount/token" } } } ] } ``` -------------------------------- ### Example: Run DB Migration Test Without Postgres Restart (Shell) Source: https://github.com/kruize/autotune/blob/master/tests/scripts/remote_monitoring_tests/db_migration_test.md An example command demonstrating how to run the database migration test script without a PostgreSQL restart, specifying previous and current Kruize image versions and a results directory. ```shell cd /tests/scripts/remote_monitoring_tests/db_migration_test ./db_migration_test_without_postgres_restart.sh -i quay.io/kruize/autotune_operator:0.0.19.5_mvp -j quay.io/kruize/autotune_operator:0.0.20.1_mvp -r /tmp/db_migration_results ``` -------------------------------- ### Querying Kruize Tunables with SLO Class (Shell) Source: https://github.com/kruize/autotune/blob/master/design/ExperimentModeAPI.md Example using curl to query the /listKruizeTunables endpoint, specifying the SLO class via a query parameter and requesting a JSON response. ```Shell curl -H 'Accept: application/json' http://:/listKruizeTunables?slo_class= ``` -------------------------------- ### Call Create Experiment Trial API with curl Source: https://github.com/kruize/autotune/blob/master/design/ExperimentModeAPI.md Example curl command to call the /createExperimentTrial API endpoint using a POST request and providing the JSON payload. ```shell curl -H 'Accept: application/json' -X POST --data 'copy paste below JSON' http://:/createExperimentTrial ``` -------------------------------- ### Example Bulk Endpoint Response (Metadata) - JSON Source: https://github.com/kruize/autotune/blob/master/design/BulkAPI.md Shows the structure of the JSON response when requesting metadata from the /bulk endpoint, detailing datasources, clusters, namespaces, workloads, and containers identified for recommendations. ```json { "metadata": { "datasources": { "prometheus-1": { "clusters": { "default": { "namespaces": { "default": { "namespace": "default", "workloads": null }, "local-path-storage": { "namespace": "local-path-storage", "workloads": { "local-path-provisioner": { "containers": { "local-path-provisioner": { "container_name": "local-path-provisioner", "container_image_name": "docker.io/kindest/local-path-provisioner:v0.0.22-kind.0" } }, "workload_name": "local-path-provisioner", "workload_type": "deployment" } } }, "cadvisor": { "namespace": "cadvisor", "workloads": { "cadvisor": { "containers": { "cadvisor": { "container_name": "cadvisor", "container_image_name": "gcr.io/cadvisor/cadvisor:v0.45.0" } }, "workload_name": "cadvisor", "workload_type": "daemonset" } } }, "kube-node-lease": { "namespace": "kube-node-lease", "workloads": null }, "kube-system": { "namespace": "kube-system", "workloads": { "coredns": { "containers": { "coredns": { "container_name": "coredns", "container_image_name": "k8s.gcr.io/coredns/coredns:v1.8.6" } }, "workload_name": "coredns", "workload_type": "deployment" }, "kube-proxy": { "containers": { "kube-proxy": { "container_name": "kube-proxy", "container_image_name": "k8s.gcr.io/kube-proxy:v1.24.0" } }, "workload_name": "kube-proxy", ``` -------------------------------- ### Run All Remote Monitoring Tests with test_autotune.sh - Shell Source: https://github.com/kruize/autotune/blob/master/tests/scripts/remote_monitoring_tests/Remote_monitoring_tests.md Example command to execute all tests within the 'remote_monitoring_tests' suite using the test_autotune.sh script, specifying minikube as the cluster type and a custom results directory. ```Shell /tests/test_autotune.sh -c minikube --testsuite=remote_monitoring_tests --resultsdir=/home/results ``` -------------------------------- ### Example Kruize Autotune Recommendation JSON (Cluster/Deployment View) Source: https://github.com/kruize/autotune/blob/master/design/APISamples.md This JSON snippet illustrates the structure of recommendations focused on a specific deployment within a cluster. It includes notifications and potentially cost-related data for containers. ```json { "cluster_name": "cluster-one-division-bell", "kubernetes_objects": [ { "type": "deployment", "name": "my-sample-deployment", "namespace": "default", "containers": [ { "container_image_name": "my-sample-image", "container_name": "my-sample-container", "recommendations": { "notifications": { "112101": { "type": "info", "message": "Cost Recommendations Available", "code": 112101 } }, "data": { "2023-06-15T00:58:50.033Z": { "cost": { "short_term": { "monitoring_start_time": "2023-06-14T00:58:50.033Z", "monitoring_end_time": "2023-06-15T00:58:50.033Z", "duration_in_hours": 24.0, "pods_count": 1, "confidence_level": 0.0, "current": { "requests": { "memory": { "amount": 237.52, "format": "MiB" }, "cpu": { "amount": 0.23, "format": "cores" } } } } } } } } } ] } ] } ``` -------------------------------- ### Create Experiment API Success Response (JSON) Source: https://github.com/kruize/autotune/blob/master/design/AutoScalingModeAPI.md Example JSON response indicating successful registration of an experiment via the /createExperiment API. It includes a success message, HTTP code (201 for created), documentation link (if any), and status. ```json { "message": "Experiment registered successfully with Autotune. View registered experiments at /listExperiments", "httpcode": 201, "documentationLink": "", "status": "SUCCESS" } ```