Specs
- traefik
2.5.3
- traefik helm chart version
10.3.4
- on Google Cloud GKE
1.20.9-gke.701
Problem
I'm unable to get Traefik to detect a Kubernetes Service
. I look at the dashboard to see if at least a route is added, even if it's red (malfunctioning).
Here's the deployment file:
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
run: nginx
name: nginx-deploy-main
namespace: traefik
spec:
replicas: 1
selector:
matchLabels:
run: nginx-main
template:
metadata:
labels:
run: nginx-main
spec:
containers:
- image: nginx
name: nginx
Here's the service:
apiVersion: v1
kind: Service
metadata:
labels:
run: nginx
name: nginx-deploy-main
namespace: traefik
spec:
ports:
- port: 80
protocol: TCP
targetPort: 80
selector:
run: nginx-main
Here's the ingressroute to expose that service:
---
apiVersion: traefik.containo.us/v1alpha1
kind: IngressRoute
metadata:
name: http
namespace: traefik
spec:
entryPoints:
- web
routes:
- match: Host(`does.not.matter.com`)
kind: Rule
services:
- name: nginx-deploy-main
So far so good. However, when I use the same IngressRoute above but add kind: TraefikService
such that it looks like this:
services:
- name: nginx-deploy-main
kind: TraefikService
... I see it appear on the Traefik dashboard:
I understand that kind: Service
is the default.
I don't know what else to try. Thanks for your help in advance!
Note:
- followed this video except that I put traefik and nginx in the
traefik
namespace. My goal is to put the non-traefik services in their own namespace, but that's another topic.
Hello @ramon.tayag
Thanks for using Traefik.
Traefik Service is an abstraction layer created on the top of default Kubernetes resources. It can be used to create more advanced use cases such as canary deployment, mirroring, nested health checks. For general use case, you should use the Kubernetes service and configure it on Ingressroute.
https://doc.traefik.io/traefik/routing/providers/kubernetes-crd/#kind-traefikservice
If you would like to learn more about advanced load balancing techniques based on TraefikService you can join the upcoming webinar that is going to happen on September 30.
Thank you,
Thank you. Yes, that's where I read that kind: Service
is the default in the "Disambiguate Traefik and Kubernetes Services" card.
Currently, I don't need to use TraefikService though, I want to point to a Kubernetes service. I showed that my configuration seems right by getting the route to show up when I put TraefikService
.
I just tried something else: I created a TraefikService that points to the Kubernetes service.
This works. Route shows up. However, based on the documentation and examples I've seen online, it doesn't seem like this needs to be done.
EDIT: Here are some examples
---
apiVersion: traefik.containo.us/v1alpha1
kind: TraefikService
metadata:
name: nginx-ts
namespace: traefik
spec:
weighted:
services:
- name: nginx-deploy-main
port: 80
Then, the IngressRoute points to that TraefikService:
services:
- name: nginx-ts
kind: TraefikService
I followed the same tutorial and ran into the same problem. When I fiddled with the service name (I gave it a different name than the deployment and changed the ingress route to use the new name), the route appeared in Traefik. So apparently something was not picked up right.
I verified that the name match between service and deployment is not the culprit - I deleted the service (the route disappeared), created it with the same name as the deployment and changed the IngressRoute again. The route reappeared.
For debugging, always show the error log of your traefik pod with kubectl logs -f -n traefik id-of-your-traefik-pod
1 Like