Learn how autoscaling works in OVH Kubernetes clusters. Our OVH Support team is just a click away.
How Autoscaling Works in OVH Kubernetes Clusters
Did you know that autoscaling is one of Kubernetes’ most powerful advantages?
It helps us balance performance and cost-efficiency by ensuring our applications use only the required cloud resources.
This blog will explain Kubernetes autoscaling, how it helps reduce costs, and how to configure it when using a cloud provider like OVH.
An Overview:
What Is Kubernetes Autoscaling?
Kubernetes autoscaling automatically adjusts the resources based on real-time demand. When the application requires more CPU or RAM, the cluster scales up, and when demand drops, it scales down. This dynamic approach means we use only what’s needed. In other words, it saves us from overprovisioning and overspending.
If you’re coming from managing virtual machines manually (such as with KVM or Virtualizor), you’ll appreciate how Kubernetes automates these operations. This guide on setting up a KVM bridge with Virtualizor offers a solid comparison point for traditional VM management versus Kubernetes orchestration.
Suppose we are running a 24/7 service with traffic that spikes during the U.S. daytime and dips at night. Using tools like Cluster Autoscaler and Horizontal Pod Autoscaler (HPA), Kubernetes dynamically adjusts resources based on load, ensuring end-users always experience optimal performance. This prevents us from burning through the budget.
Why Autoscaling Matters: The Cost-Saving Advantage
Without autoscaling, DevOps teams must manually assign resources. This is an error-prone and inefficient process. It results in:
- Paying for unused resources just in case traffic spikes.
- Facing crashes and performance issues during unexpected demand surges.
- Losing customers due to downtime or degraded performance.
Kubernetes autoscaling removes these issues and automates the process, ensuring cost-efficiency and high availability.
Manually scaling can also lead to operational challenges, especially during migrations. Here’s a deeper look at how Virtualizor users face errors during migration or cloning tasks, something Kubernetes autoscaling can help mitigate by avoiding capacity bottlenecks.
Autoscaling Methods in Kubernetes
Kubernetes supports autoscaling at both the application layer and the infrastructure layer:
- Horizontal Pod Autoscaler (HPA)
Increases or decreases the number of pod replicas based on CPU usage or custom metrics.
- Vertical Pod Autoscaler (VPA)
Adjusts CPU and memory requests for individual pods.
- Cluster Autoscaler
Automatically adds or removes nodes from your cluster depending on scheduling needs.
Configuring Autoscaling with `kubectl`
With the Kubernetes API (via `kubectl`), we can enable and fine-tune autoscaling for our cluster.
- List Node Pools:
kubectl get nodepools
- Patch a Node Pool:
kubectl patch nodepool our_nodepool_name --type="merge" --patch='{
"spec": {
"autoscaling": {
"scaleDownUnneededTimeSeconds": 900,
"scaleDownUnreadyTimeSeconds": 1500,
"scaleDownUtilizationThreshold": "0.7"
}
}
}'
- Check Configuration:
kubectl get nodepool our_nodepool_name -o json | jq .spec
The editable fields include autoscale, autoscaling, desiredNodes, minNodes, and maxNodes.
Example: Using Autoscaler with OVH Cloud
Let’s walk through setting up Kubernetes autoscaling on OVH Public Cloud.
- First, we have to create a cluster with Autoscaling. Go to OVH > Public Cloud > Managed Kubernetes Services and create a cluster. In step 5, enable Autoscaling before completing the setup.
- Then, download the kubeconfig file from OVH and export it:
export KUBECONFIG=./kubeconfig.yml
- Next, verify Node pool status.
kubectl get nodepool
We will see autoscaling enabled with defined minimum and maximum node values.
- Now, create a `mongo` deployment and service:
# mongo-service.yaml
apiVersion: v1
kind: Service
metadata:
name: mongo
spec:
selector:
app: mongo
ports:
- protocol: TCP
port: 27017
# mongo-deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: mongo
spec:
replicas: 1
selector:
matchLabels:
app: mongo
template:
metadata:
labels:
app: mongo
spec:
containers:
- name: mongodb
image: mongo:5.0.6
ports:
- containerPort: 27017
- Then, apply with:
kubectl create -f mongo-service.yaml
kubectl create -f mongo-deployment.yaml
We may have to update the `image` field for version changes.
- If we are using NGINX as the ingress controller, install it first. Then, create the ingress resource:
kubectl create -f ams-k8s-ingress.yaml
For environments still using bare-metal or manually configured hypervisors, you might also be interested in how to enable KVM on Ubuntu 22.04.Afterward, configure your DNS to access the app dashboard using the following command.
kubectl get ingress
Alternatively, if you’re exploring setting up Virtualizor environments for container or VM hosting, this guide on installing Virtualizor on AlmaLinux with command-line steps might also be helpful.
[Need assistance with a different issue? Our team is available 24/7.]
Conclusion
Kubernetes autoscaling is a must-have feature for any cloud-native application. It ensures that the apps always have the resources they need. Whether running mission-critical apps or handling variable loads, autoscaling delivers performance and savings.
In brief, our Support Experts demonstrated how autoscaling works in OVH Kubernetes clusters.
0 Comments