Skip to content

Instantly share code, notes, and snippets.

@gauravgola96
Last active April 7, 2021 05:26
Show Gist options
  • Save gauravgola96/dadd75d73d552b4722397ecbcf97adca to your computer and use it in GitHub Desktop.
Save gauravgola96/dadd75d73d552b4722397ecbcf97adca to your computer and use it in GitHub Desktop.
Horizontal Pod Scaling with custom metrics
apiVersion: autoscaling/v2beta1
kind: HorizontalPodAutoscaler
metadata:
name: podname
namespace: namespace
annotations:
metric-config.external.processed-events-per-second.prometheus/prometheus-server: http://prometheus.istio-system.svc
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="podname",
destination_workload_namespace="namespace",
reporter="destination"
}[1m]
)
) / count(container_memory_usage_bytes{namespace="namespace", container=~"podname.*"})
spec:
maxReplicas: 50
minReplicas: 1
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: podname
metrics:
- type: Object
object:
metricName: istio-requests-total
target:
apiVersion: v1
kind: Pod
name: podname
targetValue: 30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment