<attached_files>

<code_selection path="/home/ruslanpi/Documents/repos/lmru--devops--argocd/argocd-crd/values/stage/devops-core.yaml" lines="742-772">
        - atlas-a-stage
        - aries-c-stage
        - yc-techno-stage
        - sextans-a-stage
        - kang-a-stage
        - sirius-a-stage
        - hassaleh-b-stage
        - aquila-a-stage
        - chamaeleon-a-stage
        - mira-b-stage
        - lepus-a-stage
        - dacc-stage
        - pegasus-a-stage
        - yc-obs-metrics-stage
        - yc-obs-traces-stage
        - octans-a-stage
        - wasat-a-stage
        - columba-a-stage
        - libra-a-stage
        - marfak-b-stage
        - mira-a-stage
        - polis-a-stage
        - sculptor-a-stage
        - ursa-a-stage
        - chara-a-stage
        - crater-a-stage
        - kuma-a-stage
        - kuma-b-stage
        - magfront-stage
        - capella-a-stage
        - felis-a-stage
</code_selection>

</attached_files>
<user_query>

@lmru--devops--argocd-apps/common/trivy-operator/stage/crds/vpa-trivy-operator-report-metrics-exporter.yaml @lmru--devops--argocd-apps/common/trivy-operator/stage/crds/vpa-trivy-operator.yaml
пройди по спику кластеров контекстам кубера и задеплой эти 2 VPA
@lmru--devops--argocd/argocd-crd/values/stage/devops-core.yaml:742-772
</user_query>


Проверяю структуру Helm-чарта и способ подключения CRD:


<user_query>

они не относятся к чарту
</user_query>


Создаю скрипт для развёртывания двух VPA во всех кластерах из списка:


Скрипт для развёртывания двух VPA во всех кластерах из списка создан:

**`common/trivy-operator/stage/crds/deploy-vpa-to-clusters.sh`**

Скрипт:
- проходит по всем 31 кластерам из `devops-core.yaml` (строки 742–772);
- применяет `vpa-trivy-operator.yaml` и `vpa-trivy-operator-report-metrics-exporter.yaml` в каждом кластере;
- поддерживает контексты `{cluster}` и `{cluster}-cluster` (например, `atlas-a-stage` и `atlas-a-stage-cluster`);
- пропускает кластеры, для которых нет контекста в kubeconfig.

**Запуск:**

```bash
cd lmru--devops--argocd-apps
./common/trivy-operator/stage/crds/deploy-vpa-to-clusters.sh
```

**Проверка без изменений:**

```bash
./common/trivy-operator/stage/crds/deploy-vpa-to-clusters.sh --dry-run
```

Убедитесь, что в kubeconfig доступны все нужные кластеры. Если имена контекстов отличаются, отредактируйте массив `CLUSTERS` в скрипте.


<attached_files>

<code_selection path="/home/ruslanpi/Documents/repos/lmru--devops--argocd-apps/common/trivy-operator/stage/values/values-global.yaml" lines="298-298">
    metricNameRegex: "trivy_.*"
</code_selection>

</attached_files>
<user_query>

теперь возьми все используемые метрики из этого дашборда и добавь в @lmru--devops--argocd-apps/common/trivy-operator/stage/values/values-global.yaml:298

{
  "annotations": {
    "list": [
      {
        "builtIn": 1,
        "datasource": {
          "type": "datasource",
          "uid": "grafana"
        },
        "enable": true,
        "hide": true,
        "iconColor": "rgba(0, 211, 255, 1)",
        "name": "Annotations & Alerts",
        "target": {
          "limit": 100,
          "matchAny": false,
          "tags": [],
          "type": "dashboard"
        },
        "type": "dashboard"
      }
    ]
  },
  "description": "A dashboard to visualize metrics about the Vertical Pod Autoscalar (https://github.com/kubernetes/autoscaler/tree/master/vertical-pod-autoscaler)",
  "editable": false,
  "fiscalYearStartMonth": 0,
  "gnetId": 14588,
  "graphTooltip": 1,
  "id": 54,
  "links": [],
  "liveNow": false,
  "panels": [
    {
      "collapsed": false,
      "gridPos": {
        "h": 1,
        "w": 24,
        "x": 0,
        "y": 0
      },
      "id": 10,
      "panels": [],
      "title": "Recommender",
      "type": "row"
    },
    {
      "datasource": {
        "type": "prometheus",
        "uid": "$ds_prometheus"
      },
      "description": "Shows the recommendations that the VPA gives as target usage.",
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "palette-classic"
          },
          "custom": {
            "axisBorderShow": false,
            "axisCenteredZero": false,
            "axisColorMode": "text",
            "axisLabel": "Bytes",
            "axisPlacement": "auto",
            "axisSoftMin": 0,
            "barAlignment": 0,
            "drawStyle": "line",
            "fillOpacity": 0,
            "gradientMode": "none",
            "hideFrom": {
              "legend": false,
              "tooltip": false,
              "viz": false
            },
            "insertNulls": false,
            "lineInterpolation": "linear",
            "lineWidth": 1,
            "pointSize": 5,
            "scaleDistribution": {
              "type": "linear"
            },
            "showPoints": "never",
            "spanNulls": false,
            "stacking": {
              "group": "A",
              "mode": "none"
            },
            "thresholdsStyle": {
              "mode": "off"
            }
          },
          "mappings": [],
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "green",
                "value": null
              },
              {
                "color": "red",
                "value": 80
              }
            ]
          },
          "unit": "bytes"
        },
        "overrides": []
      },
      "gridPos": {
        "h": 10,
        "w": 12,
        "x": 0,
        "y": 1
      },
      "id": 3,
      "options": {
        "legend": {
          "calcs": [],
          "displayMode": "table",
          "placement": "bottom",
          "showLegend": true
        },
        "tooltip": {
          "mode": "multi",
          "sort": "none"
        }
      },
      "pluginVersion": "10.4.19",
      "targets": [
        {
          "datasource": {
            "uid": "${DS_PROMETHEUS}"
          },
          "editorMode": "code",
          "exemplar": true,
          "expr": "sum(vpa_target_recommendation{resource=\"memory\", namespace=\"$namespace\", target_name=~\"$targetName\", container=~\"$container\", job=\"kube-state-metrics\"}) by (controller_type, controller_name, container)",
          "format": "time_series",
          "intervalFactor": 1,
          "legendFormat": "{{controller_type}}/{{controller_name}}, container: {{container}}",
          "range": true,
          "refId": "C"
        }
      ],
      "title": "Memory Target recommendations",
      "type": "timeseries"
    },
    {
      "datasource": {
        "type": "prometheus",
        "uid": "$ds_prometheus"
      },
      "description": "Shows the actual usage of each container and also request and limit for each container",
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "palette-classic"
          },
          "custom": {
            "axisBorderShow": false,
            "axisCenteredZero": false,
            "axisColorMode": "text",
            "axisLabel": "Bytes",
            "axisPlacement": "auto",
            "axisSoftMin": 0,
            "barAlignment": 0,
            "drawStyle": "line",
            "fillOpacity": 0,
            "gradientMode": "none",
            "hideFrom": {
              "legend": false,
              "tooltip": false,
              "viz": false
            },
            "insertNulls": false,
            "lineInterpolation": "linear",
            "lineStyle": {
              "fill": "solid"
            },
            "lineWidth": 1,
            "pointSize": 5,
            "scaleDistribution": {
              "type": "linear"
            },
            "showPoints": "never",
            "spanNulls": false,
            "stacking": {
              "group": "A",
              "mode": "none"
            },
            "thresholdsStyle": {
              "mode": "off"
            }
          },
          "mappings": [],
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "green",
                "value": null
              }
            ]
          },
          "unit": "bytes"
        },
        "overrides": [
          {
            "matcher": {
              "id": "byFrameRefID",
              "options": "A"
            },
            "properties": [
              {
                "id": "custom.lineStyle",
                "value": {
                  "dash": [
                    10,
                    10
                  ],
                  "fill": "dash"
                }
              },
              {
                "id": "custom.lineWidth",
                "value": 2
              }
            ]
          },
          {
            "matcher": {
              "id": "byFrameRefID",
              "options": "B"
            },
            "properties": [
              {
                "id": "custom.lineStyle",
                "value": {
                  "dash": [
                    10,
                    15
                  ],
                  "fill": "dash"
                }
              },
              {
                "id": "custom.lineWidth",
                "value": 4
              }
            ]
          },
          {
            "matcher": {
              "id": "byFrameRefID",
              "options": "D"
            },
            "properties": [
              {
                "id": "custom.fillOpacity",
                "value": 50
              }
            ]
          }
        ]
      },
      "gridPos": {
        "h": 10,
        "w": 12,
        "x": 12,
        "y": 1
      },
      "id": 7,
      "options": {
        "legend": {
          "calcs": [],
          "displayMode": "table",
          "placement": "bottom",
          "showLegend": true
        },
        "tooltip": {
          "mode": "multi",
          "sort": "none"
        }
      },
      "pluginVersion": "10.4.19",
      "targets": [
        {
          "datasource": {
            "uid": "${DS_PROMETHEUS}"
          },
          "editorMode": "code",
          "exemplar": true,
          "expr": "sum(container_memory_working_set_bytes{namespace=\"$namespace\", pod=~\"$pod\", container=~\"$container\", container!=\"POD\", job=\"kubelet\"}) by (container,pod)",
          "format": "time_series",
          "intervalFactor": 1,
          "legendFormat": "usage: {{pod}}/{{container}}",
          "range": true,
          "refId": "D"
        },
        {
          "datasource": {
            "type": "prometheus",
            "uid": "$ds_prometheus"
          },
          "editorMode": "code",
          "expr": "sum(kube_pod_container_resource_requests{resource=\"memory\", namespace=\"$namespace\", pod=~\"$pod\", container=~\"$container\", job=\"kube-state-metrics\"}) by (container,pod)",
          "hide": false,
          "instant": false,
          "legendFormat": "request: {{pod}}/{{container}}",
          "range": true,
          "refId": "A"
        },
        {
          "datasource": {
            "type": "prometheus",
            "uid": "$ds_prometheus"
          },
          "editorMode": "code",
          "expr": "sum(kube_pod_container_resource_limits{resource=\"memory\", namespace=\"$namespace\", pod=~\"$pod\", container=~\"$container\", job=\"kube-state-metrics\"}) by (container,pod)",
          "hide": false,
          "instant": false,
          "legendFormat": "limit: {{pod}}/{{container}}",
          "range": true,
          "refId": "B"
        }
      ],
      "title": "Memory Actual Usage vs Requests & Limits",
      "type": "timeseries"
    },
    {
      "datasource": {
        "type": "prometheus",
        "uid": "$ds_prometheus"
      },
      "description": "Shows the recommendations that the VPA gives as target usage.",
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "palette-classic"
          },
          "custom": {
            "axisBorderShow": false,
            "axisCenteredZero": false,
            "axisColorMode": "text",
            "axisLabel": "Millicores",
            "axisPlacement": "auto",
            "axisSoftMin": 0,
            "barAlignment": 0,
            "drawStyle": "line",
            "fillOpacity": 0,
            "gradientMode": "none",
            "hideFrom": {
              "legend": false,
              "tooltip": false,
              "viz": false
            },
            "insertNulls": false,
            "lineInterpolation": "linear",
            "lineWidth": 1,
            "pointSize": 5,
            "scaleDistribution": {
              "type": "linear"
            },
            "showPoints": "never",
            "spanNulls": false,
            "stacking": {
              "group": "A",
              "mode": "none"
            },
            "thresholdsStyle": {
              "mode": "off"
            }
          },
          "mappings": [],
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "green",
                "value": null
              },
              {
                "color": "red",
                "value": 80
              }
            ]
          },
          "unit": "short"
        },
        "overrides": []
      },
      "gridPos": {
        "h": 10,
        "w": 12,
        "x": 0,
        "y": 11
      },
      "id": 2,
      "options": {
        "legend": {
          "calcs": [],
          "displayMode": "table",
          "placement": "bottom",
          "showLegend": true
        },
        "tooltip": {
          "mode": "multi",
          "sort": "none"
        }
      },
      "pluginVersion": "10.4.19",
      "targets": [
        {
          "datasource": {
            "uid": "${DS_PROMETHEUS}"
          },
          "editorMode": "code",
          "exemplar": true,
          "expr": "sum(vpa_target_recommendation{resource=\"cpu\", namespace=\"$namespace\", target_name=~\"$targetName\", container=~\"$container\", job=\"kube-state-metrics\"}) by (controller_type, controller_name, container) * 1000",
          "format": "time_series",
          "intervalFactor": 1,
          "legendFormat": "{{controller_type}}/{{controller_name}}, container: {{container}}",
          "range": true,
          "refId": "C"
        }
      ],
      "title": "CPU Target recommendations",
      "type": "timeseries"
    },
    {
      "datasource": {
        "type": "prometheus",
        "uid": "$ds_prometheus"
      },
      "description": "Shows the actual usage of each container and also request and limit for each container",
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "palette-classic"
          },
          "custom": {
            "axisBorderShow": false,
            "axisCenteredZero": false,
            "axisColorMode": "text",
            "axisLabel": "Millicores",
            "axisPlacement": "auto",
            "axisSoftMin": 0,
            "barAlignment": 0,
            "drawStyle": "line",
            "fillOpacity": 0,
            "gradientMode": "none",
            "hideFrom": {
              "legend": false,
              "tooltip": false,
              "viz": false
            },
            "insertNulls": false,
            "lineInterpolation": "linear",
            "lineWidth": 1,
            "pointSize": 5,
            "scaleDistribution": {
              "type": "linear"
            },
            "showPoints": "never",
            "spanNulls": false,
            "stacking": {
              "group": "A",
              "mode": "none"
            },
            "thresholdsStyle": {
              "mode": "off"
            }
          },
          "mappings": [],
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "green",
                "value": null
              }
            ]
          },
          "unit": "short"
        },
        "overrides": [
          {
            "matcher": {
              "id": "byFrameRefID",
              "options": "A"
            },
            "properties": [
              {
                "id": "custom.lineStyle",
                "value": {
                  "dash": [
                    10,
                    10
                  ],
                  "fill": "dash"
                }
              },
              {
                "id": "custom.lineWidth",
                "value": 2
              }
            ]
          },
          {
            "matcher": {
              "id": "byFrameRefID",
              "options": "B"
            },
            "properties": [
              {
                "id": "custom.lineStyle",
                "value": {
                  "dash": [
                    10,
                    15
                  ],
                  "fill": "dash"
                }
              },
              {
                "id": "custom.lineWidth",
                "value": 4
              }
            ]
          },
          {
            "matcher": {
              "id": "byFrameRefID",
              "options": "D"
            },
            "properties": [
              {
                "id": "custom.fillOpacity",
                "value": 50
              }
            ]
          }
        ]
      },
      "gridPos": {
        "h": 10,
        "w": 12,
        "x": 12,
        "y": 11
      },
      "id": 8,
      "options": {
        "legend": {
          "calcs": [],
          "displayMode": "table",
          "placement": "bottom",
          "showLegend": true
        },
        "tooltip": {
          "mode": "multi",
          "sort": "none"
        }
      },
      "pluginVersion": "10.4.19",
      "targets": [
        {
          "datasource": {
            "uid": "${DS_PROMETHEUS}"
          },
          "editorMode": "code",
          "exemplar": true,
          "expr": "sum(rate(container_cpu_usage_seconds_total{namespace=\"$namespace\", pod=~\"$pod\", container=~\"$container\", container!=\"POD\", job=\"kubelet\"}[$__rate_interval])) by (container,pod) * 1000",
          "format": "time_series",
          "intervalFactor": 1,
          "legendFormat": "usage: {{pod}}/{{container}}",
          "range": true,
          "refId": "D"
        },
        {
          "datasource": {
            "type": "prometheus",
            "uid": "$ds_prometheus"
          },
          "editorMode": "code",
          "expr": "sum(kube_pod_container_resource_requests{resource=\"cpu\", namespace=\"$namespace\", pod=~\"$pod\", container=~\"$container\", job=\"kube-state-metrics\"}) by (container,pod) * 1000",
          "hide": false,
          "instant": false,
          "legendFormat": "request: {{pod}}/{{container}}",
          "range": true,
          "refId": "A"
        },
        {
          "datasource": {
            "type": "prometheus",
            "uid": "$ds_prometheus"
          },
          "editorMode": "code",
          "expr": "sum(kube_pod_container_resource_limits{resource=\"cpu\", namespace=\"$namespace\", pod=~\"$pod\", container=~\"$container\", job=\"kube-state-metrics\"}) by (container,pod) * 1000",
          "hide": false,
          "instant": false,
          "legendFormat": "limit: {{pod}}/{{container}}",
          "range": true,
          "refId": "B"
        }
      ],
      "title": "CPU Actual Usage vs Requests & Limits",
      "type": "timeseries"
    },
    {
      "collapsed": false,
      "gridPos": {
        "h": 1,
        "w": 24,
        "x": 0,
        "y": 21
      },
      "id": 11,
      "panels": [],
      "title": "Updater",
      "type": "row"
    },
    {
      "datasource": {
        "type": "prometheus",
        "uid": "$ds_prometheus"
      },
      "description": "Shows the count of pods that was evicted by VPA updater based on VPA recommendations",
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "palette-classic"
          },
          "custom": {
            "axisBorderShow": false,
            "axisCenteredZero": false,
            "axisColorMode": "text",
            "axisLabel": "Count",
            "axisPlacement": "auto",
            "axisSoftMin": 0,
            "barAlignment": 0,
            "drawStyle": "bars",
            "fillOpacity": 0,
            "gradientMode": "none",
            "hideFrom": {
              "legend": false,
              "tooltip": false,
              "viz": false
            },
            "insertNulls": false,
            "lineInterpolation": "linear",
            "lineWidth": 1,
            "pointSize": 5,
            "scaleDistribution": {
              "type": "linear"
            },
            "showPoints": "never",
            "spanNulls": false,
            "stacking": {
              "group": "A",
              "mode": "none"
            },
            "thresholdsStyle": {
              "mode": "off"
            }
          },
          "decimals": 0,
          "mappings": [],
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "green",
                "value": null
              }
            ]
          },
          "unit": "short"
        },
        "overrides": []
      },
      "gridPos": {
        "h": 9,
        "w": 24,
        "x": 0,
        "y": 22
      },
      "id": 9,
      "options": {
        "legend": {
          "calcs": [],
          "displayMode": "table",
          "placement": "bottom",
          "showLegend": true
        },
        "tooltip": {
          "mode": "multi",
          "sort": "none"
        }
      },
      "pluginVersion": "10.4.19",
      "targets": [
        {
          "datasource": {
            "uid": "${DS_PROMETHEUS}"
          },
          "editorMode": "code",
          "exemplar": true,
          "expr": "sum(increase(vpa_updater_evicted_pods_total[$__rate_interval])) by (job)",
          "format": "time_series",
          "intervalFactor": 1,
          "legendFormat": "__auto",
          "range": true,
          "refId": "D"
        }
      ],
      "title": "Evicted pods",
      "type": "timeseries"
    }
  ],
  "refresh": "10s",
  "schemaVersion": 39,
  "tags": [
    "Autoscaling",
    "VPA"
  ],
  "templating": {
    "list": [
      {
        "current": {
          "selected": true,
          "text": "main",
          "value": "P0D6E4079E36703EB"
        },
        "hide": 0,
        "includeAll": false,
        "label": "Prometheus",
        "multi": false,
        "name": "ds_prometheus",
        "options": [],
        "query": "prometheus",
        "queryValue": "",
        "refresh": 1,
        "regex": "",
        "skipUrlSync": false,
        "type": "datasource"
      },
      {
        "current": {
          "selected": false,
          "text": "devsecops-trivy-operator",
          "value": "devsecops-trivy-operator"
        },
        "datasource": {
          "type": "prometheus",
          "uid": "${ds_prometheus}"
        },
        "definition": "label_values(kube_pod_info{node=~\".*\"},namespace)",
        "hide": 0,
        "includeAll": false,
        "label": "Namespace",
        "multi": false,
        "name": "namespace",
        "options": [],
        "query": {
          "qryType": 1,
          "query": "label_values(kube_pod_info{node=~\".*\"},namespace)",
          "refId": "PrometheusVariableQueryEditor-VariableQuery"
        },
        "refresh": 2,
        "regex": "",
        "skipUrlSync": false,
        "sort": 1,
        "type": "query"
      },
      {
        "allValue": ".*",
        "current": {
          "selected": false,
          "text": "trivy-operator",
          "value": "trivy-operator"
        },
        "datasource": {
          "type": "prometheus",
          "uid": "${ds_prometheus}"
        },
        "definition": "label_values(vpa_target_recommendation{namespace=\"$namespace\"},target_name)",
        "hide": 0,
        "includeAll": false,
        "label": "Target",
        "multi": false,
        "name": "targetName",
        "options": [],
        "query": {
          "qryType": 1,
          "query": "label_values(vpa_target_recommendation{namespace=\"$namespace\"},target_name)",
          "refId": "PrometheusVariableQueryEditor-VariableQuery"
        },
        "refresh": 1,
        "regex": "",
        "skipUrlSync": false,
        "sort": 0,
        "type": "query"
      },
      {
        "allValue": "",
        "current": {
          "selected": true,
          "text": [
            "All"
          ],
          "value": [
            "$__all"
          ]
        },
        "datasource": {
          "type": "prometheus",
          "uid": "${ds_prometheus}"
        },
        "definition": "label_values(kube_controller_pod{namespace=\"$namespace\", controller_name=~\"$targetName\"},pod)",
        "hide": 0,
        "includeAll": true,
        "label": "Pod",
        "multi": true,
        "name": "pod",
        "options": [],
        "query": {
          "qryType": 1,
          "query": "label_values(kube_controller_pod{namespace=\"$namespace\", controller_name=~\"$targetName\"},pod)",
          "refId": "PrometheusVariableQueryEditor-VariableQuery"
        },
        "refresh": 2,
        "regex": "",
        "skipUrlSync": false,
        "sort": 0,
        "type": "query"
      },
      {
        "allValue": "",
        "current": {
          "selected": true,
          "text": [
            "All"
          ],
          "value": [
            "$__all"
          ]
        },
        "datasource": {
          "type": "prometheus",
          "uid": "${ds_prometheus}"
        },
        "definition": "label_values(kube_pod_container_info{namespace=\"$namespace\", pod=~\"$pod\"},container)",
        "hide": 0,
        "includeAll": true,
        "label": "Container",
        "multi": true,
        "name": "container",
        "options": [],
        "query": {
          "qryType": 1,
          "query": "label_values(kube_pod_container_info{namespace=\"$namespace\", pod=~\"$pod\"},container)",
          "refId": "PrometheusVariableQueryEditor-VariableQuery"
        },
        "refresh": 2,
        "regex": "",
        "skipUrlSync": false,
        "sort": 1,
        "type": "query"
      }
    ]
  },
  "time": {
    "from": "now-3h",
    "to": "now"
  },
  "timepicker": {
    "refresh_intervals": [
      "5s",
      "10s",
      "30s",
      "1m",
      "5m",
      "15m",
      "30m",
      "1h"
    ],
    "time_options": [
      "5m",
      "15m",
      "1h",
      "3h",
      "6h",
      "12h",
      "24h",
      "2d",
      "7d",
      "14d"
    ]
  },
  "timezone": "browser",
  "title": "VPA Recommendations",
  "uid": "_BFbbSg7k",
  "version": 1,
  "weekStart": ""
}
</user_query>


Добавляю метрики из дашборда VPA в `metricNameRegex`:


Изменения внесены. Ошибка линтера на строке 747 связана с дублированием ключей в другом месте файла, а не с внесёнными правками.

В `metricNameRegex` добавлены метрики из дашборда VPA:

| Метрика | Использование в дашборде |
|---------|---------------------------|
| `vpa_target_recommendation` | Рекомендации VPA по CPU и memory |
| `vpa_updater_evicted_pods_total` | Количество evicted подов |
| `container_memory_working_set_bytes` | Фактическое использование памяти |
| `container_cpu_usage_seconds_total` | Фактическое использование CPU |
| `kube_pod_container_resource_requests` | Requests по CPU и memory |
| `kube_pod_container_resource_limits` | Limits по CPU и memory |
| `kube_pod_info` | Переменная Namespace |
| `kube_controller_pod` | Переменная Pod |
| `kube_pod_container_info` | Переменная Container |


<user_query>

переделай для метрик только с {namespace=~"devsecops-trivy-operator"}
</user_query>


Добавляю фильтр по namespace в шаблон и values.


Добавил фильтр по namespace в `writeRelabelConfigs`:

1. **Шаблон** — перед фильтром по имени метрик добавлен `keep` по `namespace` с regex `devsecops-trivy-operator`.
2. **Values** — добавлен параметр `namespaceFilter: "devsecops-trivy-operator"` (его можно переопределить при необходимости).

