Skip to content

Instantly share code, notes, and snippets.

@thxCode
Last active November 20, 2019 07:33
Show Gist options
  • Save thxCode/da84d0b2b5845d70e986c48aa81d4e72 to your computer and use it in GitHub Desktop.
Save thxCode/da84d0b2b5845d70e986c48aa81d4e72 to your computer and use it in GitHub Desktop.
Prometheus relatived
kind: ServiceMonitor
apiVersion: monitoring.coreos.com/v1
metadata:
name: hpa-app
namespace: kube-public
labels:
app: hpa-app
spec:
namespaceSelector:
matchNames:
- kube-public
selector:
matchLabels:
app: hpa-app
endpoints:
- port: http
apiVersion: apps/v1
kind: Deployment
metadata:
name: hpa-app
namespace: kube-public
labels:
app: hpa-app
spec:
replicas: 1
selector:
matchLabels:
app: hpa-app
template:
metadata:
labels:
app: hpa-app
spec:
containers:
- image: luxas/autoscale-demo:v0.1.2
name: metrics-provider
ports:
- name: http
containerPort: 8080
---
apiVersion: v1
kind: Service
metadata:
name: hpa-app
namespace: kube-public
labels:
app: hpa-app
spec:
selector:
app: hpa-app
ports:
- protocol: TCP
port: 80
targetPort: 8080
name: http
kind: HorizontalPodAutoscaler
apiVersion: autoscaling/v2beta1
metadata:
name: hpa-app
namespace: kube-public
spec:
scaleTargetRef:
# point the HPA at the sample application
# you created above
apiVersion: apps/v1
kind: Deployment
name: hpa-app
# autoscale between 1 and 10 replicas
minReplicas: 1
maxReplicas: 10
metrics:
# use a "Pods" metric, which takes the average of the
# given metric across all pods controlled by the autoscaling target
- type: Pods
pods:
# use the metric that you used above: pods/http_requests
metricName: http_requests
# target 500 milli-requests per second,
# which is 1 request every two seconds
targetAverageValue: 500m
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment