Horizontal Pod Autoscaler(HPA) on AWS EKS/Kubernetes

ismail yenigül
Mar 7 · 3 min read

Install metrics-server

$ kubectl get apiservice v1beta1.metrics.k8s.io -o yaml
apiVersion: apiregistration.k8s.io/v1
kind: APIService
metadata:
creationTimestamp: 2019-03-04T08:58:24Z
name: v1beta1.metrics.k8s.io
resourceVersion: "1532302"
selfLink: /apis/apiregistration.k8s.io/v1/apiservices/v1beta1.metrics.k8s.io
uid: ab0ee196-3e5b-11e9-ae35-066a83e33f00
spec:
group: metrics.k8s.io
groupPriorityMinimum: 100
insecureSkipTLSVerify: true
service:
name: metrics-server
namespace: kube-system
version: v1beta1
versionPriority: 100
status:
conditions:
- lastTransitionTime: 2019-03-06T11:32:37Z
message: all checks passed
reason: Passed
status: "True"
type: Available

Configure Deployment resources

spec:
containers:
- name: mynginxdeploy
image: nginx
resources:
requests:
cpu: 200m

Deploy a HorizontalPodAutoscaler

$ cat autoscale.yaml
apiVersion: autoscaling/v2beta1
kind: HorizontalPodAutoscaler
metadata:
name: myappautoscale
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: mynginxdeploy
minReplicas: 1
maxReplicas: 4
metrics:
- type: Resource
resource:
name: cpu
targetAverageUtilization: 60

If this post was helpful, please click the clap 👏 button below a few times to show your support for the author! ⬇

Faun

The Must-Read Publication for Aspiring Developers & DevOps Enthusiasts

ismail yenigül

Written by

Linux and Cloud

Faun

Faun

The Must-Read Publication for Aspiring Developers & DevOps Enthusiasts