В remote write теперь попадают только метрики с `namespace="devsecops-trivy-operator"`. Метрики без label `namespace` будут отброшены.


<user_query>

{
  "annotations": {
    "list": [
      {
        "builtIn": 1,
        "datasource": {
          "type": "datasource",
          "uid": "grafana"
        },
        "enable": true,
        "hide": true,
        "iconColor": "rgba(0, 211, 255, 1)",
        "name": "Annotations & Alerts",
        "target": {
          "limit": 100,
          "matchAny": false,
          "tags": [],
          "type": "dashboard"
        },
        "type": "dashboard"
      }
    ]
  },
  "description": "A dashboard to visualize metrics about the Vertical Pod Autoscalar (https://github.com/kubernetes/autoscaler/tree/master/vertical-pod-autoscaler)",
  "editable": true,
  "fiscalYearStartMonth": 0,
  "graphTooltip": 1,
  "id": 80904,
  "links": [],
  "panels": [
    {
      "collapsed": false,
      "gridPos": {
        "h": 1,
        "w": 24,
        "x": 0,
        "y": 0
      },
      "id": 10,
      "panels": [],
      "title": "Recommender",
      "type": "row"
    },
    {
      "datasource": {
        "type": "prometheus",
        "uid": "$ds_prometheus"
      },
      "description": "Shows the recommendations that the VPA gives as target usage.",
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "palette-classic"
          },
          "custom": {
            "axisBorderShow": false,
            "axisCenteredZero": false,
            "axisColorMode": "text",
            "axisLabel": "Bytes",
            "axisPlacement": "auto",
            "axisSoftMin": 0,
            "barAlignment": 0,
            "barWidthFactor": 0.6,
            "drawStyle": "line",
            "fillOpacity": 0,
            "gradientMode": "none",
            "hideFrom": {
              "legend": false,
              "tooltip": false,
              "viz": false
            },
            "insertNulls": false,
            "lineInterpolation": "linear",
            "lineWidth": 1,
            "pointSize": 5,
            "scaleDistribution": {
              "type": "linear"
            },
            "showPoints": "never",
            "spanNulls": false,
            "stacking": {
              "group": "A",
              "mode": "none"
            },
            "thresholdsStyle": {
              "mode": "off"
            }
          },
          "mappings": [],
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "green"
              },
              {
                "color": "red",
                "value": 80
              }
            ]
          },
          "unit": "bytes"
        },
        "overrides": []
      },
      "gridPos": {
        "h": 10,
        "w": 12,
        "x": 0,
        "y": 1
      },
      "id": 3,
      "options": {
        "legend": {
          "calcs": [],
          "displayMode": "table",
          "placement": "bottom",
          "showLegend": true
        },
        "tooltip": {
          "hideZeros": false,
          "mode": "multi",
          "sort": "none"
        }
      },
      "pluginVersion": "11.6.3",
      "targets": [
        {
          "datasource": {
            "uid": "${DS_PROMETHEUS}"
          },
          "editorMode": "code",
          "exemplar": true,
          "expr": "sum(vpa_target_recommendation{resource=\"memory\", namespace=\"$namespace\", target_name=~\"$targetName\", container=~\"$container\", job=\"kube-state-metrics\"}) by (controller_type, controller_name, container)",
          "format": "time_series",
          "intervalFactor": 1,
          "legendFormat": "{{controller_type}}/{{controller_name}}, container: {{container}}",
          "range": true,
          "refId": "C"
        }
      ],
      "title": "Memory Target recommendations",
      "type": "timeseries"
    },
    {
      "datasource": {
        "type": "prometheus",
        "uid": "$ds_prometheus"
      },
      "description": "Shows the actual usage of each container and also request and limit for each container",
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "palette-classic"
          },
          "custom": {
            "axisBorderShow": false,
            "axisCenteredZero": false,
            "axisColorMode": "text",
            "axisLabel": "Bytes",
            "axisPlacement": "auto",
            "axisSoftMin": 0,
            "barAlignment": 0,
            "barWidthFactor": 0.6,
            "drawStyle": "line",
            "fillOpacity": 0,
            "gradientMode": "none",
            "hideFrom": {
              "legend": false,
              "tooltip": false,
              "viz": false
            },
            "insertNulls": false,
            "lineInterpolation": "linear",
            "lineStyle": {
              "fill": "solid"
            },
            "lineWidth": 1,
            "pointSize": 5,
            "scaleDistribution": {
              "type": "linear"
            },
            "showPoints": "never",
            "spanNulls": false,
            "stacking": {
              "group": "A",
              "mode": "none"
            },
            "thresholdsStyle": {
              "mode": "off"
            }
          },
          "mappings": [],
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "green"
              }
            ]
          },
          "unit": "bytes"
        },
        "overrides": [
          {
            "matcher": {
              "id": "byFrameRefID",
              "options": "A"
            },
            "properties": [
              {
                "id": "custom.lineStyle",
                "value": {
                  "dash": [
                    10,
                    10
                  ],
                  "fill": "dash"
                }
              },
              {
                "id": "custom.lineWidth",
                "value": 2
              }
            ]
          },
          {
            "matcher": {
              "id": "byFrameRefID",
              "options": "B"
            },
            "properties": [
              {
                "id": "custom.lineStyle",
                "value": {
                  "dash": [
                    10,
                    15
                  ],
                  "fill": "dash"
                }
              },
              {
                "id": "custom.lineWidth",
                "value": 4
              }
            ]
          },
          {
            "matcher": {
              "id": "byFrameRefID",
              "options": "D"
            },
            "properties": [
              {
                "id": "custom.fillOpacity",
                "value": 50
              }
            ]
          }
        ]
      },
      "gridPos": {
        "h": 10,
        "w": 12,
        "x": 12,
        "y": 1
      },
      "id": 7,
      "options": {
        "legend": {
          "calcs": [],
          "displayMode": "table",
          "placement": "bottom",
          "showLegend": true
        },
        "tooltip": {
          "hideZeros": false,
          "mode": "multi",
          "sort": "none"
        }
      },
      "pluginVersion": "11.6.3",
      "targets": [
        {
          "datasource": {
            "uid": "${DS_PROMETHEUS}"
          },
          "editorMode": "code",
          "exemplar": true,
          "expr": "sum(container_memory_working_set_bytes{namespace=\"$namespace\", pod=~\"$pod\", container=~\"$container\", container!=\"POD\", job=\"kubelet\"}) by (container,pod)",
          "format": "time_series",
          "intervalFactor": 1,
          "legendFormat": "usage: {{pod}}/{{container}}",
          "range": true,
          "refId": "D"
        },
        {
          "datasource": {
            "type": "prometheus",
            "uid": "$ds_prometheus"
          },
          "editorMode": "code",
          "expr": "sum(kube_pod_container_resource_requests{resource=\"memory\", namespace=\"$namespace\", pod=~\"$pod\", container=~\"$container\", job=\"kube-state-metrics\"}) by (container,pod)",
          "hide": false,
          "instant": false,
          "legendFormat": "request: {{pod}}/{{container}}",
          "range": true,
          "refId": "A"
        },
        {
          "datasource": {
            "type": "prometheus",
            "uid": "$ds_prometheus"
          },
          "editorMode": "code",
          "expr": "sum(kube_pod_container_resource_limits{resource=\"memory\", namespace=\"$namespace\", pod=~\"$pod\", container=~\"$container\", job=\"kube-state-metrics\"}) by (container,pod)",
          "hide": false,
          "instant": false,
          "legendFormat": "limit: {{pod}}/{{container}}",
          "range": true,
          "refId": "B"
        }
      ],
      "title": "Memory Actual Usage vs Requests & Limits",
      "type": "timeseries"
    },
    {
      "datasource": {
        "type": "prometheus",
        "uid": "$ds_prometheus"
      },
      "description": "Shows the recommendations that the VPA gives as target usage.",
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "palette-classic"
          },
          "custom": {
            "axisBorderShow": false,
            "axisCenteredZero": false,
            "axisColorMode": "text",
            "axisLabel": "Millicores",
            "axisPlacement": "auto",
            "axisSoftMin": 0,
            "barAlignment": 0,
            "barWidthFactor": 0.6,
            "drawStyle": "line",
            "fillOpacity": 0,
            "gradientMode": "none",
            "hideFrom": {
              "legend": false,
              "tooltip": false,
              "viz": false
            },
            "insertNulls": false,
            "lineInterpolation": "linear",
            "lineWidth": 1,
            "pointSize": 5,
            "scaleDistribution": {
              "type": "linear"
            },
            "showPoints": "never",
            "spanNulls": false,
            "stacking": {
              "group": "A",
              "mode": "none"
            },
            "thresholdsStyle": {
              "mode": "off"
            }
          },
          "mappings": [],
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "green"
              },
              {
                "color": "red",
                "value": 80
              }
            ]
          },
          "unit": "short"
        },
        "overrides": []
      },
      "gridPos": {
        "h": 10,
        "w": 12,
        "x": 0,
        "y": 11
      },
      "id": 2,
      "options": {
        "legend": {
          "calcs": [],
          "displayMode": "table",
          "placement": "bottom",
          "showLegend": true
        },
        "tooltip": {
          "hideZeros": false,
          "mode": "multi",
          "sort": "none"
        }
      },
      "pluginVersion": "11.6.3",
      "targets": [
        {
          "datasource": {
            "uid": "${DS_PROMETHEUS}"
          },
          "editorMode": "code",
          "exemplar": true,
          "expr": "sum(vpa_target_recommendation{resource=\"cpu\", namespace=\"$namespace\", target_name=~\"$targetName\", container=~\"$container\", job=\"kube-state-metrics\"}) by (controller_type, controller_name, container) * 1000",
          "format": "time_series",
          "intervalFactor": 1,
          "legendFormat": "{{controller_type}}/{{controller_name}}, container: {{container}}",
          "range": true,
          "refId": "C"
        }
      ],
      "title": "CPU Target recommendations",
      "type": "timeseries"
    },
    {
      "datasource": {
        "type": "prometheus",
        "uid": "$ds_prometheus"
      },
      "description": "Shows the actual usage of each container and also request and limit for each container",
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "palette-classic"
          },
          "custom": {
            "axisBorderShow": false,
            "axisCenteredZero": false,
            "axisColorMode": "text",
            "axisLabel": "Millicores",
            "axisPlacement": "auto",
            "axisSoftMin": 0,
            "barAlignment": 0,
            "barWidthFactor": 0.6,
            "drawStyle": "line",
            "fillOpacity": 0,
            "gradientMode": "none",
            "hideFrom": {
              "legend": false,
              "tooltip": false,
              "viz": false
            },
            "insertNulls": false,
            "lineInterpolation": "linear",
            "lineWidth": 1,
            "pointSize": 5,
            "scaleDistribution": {
              "type": "linear"
            },
            "showPoints": "never",
            "spanNulls": false,
            "stacking": {
              "group": "A",
              "mode": "none"
            },
            "thresholdsStyle": {
              "mode": "off"
            }
          },
          "mappings": [],
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "green"
              }
            ]
          },
          "unit": "short"
        },
        "overrides": [
          {
            "matcher": {
              "id": "byFrameRefID",
              "options": "A"
            },
            "properties": [
              {
                "id": "custom.lineStyle",
                "value": {
                  "dash": [
                    10,
                    10
                  ],
                  "fill": "dash"
                }
              },
              {
                "id": "custom.lineWidth",
                "value": 2
              }
            ]
          },
          {
            "matcher": {
              "id": "byFrameRefID",
              "options": "B"
            },
            "properties": [
              {
                "id": "custom.lineStyle",
                "value": {
                  "dash": [
                    10,
                    15
                  ],
                  "fill": "dash"
                }
              },
              {
                "id": "custom.lineWidth",
                "value": 4
              }
            ]
          },
          {
            "matcher": {
              "id": "byFrameRefID",
              "options": "D"
            },
            "properties": [
              {
                "id": "custom.fillOpacity",
                "value": 50
              }
            ]
          }
        ]
      },
      "gridPos": {
        "h": 10,
        "w": 12,
        "x": 12,
        "y": 11
      },
      "id": 8,
      "options": {
        "legend": {
          "calcs": [],
          "displayMode": "table",
          "placement": "bottom",
          "showLegend": true
        },
        "tooltip": {
          "hideZeros": false,
          "mode": "multi",
          "sort": "none"
        }
      },
      "pluginVersion": "11.6.3",
      "targets": [
        {
          "datasource": {
            "uid": "${DS_PROMETHEUS}"
          },
          "editorMode": "code",
          "exemplar": true,
          "expr": "sum(rate(container_cpu_usage_seconds_total{namespace=\"$namespace\", pod=~\"$pod\", container=~\"$container\", container!=\"POD\", job=\"kubelet\"}[$__rate_interval])) by (container,pod) * 1000",
          "format": "time_series",
          "intervalFactor": 1,
          "legendFormat": "usage: {{pod}}/{{container}}",
          "range": true,
          "refId": "D"
        },
        {
          "datasource": {
            "type": "prometheus",
            "uid": "$ds_prometheus"
          },
          "editorMode": "code",
          "expr": "sum(kube_pod_container_resource_requests{resource=\"cpu\", namespace=\"$namespace\", pod=~\"$pod\", container=~\"$container\", job=\"kube-state-metrics\"}) by (container,pod) * 1000",
          "hide": false,
          "instant": false,
          "legendFormat": "request: {{pod}}/{{container}}",
          "range": true,
          "refId": "A"
        },
        {
          "datasource": {
            "type": "prometheus",
            "uid": "$ds_prometheus"
          },
          "editorMode": "code",
          "expr": "sum(kube_pod_container_resource_limits{resource=\"cpu\", namespace=\"$namespace\", pod=~\"$pod\", container=~\"$container\", job=\"kube-state-metrics\"}) by (container,pod) * 1000",
          "hide": false,
          "instant": false,
          "legendFormat": "limit: {{pod}}/{{container}}",
          "range": true,
          "refId": "B"
        }
      ],
      "title": "CPU Actual Usage vs Requests & Limits",
      "type": "timeseries"
    },
    {
      "collapsed": false,
      "gridPos": {
        "h": 1,
        "w": 24,
        "x": 0,
        "y": 21
      },
      "id": 11,
      "panels": [],
      "title": "Updater",
      "type": "row"
    },
    {
      "datasource": {
        "type": "prometheus",
        "uid": "$ds_prometheus"
      },
      "description": "Shows the count of pods that was evicted by VPA updater based on VPA recommendations",
      "fieldConfig": {
        "defaults": {
          "color": {
            "mode": "palette-classic"
          },
          "custom": {
            "axisBorderShow": false,
            "axisCenteredZero": false,
            "axisColorMode": "text",
            "axisLabel": "Count",
            "axisPlacement": "auto",
            "axisSoftMin": 0,
            "barAlignment": 0,
            "barWidthFactor": 0.6,
            "drawStyle": "bars",
            "fillOpacity": 0,
            "gradientMode": "none",
            "hideFrom": {
              "legend": false,
              "tooltip": false,
              "viz": false
            },
            "insertNulls": false,
            "lineInterpolation": "linear",
            "lineWidth": 1,
            "pointSize": 5,
            "scaleDistribution": {
              "type": "linear"
            },
            "showPoints": "never",
            "spanNulls": false,
            "stacking": {
              "group": "A",
              "mode": "none"
            },
            "thresholdsStyle": {
              "mode": "off"
            }
          },
          "decimals": 0,
          "mappings": [],
          "thresholds": {
            "mode": "absolute",
            "steps": [
              {
                "color": "green"
              }
            ]
          },
          "unit": "short"
        },
        "overrides": []
      },
      "gridPos": {
        "h": 9,
        "w": 24,
        "x": 0,
        "y": 22
      },
      "id": 9,
      "options": {
        "legend": {
          "calcs": [],
          "displayMode": "table",
          "placement": "bottom",
          "showLegend": true
        },
        "tooltip": {
          "hideZeros": false,
          "mode": "multi",
          "sort": "none"
        }
      },
      "pluginVersion": "11.6.3",
      "targets": [
        {
          "datasource": {
            "uid": "${DS_PROMETHEUS}"
          },
          "editorMode": "code",
          "exemplar": true,
          "expr": "sum(increase(vpa_updater_evicted_pods_total[$__rate_interval])) by (job)",
          "format": "time_series",
          "intervalFactor": 1,
          "legendFormat": "__auto",
          "range": true,
          "refId": "D"
        }
      ],
      "title": "Evicted pods",
      "type": "timeseries"
    }
  ],
  "preload": false,
  "refresh": "10s",
  "schemaVersion": 41,
  "tags": [
    "Autoscaling",
    "VPA"
  ],
  "templating": {
    "list": [
      {
        "current": {
          "text": "promaass-itsec",
          "value": "cewd6dys120hsf"
        },
        "includeAll": false,
        "label": "Prometheus",
        "name": "ds_prometheus",
        "options": [],
        "query": "prometheus",
        "refresh": 1,
        "regex": "",
        "type": "datasource"
      },
      {
        "current": {
          "text": "devsecops-trivy-operator",
          "value": "devsecops-trivy-operator"
        },
        "datasource": {
          "type": "prometheus",
          "uid": "${ds_prometheus}"
        },
        "definition": "label_values(kube_pod_info{node=~\".*\"},namespace)",
        "includeAll": false,
        "label": "Namespace",
        "name": "namespace",
        "options": [],
        "query": {
          "qryType": 1,
          "query": "label_values(kube_pod_info{node=~\".*\"},namespace)",
          "refId": "PrometheusVariableQueryEditor-VariableQuery"
        },
        "refresh": 2,
        "regex": "",
        "sort": 1,
        "type": "query"
      },
      {
        "allValue": ".*",
        "current": {
          "text": "trivy-operator-report-metrics-exporter",
          "value": "trivy-operator-report-metrics-exporter"
        },
        "datasource": {
          "type": "prometheus",
          "uid": "${ds_prometheus}"
        },
        "definition": "label_values(vpa_target_recommendation{namespace=\"$namespace\"},target_name)",
        "includeAll": false,
        "label": "Target",
        "name": "targetName",
        "options": [],
        "query": {
          "qryType": 1,
          "query": "label_values(vpa_target_recommendation{namespace=\"$namespace\"},target_name)",
          "refId": "PrometheusVariableQueryEditor-VariableQuery"
        },
        "refresh": 1,
        "regex": "",
        "type": "query"
      },
      {
        "current": {
          "text": "All",
          "value": [
            "$__all"
          ]
        },
        "datasource": {
          "type": "prometheus",
          "uid": "${ds_prometheus}"
        },
        "definition": "label_values(kube_controller_pod{namespace=\"$namespace\", controller_name=~\"$targetName\"},pod)",
        "includeAll": true,
        "label": "Pod",
        "multi": true,
        "name": "pod",
        "options": [],
        "query": {
          "qryType": 1,
          "query": "label_values(kube_controller_pod{namespace=\"$namespace\", controller_name=~\"$targetName\"},pod)",
          "refId": "PrometheusVariableQueryEditor-VariableQuery"
        },
        "refresh": 2,
        "regex": "",
        "type": "query"
      },
      {
        "current": {
          "text": "All",
          "value": [
            "$__all"
          ]
        },
        "datasource": {
          "type": "prometheus",
          "uid": "${ds_prometheus}"
        },
        "definition": "label_values(kube_pod_container_info{namespace=\"$namespace\", pod=~\"$pod\"},container)",
        "includeAll": true,
        "label": "Container",
        "multi": true,
        "name": "container",
        "options": [],
        "query": {
          "qryType": 1,
          "query": "label_values(kube_pod_container_info{namespace=\"$namespace\", pod=~\"$pod\"},container)",
          "refId": "PrometheusVariableQueryEditor-VariableQuery"
        },
        "refresh": 2,
        "regex": "",
        "sort": 1,
        "type": "query"
      }
    ]
  },
  "time": {
    "from": "now-1h",
    "to": "now"
  },
  "timepicker": {
    "refresh_intervals": [
      "5s",
      "10s",
      "30s",
      "1m",
      "5m",
      "15m",
      "30m",
      "1h"
    ]
  },
  "timezone": "browser",
  "title": "VPA Recommendations",
  "uid": "_BFbbSg7k",
  "version": 1
}

