Using Traefik to expose your applications
Traefik is the ingress controller included by default in K3s. It uses the same configurations as NGINX as shown in the previous example in the myapp-ingress.yaml
file. Let’s assume that you already have created the myapp
Deployment from the previous section. So, let’s get started with Traefik by following the given steps:
- To find the load balancer IP address created by Traefik, run the following command:
$ IP_LOADBALANCER=$(kubectl get svc traefik --output jsonpath='{.status.loadBalancer.ingress[0].ip}' -n kube-system)
Run the following command to see the current IP address assigned to the load balancer that the Traefik installation provisioned. This will be used to create an entry in the /etc/hosts
file:
$ echo $IP_LOADBALANCER
Let’s say that returns 192.168.0.240
. You have to add the next line to the /etc/hosts
file:
192.168.0.240 myapp-test-traefik.test
Now you are ready to create...