Rancher Desktop, K3s and Traefik as ingress controller
Rancher Desktop
Select context, create namespace and deploy nginx
and service
➜ kubectl config use-context rancher-desktop
➜ kubectl get node -o wide
### Namespaces
➜ kubectl create namespace my-namespace
### Deployments
➜ kubectl create deployment nginx --image=nginx:latest --port=80 --namespace my-namespace
### Services
➜ kubectl expose deployment nginx --port=80 -n my-namespace
Traefik as the default ingress controller
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
annotations:
traefik.ingress.kubernetes.io/router.entrypoints: web
name: nginx-ingress
namespace: my-namespace
spec:
rules:
- host: hp450-2.lan
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: nginx
port:
number: 80
Create ingress
➜ kubectl apply -n my-namespace -f .\nginx-ingess.yaml
Port Forwarding
Other option use kubectl port-forward
➜ kubectl get pod -n my-namespace -o wide
# kubectl describe pod nginx-6b7f675859-p7csp -n my-namespace
➜ kubectl port-forward -n my-namespace nginx-6b7f675859-p7csp 80:80
Delete namespace
➜ kubectl delete namespace my-namespace