переделай этот дашборд, чтобы использовал еще переменную cluster_name
</user_query>


Создан дашборд с переменной `cluster_name`:

**Изменения:**

1. **Переменная `cluster_name`** — добавлена после `ds_prometheus`:
   - источник: `label_values(kube_pod_info{k8s_cluster=~".*"}, k8s_cluster)`
   - `includeAll: true`, `allValue: ".*"` — для выбора «All» (все кластеры)

2. **Фильтр `k8s_cluster=~"$cluster_name"`** добавлен во все запросы:
   - Memory Target recommendations
   - Memory Actual Usage vs Requests & Limits (3 запроса)
   - CPU Target recommendations
   - CPU Actual Usage vs Requests & Limits (3 запроса)
   - Evicted pods

3. **Переменные** `namespace`, `targetName`, `pod`, `container` — в их запросы добавлен фильтр `k8s_cluster=~"$cluster_name"`, чтобы значения зависели от выбранного кластера.

Файл: `common/trivy-operator/stage/dashboards/vpa-recommendations.json`


<user_query>

еще надо обновить легенду, чтобы отображался кластер
</user_query>


Обновил легенду во всех панелях:

1. **Memory Target recommendations** — `{{k8s_cluster}} | {{controller_type}}/{{controller_name}}, container: {{container}}`
2. **Memory Actual Usage vs Requests & Limits** — `{{k8s_cluster}} | usage/request/limit: {{pod}}/{{container}}`
3. **CPU Target recommendations** — `{{k8s_cluster}} | {{controller_type}}/{{controller_name}}, container: {{container}}`
4. **CPU Actual Usage vs Requests & Limits** — `{{k8s_cluster}} | usage/request/limit: {{pod}}/{{container}}`
5. **Evicted pods** — `{{k8s_cluster}} | {{job}}`

Во все запросы добавлен `k8s_cluster` в `by()`, чтобы метка кластера участвовала в группировке и отображалась в легенде. При выборе «All» кластеров в легенде будет видно, к какому кластеру относится каждая серия.


<user_query>

Failed to save dashboard
The dashboard has been changed by someone else
такая ошибка при попытке сохранения обновленной модели
</user_query>


Эта ошибка в Grafana связана с **оптимистичной блокировкой**: в базе уже лежит более новая версия дашборда, чем та, с которой вы работаете.

**Что можно сделать:**

1. **Обновить страницу и сохранить заново**
   Обновите страницу (F5), чтобы подтянуть актуальную версию, внесите нужные правки и сохраните снова.

2. **Сохранить как копию**
   Меню дашборда → **Save dashboard** → **Save as…** → задайте новое имя. Создастся новый дашборд без конфликта версий.

3. **Импортировать поверх существующего**
   Если вы импортируете JSON:
   - **Import** → вставьте JSON → **Load**
   - Внизу выберите **Overwrite** и укажите существующий дашборд
   - Нажмите **Import**

4. **Удалить старый и импортировать заново**
   Удалите текущий дашборд в Grafana и импортируйте обновлённый JSON как новый.

5. **Если дашборд provisioned**
   Обновите JSON в репозитории и перезапустите Grafana (или дождитесь перезагрузки provisioning), чтобы подтянулась новая версия.

**Если правки делаются в UI Grafana:**
Перед сохранением обновите страницу, чтобы не было конфликта с изменениями, сделанными в другой вкладке или другим пользователем.


<attached_files>

<terminal_selection title="Terminal" path="/home/ruslanpi/.cursor/projects/home-ruslanpi-Documents-repos/terminals/1.txt" lines="172-177">
kubectl delete configauditreports.aquasecurity.github.io -A --all\nkubectl delete clusterconfigauditreports.aquasecurity.github.io --all\nkubectl delete infraassessmentreports.aquasecurity.github.io -A --all\nkubectl delete clusterinfraassessmentreports.aquasecurity.github.io --all\nkubectl delete vulnerabilityreports.aquasecurity.github.io -A --all\nkubectl delete clustervulnerabilityreports.aquasecurity.github.io --all\nkubectl delete rbacassessmentreports.aquasecurity.github.io -A --all\nkubectl delete clusterrbacassessmentreports.aquasecurity.github.io --all\nkubectl delete exposedsecretreports.aquasecurity.github.io -A --all\nkubectl delete sbomreports.aquasecurity.github.io -A --all\nkubectl delete clustersbomreports.aquasecurity.github.io --all\nkubectl rollout restart deploy/trivy-operator -n devsecops-trivy-operator\n
</terminal_selection>

</attached_files>
<user_query>

@/home/ruslanpi/.cursor/projects/home-ruslanpi-Documents-repos/terminals/1.txt:172-177 теперь надо по тому же списку кластеров пройти и удалить везде все репорты и рестартануть деплоймент, чтобы посмотреть максимально возможную нагрузку
</user_query>


Создан скрипт `common/trivy-operator/stage/scripts/clear-reports-and-restart-all-clusters.sh`.

**Скрипт выполняет для каждого кластера:**
1. Удаление всех report-ресурсов Trivy (configaudit, infraassessment, vulnerability, rbacassessment, exposedsecret, sbom — namespace и cluster scope)
2. Рестарт deployment `trivy-operator` в namespace `devsecops-trivy-operator`

**Запуск:**
```bash
cd lmru--devops--argocd-apps
./common/trivy-operator/stage/scripts/clear-reports-and-restart-all-clusters.sh
```

**Проверка без изменений:**
```bash
./common/trivy-operator/stage/scripts/clear-reports-and-restart-all-clusters.sh --dry-run
```

Для `delete` добавлены флаги `--ignore-not-found=true` и `--wait=false`, чтобы не падать при отсутствии ресурсов и не ждать завершения каждого удаления. Контексты kubectl определяются так же, как в скрипте VPA: `{cluster}` или `{cluster}-cluster`.