Add annotations to primary HPA
Hi, I am using kube-metrics-adapter to pull metrics from Prometheus for scaling HPAs.
For this purpose, I have added the query information in the HPA's annotation. The annotations are showing up in canary HPA but not in primary HPA. What should I do to propagate annotations to the primary HPA?
Flagger version: v1.18.0
Canary HPA
Name: foo-autoscaler
Namespace: dev
Labels: app.kubernetes.io/managed-by=Helm
Annotations: meta.helm.sh/release-name: foo-bmy3hvz
meta.helm.sh/release-namespace: dev
metric-config.object.istio-requests-total.prometheus/per-replica: true
metric-config.object.istio-requests-total.prometheus/query:
sum(
rate(
istio_requests_total{
destination_workload="foo",
destination_workload_namespace="dev"
}[2m]
)
)
CreationTimestamp: Wed, 09 Jun 2021 16:08:49 +0000
Reference: Deployment/foo
Metrics: ( current / target )
"istio-requests-total" on Pod/foo (target value): <unknown> / 10
Min replicas: 5
Max replicas: 10
Deployment pods: 0 current / 0 desired
Primary HPA
Name: foo-autoscaler-primary
Namespace: dev
Labels: app.kubernetes.io/managed-by=Helm
Annotations: <none>
CreationTimestamp: Wed, 16 Feb 2022 02:18:38 +0000
Reference: Deployment/foo-primary
Metrics: ( current / target )
"istio-requests-total" on Pod/foo (target value): 0 / 10
Min replicas: 5
Max replicas: 10
Deployment pods: 5 current / 5 desired
The destination workload is different for the primary so copying the annotation would do no good. You have to remove the hpa ref from the canary and create them on your own. The primary HPA should target the appname-primary workload.
Thank you Stefan for your suggestion. I was able to detach the HPA from the canary and have it working.
Is there a reason for annotations to be not propagated to primary hpa? Or can that be integrated by the model similar to service? https://github.com/fluxcd/flagger/blob/main/docs/gitbook/faq.md#can-i-use-annotations
Is there a reason for annotations to be not propagated to primary hpa?
Yes, copying the annotation is not going to do any good, the primary HPA must have destination_workload="foo-primary" while the canary must have destination_workload="foo".
Yes, that part I understood. By propagating here, I meant having the required annotation values changed. For example appname to appname-primary.
A feature like this:
autoscalerRef:
apiVersion: autoscaling/v2beta1
kind: HorizontalPodAutoscaler
name: foo
primary:
annotations:
metric-config.object.istio-requests-total.prometheus/query: <query specific to primary>
canary:
annotations:
metric-config.object.istio-requests-total.prometheus/query: <query specific to canary>
Edit:
So to be little more generic like this:
primary:
annotations:
foo: bar
canary:
annotations:
foo1: bar1
Can we use a annotation to specify which annotations or labels need to be propagated without appending suffix -primary ?For example:
annotations:
flagger.io/annotations-propagation: <KEY1>,<KEY2>
flagger.io/labels-propagation: <KEY1>,<KEY2>