Skip to content

Downsides of services

Course: Kubernetes Part 2 - chapter 6

Services are great, but they have some downsides -

  1. If you have three apps (frontend, backend, websocket server), you will have to create 3 saparate services to route traffic to them. There is no way to do centralized traffic management (routing traffic from the same URL/Path-Based Routing)
  2. There are also limits to how many load balancers you can create

You can create certificates for your load balancers but you have to maintain them outside the cluster and create them manually

You also have to update them if they ever expire

No centralized logic to handle rate limitting to all services

Section titled “No centralized logic to handle rate limitting to all services”

Each load balancer can have its own set of rate limits, but you cant create a single rate limitter for all your services.

Here is a sample manifest that you can run to start two saparate deployments and attach them to two saparate LoadBalancer services

Manifest
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx-deployment
spec:
replicas: 2
selector:
matchLabels:
app: nginx
template:
metadata:
labels:
app: nginx
spec:
containers:
- name: nginx
image: nginx:alpine
ports:
- containerPort: 80
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: apache-deployment
spec:
replicas: 2
selector:
matchLabels:
app: apache
template:
metadata:
labels:
app: apache
spec:
containers:
- name: my-apache-site
image: httpd:2.4
ports:
- containerPort: 80
---
apiVersion: v1
kind: Service
metadata:
name: nginx-service
spec:
selector:
app: nginx
ports:
- protocol: TCP
port: 80
targetPort: 80
type: LoadBalancer
---
apiVersion: v1
kind: Service
metadata:
name: apache-service
spec:
selector:
app: apache
ports:
- protocol: TCP
port: 80
targetPort: 80
type: LoadBalancer
kubectl apply -f manifest.yml

You will notice two load balancers created for your two services

Open the load balancers