> For the complete documentation index, see [llms.txt](https://docs.akamas.io/akamas-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.akamas.io/akamas-docs/3.1.2/knowledge-base/optimizing-a-live-k8s-deployment.md).

# Optimizing a live K8s deployment

In this live optimization, the goal is to minimize the cost of a Kubernetes deployment with a single replica while matching, some performance-related constraints (e.g. the response time).

Notice that the workload selection refers to the service throughput metric provided by Istio.

{% code lineNumbers="true" %}

```yaml
name: Optimize a Kubernetes Container
system: My Deployment
workflow: workflow

goal:
  objective: minimize
  function:
    formula: container.cost
  constraints:
    absolute:
      - name: response-time-slo
        formula: shippingservice_istio.istio_incoming_response_time_90_ms:max <= 10
      - name: shippingservice-restart-slo
        formula: shippingservice_pod.k8s_pod_container_restarts:max == 0
      - name: shippingservice-failures-slo
        formula: shippingservice_istio.istio_incoming_failed_transactions / shippingservice_istio.istio_incoming_success_transactions <= 0.1

workloadsSelection:
  - name: shippingservice_istio.istio_incoming_service_throughput

optimizerOptions:
  onlineMode: RECOMMEND
  experimentsWithBeta: 0

windowing:
  type: trim
  trim: [1m, 0s]
  task: Test

parametersSelection:
  - name: shippingservice.cpu_request
    domain: [10, 600]
  - name: shippingservice.memory_request
    domain: [64, 512]

parameterConstraints:
  - name: limits_over_cpu_usage_bsl
    formula: shippingservice.cpu_request >= 11

steps:
  - name: baseline
    type: baseline
    numberOfTrials: 14
    values:
      shippingservice.cpu_request: 200
      shippingservice.memory_request: 128

  - name: optimize
    type: optimize
    numberOfTrials: 14
    numberOfExperiments: 1000
    numberOfInitExperiments: 0
    maxFailedExperiments: 1000
```

{% endcode %}

An example of how this study can be extended to also include the JVM layer is provided by [Optimizing a live full-stack deployment (](/akamas-docs/3.1.2/knowledge-base/optimizing-a-live-full-stack-deployment-k8s-+-jvm.md)[K8S + JVM](/akamas-docs/3.1.2/knowledge-base/optimizing-a-live-full-stack-deployment-k8s-+-jvm.md)). &#x20;


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.akamas.io/akamas-docs/3.1.2/knowledge-base/optimizing-a-live-k8s-deployment.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
