Wondering how to use vertical pod autoscaler kubernetes? Our in-house experts are here to help you out with this article. Our digitalocean support is here to offer a lending hand with your queries and issues.
Vertical pod autoscaler kubernetes
You can use the Kubernetes Vertical Pod Autoscaler to automatically adjust the resource requests and limits for containers running in a deployment’s pods. The Vertical Pod Autoscaler can improve cluster resource utilization by:
- Setting the requests automatically based on usage to make sure the appropriate resource amount is available for each pod.
- Maintaining ratios between limits and requests that were specified in containers’ initial configurations.
- Scaling down pods that are over-requesting resources, based on their usage over time.
- Scaling up pods that are under-requesting resources, based on their usage over time.
The Vertical Pod Autoscaler has three components:
- Recommender: Monitors the current and past resource consumption and provides recommended CPU and memory request values for a container.
- Updater: Checks for pods with incorrect resources and deletes them, so that the pods can be recreated with the updated request values.
- Admission Plugin: Sets the correct resource requests on new pods (that is, pods just created or recreated by their controller due to changes made by the Updater).
You configure the Vertical Pod Autoscaler using the
VerticalPodAutoscaler
Copy Code
custom resource definition object. The VerticalPodAutoscaler
Copy Code
object enables you to specify the pods to vertically autoscale, and which resource recommendations to apply (if any).
The Vertical Pod Autoscaler requires the installation of a metrics source, such as the Kubernetes Metrics Server, in the cluster.
Today, let us see the steps followed by our support techs to deploy vertical pod
Working with the Vertical Pod Autoscaler
Step 1: Verify the Kubernetes Metrics Server Installation
- If you haven’t already done so, follow the steps to set up the cluster’s kubeconfig configuration file and (if necessary) set the KUBECONFIG environment variable to point to the file. Note that you must set up your own kubeconfig file. You cannot access a cluster using a kubeconfig file that a different user set up.
- Confirm that the Kubernetes Metrics Server has been deployed successfully on the cluster and is available by entering: Command
If the command returns a `Not Found` error, then you must deploy the Kubernetes Metrics Server on the cluster before proceeding.kubectl -n kube-system get deployment/metrics-server
Copy Code
Step2: Download and Deploy the Vertical Pod Autoscaler
- Download the Vertical Pod Autoscaler source code from GitHub. For example, by entering:Command
git clone -b vpa-release-0.8 https://github.com/kubernetes/autoscaler.git
Copy Code
Change to the
vertical-pod-autoscaler
Copy Code
directory:
cd autoscaler/vertical-pod-autoscaler
Copy Code
If you have previously deployed the Vertical Pod Autoscaler, delete it by entering:
./hack/vpa-down.sh
Copy Code
Deploy the Vertical Pod Autoscaler by entering:
./hack/vpa-up.sh
Copy Code
Verify that the Vertical Pod Autoscaler pods have been created successfully by entering:
The output from the above command shows the pods:kubectl get pods -n kube-system
Copy Code
Note that you will probably see different names and numbers.vpa-admission-controller-59d9965cfb-bzs8l 1/1 Running 0 6m34s vpa-recommender-5bcb58569-mqdds 1/1 Running 0 6m43s vpa-updater-5979cbf757-scw2d 1/1 Running 0 6m46s
Copy Code
Step3: Deploy the Sample Application
- Deploy the sample hamster application to create a deployment and a corresponding Vertical Pod Autoscaler by entering:Command
kubectl apply -f examples/hamster.yaml
Copy Code
The output from the above command confirms the deployment and creation:
verticalpodautoscaler.autoscaling.k8s.io/hamster-vpa created deployment.apps/hamster created
Copy Code
Deploying the hamster application creates a deployment with two pods and a Vertical Pod Autoscaler pointing at the deployment. Verify that the hamster pods have been created successfully by entering:
kubectl get pods -l app=hamster
Copy Code
The output from the above command confirms the creation:
NAME READY STATUS RESTARTS AGE
hamster-7cbfd64f57-mqqnk 1/1 Running 0 54s
hamster-7cbfd64f57-rq6wv 1/1 Running 0 55s
Copy Code
Note that you will probably see different names for the hamster pods. View the CPU and memory reservations using the
kubectl describe pod
Copy Code
command and one of the hamster pod names returned in the previous step.
Step4: View the Scaling Operation
Having analyzed the original pods in the sample hamster application and determined that the CPU and memory reservations are inadequate, the Vertical Pod Autoscaler (specifically the Updater) relaunches the pods with different values as proposed by the Recommender. Note that the Vertical Pod Autoscaler does not modify the template in the deployment, but updates the actual requests of the pods.
- Monitor the pods in the sample hamster application, and wait for the Updater to start a new hamster pod with a new name, by entering:
kubectl get --watch pods -l app=hamster
Copy Code
When you see that a new hamster pod has started, view its CPU and memory reservations using the
kubectl describe pod
Copy Code
command and the pod’s name.
Step5: View the Recommendation
View the recommendations made by the Vertical Pod Autoscaler (specifically, by the Recommender) by entering:
kubectl describe vpa/hamster-vpa
Copy Code
Step6: Clean Up
- Remove the sample application by entering:
kubectl delete -f examples/hamster.yaml
Copy Code
In the
vertical-pod-autoscaler
Copy Code
directory, delete the Vertical Pod Autoscaler deployment by entering:
./hack/vpa-down.sh
Copy Code
[Looking for a solution to another query? We’re happy to help.]
Conclusion
In this article, we provide a quick and simple solution from our Support team to deploy vertical pod autoscaler kubernetes
PREVENT YOUR SERVER FROM CRASHING!
Never again lose customers to poor server speed! Let us help you.
Our server experts will monitor & maintain your server 24/7 so that it remains lightning fast and secure.
0 Comments