- Create the cluster:
k3d cluster create -p "8081:80@loadbalancer" --servers 3
- Deploy a web application
kubectl create deployment nginx --image=nginx --replicas=3
- Expose the application as a service of type ClusterIP
kubectl expose deployment/nginx --port 80 --name nginx
- Create an ingress object for the service:
kubectl apply -f - <<EOF
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: nginx-ingress
spec:
rules:
- http:
paths:
- pathType: Prefix
path: "/"
backend:
service:
name: nginx
port:
number: 80
EOF