2017-11-27 19:33:18 +08:00
|
|
|
apiVersion: apps/v1beta1
|
|
|
|
kind: Deployment
|
|
|
|
metadata:
|
|
|
|
labels:
|
|
|
|
app: sample-metrics-app
|
|
|
|
name: sample-metrics-app
|
|
|
|
spec:
|
|
|
|
replicas: 2
|
|
|
|
template:
|
|
|
|
metadata:
|
|
|
|
labels:
|
|
|
|
app: sample-metrics-app
|
|
|
|
spec:
|
|
|
|
containers:
|
2018-05-04 19:48:54 +08:00
|
|
|
- image: harbor-001.jimmysong.io/library/autoscale-demo:v0.1.2
|
2017-11-27 19:33:18 +08:00
|
|
|
name: sample-metrics-app
|
|
|
|
ports:
|
|
|
|
- name: web
|
|
|
|
containerPort: 8080
|
|
|
|
readinessProbe:
|
|
|
|
httpGet:
|
|
|
|
path: /
|
|
|
|
port: 8080
|
|
|
|
initialDelaySeconds: 3
|
|
|
|
periodSeconds: 5
|
|
|
|
livenessProbe:
|
|
|
|
httpGet:
|
|
|
|
path: /
|
|
|
|
port: 8080
|
|
|
|
initialDelaySeconds: 3
|
|
|
|
periodSeconds: 5
|
|
|
|
---
|
|
|
|
apiVersion: v1
|
|
|
|
kind: Service
|
|
|
|
metadata:
|
|
|
|
name: sample-metrics-app
|
|
|
|
labels:
|
|
|
|
app: sample-metrics-app
|
|
|
|
spec:
|
|
|
|
ports:
|
|
|
|
- name: web
|
|
|
|
port: 80
|
|
|
|
targetPort: 8080
|
|
|
|
selector:
|
|
|
|
app: sample-metrics-app
|
|
|
|
---
|
2017-12-13 23:01:57 +08:00
|
|
|
apiVersion: monitoring.coreos.com/v1
|
2017-11-27 19:33:18 +08:00
|
|
|
kind: ServiceMonitor
|
|
|
|
metadata:
|
|
|
|
name: sample-metrics-app
|
|
|
|
labels:
|
|
|
|
service-monitor: function
|
|
|
|
spec:
|
|
|
|
selector:
|
|
|
|
matchLabels:
|
|
|
|
app: sample-metrics-app
|
|
|
|
endpoints:
|
|
|
|
- port: web
|
|
|
|
---
|
|
|
|
kind: HorizontalPodAutoscaler
|
2017-12-13 23:01:57 +08:00
|
|
|
apiVersion: autoscaling/v2beta1
|
2017-11-27 19:33:18 +08:00
|
|
|
metadata:
|
|
|
|
name: sample-metrics-app-hpa
|
|
|
|
spec:
|
|
|
|
scaleTargetRef:
|
|
|
|
kind: Deployment
|
|
|
|
name: sample-metrics-app
|
|
|
|
minReplicas: 2
|
|
|
|
maxReplicas: 10
|
|
|
|
metrics:
|
|
|
|
- type: Object
|
|
|
|
object:
|
|
|
|
target:
|
|
|
|
kind: Service
|
|
|
|
name: sample-metrics-app
|
|
|
|
metricName: http_requests
|
|
|
|
targetValue: 100
|