I have configured traefik as my ingress controller for my k8s cluster on Digital Ocean. I am using terraform + helm to set up the entire cluster + traefik ingress controller + cert-manager. Everything is working as expected.
However, now I want to use an existing DO load balancer for my traefik ingress controller instead of the LB that automatically gets created by Digital Ocean when creating the LoadBalancer type k8s service for the traefik ingress controller.
In the traefik helm chart I’ve set the service.type to NodePort and the node ports to 30080 and 30443.
When I point my Digital Ocean load balancer to the nodes on ports 30080 and 30443, I get a 404 error from traefik. So, it does reach the traefik ingress controller but it does not seem to be able to route the request to the correct service.
My Ingress resource looks like this:
resource "kubernetes_ingress_v1" "whoami" {
metadata {
name = "whoami"
annotations = {
"traefik.ingress.kubernetes.io/router.entrypoints" : "websecure"
"traefik.ingress.kubernetes.io/router.tls" : "true"
"cert-manager.io/cluster-issuer" : "letsencrypt-issuer"
}
}
spec {
rule {
host = "my-domain.com"
http {
path {
path = "/foo"
path_type = "Prefix"
backend {
service {
name = "whoami"
port {
number = 80
}
}
}
}
}
}
tls {
secret_name = "my-domain.com-tls"
hosts = [
"my-domain.com"
]
}
}
}
If I use the LoadBalancer type service for traefik, everything works as expected through the automatically provisioned LB and I can access the whoami service via https://my-domain.com/foo. Does anyone know what I am doing wrong or what I am missing?
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.
Enter your email to get $200 in credit for your first 60 days with DigitalOcean.
New accounts only. By submitting your email you agree to our Privacy Policy.
Hi there,
I could suggest following the steps from this documentation here:
https://docs.digitalocean.com/tutorials/internal-lb/
In that tutorial, you learn how to use a NodePort service and ExternalDNS to make services on a DOKS cluster accessible for applications on Droplets, which will also work for existing Load Balancer within that VPC.
Though, it is more straightforward to create a service with type LoadBalancer and use the newly created Load Balancer.
Hope that this helps.
Best,
Bobby