Layer 4 and Layer 7 LB
I'm trying to understand the differences of
Layer 4 and Layer 7 Load Balancing.
I want to understand
when to use which approach
Explain in detail by simple example
Service and ingress
- K8s service deals at L4 and ingress deals at L7
- K8s ingress comes with
- ingress => Rules
- ingressController => Implements the rules
- In k8s there is no default ingress controller.
- popular ingress controllers
Give me the list of popular ingress controllers and also how to deploy them into kubernetes,
Also give me cloud provider specific ingress controllers supported for AWS, Azure and GCP
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx
spec:
replicas: 1
selector:
matchLabels:
app: nginx
template:
metadata:
labels:
app: nginx
spec:
containers:
- name: nginx
image: nginx:latest
ports:
- containerPort: 80
---
apiVersion: v1
kind: Service
metadata:
name: nginx-service
spec:
selector:
app: nginx
ports:
- port: 80
targetPort: 80
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: httpd
spec:
replicas: 1
selector:
matchLabels:
app: httpd
template:
metadata:
labels:
app: httpd
spec:
containers:
- name: httpd
image: httpd:2.4
ports:
- containerPort: 80
---
apiVersion: v1
kind: Service
metadata:
name: httpd-service
spec:
selector:
app: httpd
ports:
- port: 80
targetPort: 80
-
in killercoda lets install nginx ingress
kubectl apply -f \
https://raw.githubusercontent.com/kubernetes/ingress-nginx/main/deploy/static/provider/cloud/deploy.yaml
-
Prompt
Give me examples of ingress rules
- simple path based routing no redirection
- simple path based routing with redirection
- header based routing
- other possibilities
one by one with manifests and explanations
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: my-ingress
annotations:
nginx.ingress.kubernetes.io/use-regex: "true"
nginx.ingress.kubernetes.io/rewrite-target: /$2
spec:
ingressClassName: nginx
rules:
- http:
paths:
- path: /nginx(/|$)(.*)
pathType: ImplementationSpecific
backend:
service:
name: nginx-service
port:
number: 80
- path: /httpd(/|$)(.*)
pathType: ImplementationSpecific
backend:
service:
name: httpd-service
port:
number: 80
Purpose of CNI and Kube-proxy
Facts
- Every pod gets an ip address
- A service which is a virtual ip address when accessed is forwarding the request to pod
How?
- who is giving ip to Pod
- how does a Container running in a Pod communicate with
- Container running in a Same Pod
- Pod running in the same node
- Pod running in the different node
Basics