Autoscaling Microservices in Kubernetes: Horizontal Autoscaling
49%
Horizontal Scaling
Horizontal scaling, also known as scaling out, involves adding more instances of a service to handle increased load. In Kubernetes, this is typically achieved by increasing the number of Pods running a particular application. Let's see this in practice.
Let's recreate our stateless Flask API if it's not already running:
kubectl apply -f - <
# Namespace
apiVersion: v1
kind: Namespace
metadata:
name: stateless-flask
---
# Deployment
apiVersion: apps/v1
kind: Deployment
metadata:
name: stateless-flask
namespace: stateless-flask
spec:
replicas: 1
selector:
matchLabels:
app: stateless-flask
template:
metadata:
labels:
app: stateless-flask
spec:
containers:
- name: stateless-flask
image: eon01/stateless-flask:v0
imagePullPolicy: Never
ports:
- containerPort: 5000
---
# ClusterIP Service
apiVersion: v1
kind: Service
metadata:
name: stateless-flask
namespace: Cloud-Native Microservices With Kubernetes - 2nd Edition
A Comprehensive Guide to Building, Scaling, Deploying, Observing, and Managing Highly-Available Microservices in KubernetesEnroll now to unlock all content and receive all future updates for free.
