Skip to main content

Expose Nginx Load Balancer MetalLB with K3s

Expose Nginx Load Balancer MetalLB with K3s

kubectl create deploy nginx --image nginx:latest
kubectl expose deploy nginx --port 3000 --target-port 80 --type LoadBalancer

or


apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx
spec:
replicas: 2
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
spec:
type: LoadBalancer
selector:
app: nginx
ports:
- port: 3000
targetPort: 80