Kubernetes Vertical Pod Autoscaler (VPA): Vertically Autoscale Your Application Workloads using Kubernetes

 


Kubernetes Vertical Pod Autoscaler (VPA) Setup

1. At first install the kubernetes vertical pod autoscaler on  kubernetes

git clone https://github.com/kubernetes/autoscaler.git
cd autoscaler/vertical-pod-autoscaler
./hack/vpa-up.sh

2. Then create the deployment.yaml file

apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx
labels:
app: nginx
spec:
selector:
matchLabels:
app: nginx
replicas: 1
template:
metadata:
labels:
app: nginx
spec:
containers:
- name: nginx
image: nginx # or just image: nginx
resources:
limits:
cpu: 10m
memory: 10Mi
requests:
cpu: 5m
memory: 5Mi
ports:
- containerPort: 80

2. Next, create the service.yaml. Here, i am using Nodeport

apiVersion: v1
kind: Service
metadata:
labels:
app: nginx
name: nginx-service
namespace: default
spec:
ports:
- name: nginx-port
port: 80
selector:
app: nginx
sessionAffinity: None
type: NodePort

3. Finally, create the vpa-autoscaler.yaml

apiVersion: autoscaling.k8s.io/v1beta2
kind: VerticalPodAutoscaler
metadata:
name: nginx-vpa
spec:
targetRef:
apiVersion: "apps/v1"
kind: Deployment
name: nginx

4. Then, apply all

kubectl apply -f .

 After that, check the nodeport

 kubectl get svc

5. Finally test the autoscaler using hey command. Check the master node ip or if you are using  minikube then type minikube ip to get the ip

 hey -n 10000 -c 5 http://192.168.59.100:31205

6. Check the vpa 

kubectl get vpa

kubectl describe vpa nginx-vpa

Video Tutorial




Download Coding Interview Book and Get More Tutorials for Coding and Interview Solution: Click Here

Download System Design Interview Book and Get More Tutorials and Interview Solution: Click Here

Do you need more Guidance or Help? Then Book 1:1 Quick Call with Me: Click Here

Share on Google Plus

About Ashadullah Shawon

I am Ashadullah Shawon. I am a Software Engineer. I studied Computer Science and Engineering (CSE) at RUET. I Like To Share Knowledge. Learn More: Click Here
    Blogger Comment
    Facebook Comment

0 comments:

Post a Comment