I have:
- deployments of services A and B in k8s
- Prometheus stack
I wanna scale service A when metric m1 of service B is changed. Solutions which I found and not suitable more or less:
- I can define HPA for service A with the following part of spec:
- type: Object
object:
metric:
name: m1
describedObject:
apiVersion: api/v1
kind: Pod
name: certain-pod-of-service-B
current:
value: 10k
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)
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
The same for external metrics
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?
external metrics
? It seems to be a correct approach see: Kubernetes HPA using metrics from another deployment. – matt_j