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?
Update:
When I start the ingress controller with log-level:info I see the following logs in the traefik pod:
11T17:31:21Z" level=warning msg="No domain found in rule PathPrefix(`/`), the TLS options applied for this router will depend on the SNI of each request" entryPointName=websecure routerName=whoami-whoami@kubernetes
Update:
When I inspect the access logs for a successful request with service kind LoadBalancer:
10.110.0.3 - - [12/Feb/2023:06:23:33 +0000] "GET / HTTP/2.0" 200 1005 "-" "-" 30 "whoami-whoami-limosa-online@kubernetes" "http://10.244.0.107:80" 1ms
For the version with service type NodePort and using an existing LB from Digital Ocean:
10.110.0.10 - - [12/Feb/2023:06:23:59 +0000] "GET / HTTP/2.0" - - "-" "-" 39 "-" "-" 0ms