Setting up traefik as Ingress controller for Kubernetes
Posted on April 4, 2017 • 2 minutes • 239 words
Just my own experience setting up traefik as Ingress controller on Kubernetes.
Install helm
brew install kubernetes-helm
Init helm
helm init
Install traefik chart with helm
Download the default values.yaml
file and edit it depends on your needs. Then issue the below command.
I want to install it to kube-system
namespace hence the --namespace kube-system
.
helm install --name my-traefik --namespace kube-system --values values.yaml stable/traefik
If you make a mistake and want to remove it
helm delete --purge my-traefik
--purge
if you want to reuse the name previously. Otherwise, helm will complain release xxx already exists
.
Update your app
You will have to create an Ingress, a service and a deployment.
-
Ingress is a rule to help you setup routing traffic from a domain to your cluster service name
-
Service will expose your pods to be accessible in the cluster by selector (see example)
-
Deployment is well .. your app deployment.
It will be a whole lot easier if you see this cheese.yaml file
Download the file and kubectl create -f traefik.yaml
to deploy it to your cluster.
In the example above, i will use the domain stilton.example.com
Update DNS
Create a CNAME record of stilton.example.com
to point to your traefik’s ELB public address.
Profit!
If you have traefik dashboard enabled, you should see new ingress and the pods it distributes load to on the web.
PS: You don’t necessarily use helm
. It just make installing stuff a lot easier.