<p>Small question on how to achieve horizontal pod autoscale please</p>
<p>I have a SpringBoot app that has Actuator/Micrometer/Prometheus plugins deployed in Kubernetes</p>
<p>Hence, very happy, I am seeing my metrics while making queries to the app</p>
<pre><code>curl http://my-service.com/prometheus
http_server_requests_seconds_count{application=&quot;my-service&quot;,exception=&quot;None&quot;,method=&quot;POST&quot;,outcome=&quot;SUCCESS&quot;,status=&quot;200&quot;,uri=&quot;/myRoute&quot;,} 1.0
</code></pre>
<p>And also seeing the time series in a Prometheus server in location X, seeing the graphs. Very happy, so far so good.</p>
<p>However, when I want to autoscale, nothing is happening.</p>
<pre><code>apiVersion: autoscaling/v2beta1
kind: HorizontalPodAutoscaler
metadata:
  name: my-service
spec:
  scaleTargetRef:
    apiVersion: apps/v1
    kind: Deployment
    name: my-service
  maxReplicas: 3
  minReplicas: 1
  metrics:
  - type: Pods
    pods:
      metricName: http_server_requests_seconds_count
      targetAverageValue: &quot;5&quot;
</code></pre>
<p>May I ask why please?</p>
<p>One of my first thought is, I am not even sure Kubernetes knows about the whereabouts of our Prometheus server in location X.</p>
<p>I am having trouble understanding how both work together.</p>
<p>How to achieve HPA from Kubernetes based on SpringBoot metrics (request count) available in Prometheus in a location X please?</p>
<p>Thank you</p>

PatPanda
<p>Custom metrics in Kubernetes requires a further integration in order to make it work.</p>
<p>In general, if you use custom metrics with prometheus, you can connect the prometheus server to the actual custom metrics in Kubernetes with prometheus adaptor here, <a href="https://github.com/DirectXMan12/k8s-prometheus-adapter" rel="nofollow noreferrer">https://github.com/DirectXMan12/k8s-prometheus-adapter</a>.</p>
<p>You can install it through helm and connect it to your prometheus server. Once you have successfully set it up, you can get the custom metrics from the following command, depending on your Kubernetes version.</p>
<pre><code>kubectl get --raw &quot;/apis/custom.metrics.k8s.io/v1beta1&quot;
</code></pre>
<p>Eventually, when you describe the HPA with kubectl, you will see the metrics shown up in the HPA object.</p>
