title: Kubernetes: using HPA with metrics from other pods
body: <p>I have:</p>
  <ol>
  <li>deployments of services A and B in k8s</li>
  <li>Prometheus stack</li>
  </ol>
  <p>I wanna scale service A when metric m1 of service B is changed.
  Solutions which I found and not suitable more or less:</p>
  <ol>
  <li>I can define HPA for service A with the following part of spec:</li>
  </ol>
  <pre><code>  - type: Object
        object:
          metric:
            name: m1
          describedObject:
            apiVersion: api/v1
            kind: Pod
            name: certain-pod-of-service-B
          current:
            value: 10k
  </code></pre>
  <p>Technically, it will work. But it's not suitable for dynamic nature of k8s.
  Also I can't use pods metric (metrics: - type: Pods pods:) in HPA cause it will request m1 metric for pods of service A (which obviously doesn't have this)</p>
  <ol start="2">
  <li><p>Define custom metric in prometheus-adapter which query m1 metric from pods of service B. It's more suitable, but looks like workaround cause I already have a metric m1</p>
  </li>
  <li><p>The same for external metrics</p>
  </li>
  </ol>
  <p>I feel that I miss something cause it doesn't seem like a non realistic case :)
  So, advise me please how to scale one service by metric of another in k8s?</p>