Skip to content

Instantly share code, notes, and snippets.

@mlafeldt
Created April 12, 2019 14:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mlafeldt/9e7f7363610f5026a6a754ecde6f6616 to your computer and use it in GitHub Desktop.
Save mlafeldt/9e7f7363610f5026a6a754ecde6f6616 to your computer and use it in GitHub Desktop.
HPA based on CPU
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx
namespace: ae-ops-testing
labels:
app: nginx
spec:
# replicas: 1
selector:
matchLabels:
app: nginx
template:
metadata:
labels:
app: nginx
spec:
containers:
- name: nginx
image: nginx:1.7.9
ports:
- containerPort: 80
resources:
requests:
memory: "64Mi"
cpu: "250m"
limits:
memory: "128Mi"
cpu: "500m"
---
apiVersion: v1
kind: Service
metadata:
name: nginx
namespace: ae-ops-testing
labels:
app: nginx
spec:
ports:
- port: 80
protocol: TCP
selector:
app: nginx
---
kind: ServiceMonitor
apiVersion: monitoring.coreos.com/v1
metadata:
name: nginx
namespace: ae-ops-testing
labels:
prometheus: kube-prometheus
spec:
selector:
matchLabels:
app: nginx
endpoints:
- port: http
namespaceSelector:
matchNames:
- ae-ops-testing
---
kind: HorizontalPodAutoscaler
apiVersion: autoscaling/v2beta1
metadata:
name: nginx
namespace: ae-ops-testing
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: nginx
minReplicas: 1
maxReplicas: 10
metrics:
- type: Pods
pods:
metricName: cpu_usage
targetAverageValue: 10m
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment