Forward kubernetes service (302)

Hi,

I tried Traefik to forward kubernetes service(node port) in my LAN Network.

I have two services running on kubernetes

-simple 'hello' from google
-gitlab-ee

  • Without Traefik, With Kubectl port-forward :
    All is working fine

  • With Traefik, Without Kubectl port-forward :

  • Hello service working fine.
  • Gitlab-ee doen't work but it has exactly the same configuration than hello service (except the port of course). This service is reachable on / but the gitlab server redirect us to /users/sign_in to login. Traefik don't follow this redirect and fall in timeout with 302 HTTP code.

How can i handle this redirection ?
is it normal that i have to ?


[accesslog]
[api]
  insecure=true
  dashboard=true # Enabled Dashboard
  debug=false

[[tls.certificates]]
  certFile = "/var/traefik2/tls/mcert.crt"
  keyFile = "/var/traefik2/tls/mkey.key"
  stores = ["default"]

[tls.stores]
  [tls.stores.default]
    [tls.stores.default.defaultCertificate]
      certFile = "/var/traefik2/tls/mcert.crt"
      keyFile = "/var/traefik2/tls/mkey.key"

# ENTRYPOINTS

[entryPoints]
  [entryPoints.websecure]
    address = ":443"  
  [entryPoints.web]
    address = ":80"
    [entryPoints.web.http.redirections.entryPoint]
      to = "websecure"
      scheme = "https"
      permanent = true

# ROUTERS

[http.routers]
  [http.routers.my-api]
    rule = "PathPrefix(`/api`) || PathPrefix(`/dashboard`)"
    service = "api@internal"
    middlewares = ["auth"]
    [http.routers.my-api.tls]
    [http.middlewares.auth.basicAuth]
    users = [
    ]  

  [http.routers.kub-hello-router]
    entryPoints = ["web", "websecure"]
    rule = "Host(`192.168.3.121`) && Path(`/hello`)"
    service = "kub-hello-svc"
    [http.routers.kub-hello-router.tls]  

  [http.routers.rgitlab-router] 
    entryPoints = ["web", "websecure"]
    rule = "Host(`192.168.3.121`) && Path(`/glab`)"
    service = "kub-gitlab-svc"
    [http.routers.rgitlab-router.tls]

# SERVICES    

[http.services]
  [http.services.kub-hello-svc]
    [http.services.kub-hello-svc.loadBalancer]
      [[http.services.kub-hello-svc.loadBalancer.servers]]
        url = "http://192.168.160.2:31080/hello"                # hello - rancher

  [http.services.kub-gitlab-svc]
    [http.services.kub-gitlab-svc.loadBalancer]
      [[http.services.kub-gitlab-svc.loadBalancer.servers]]
        url = "http://192.168.160.2:31090"                      # gitlab - rancher     /users/sign_in

# Config file
[providers.file]
  directory = "/etc/traefik/"
  watch = true

# ERROR DEBUG INFO
[log]
  level="INFO"

Stucked from 3 days, thanks for your help )

Hey @StoryDevOffical

I ask out of curiosity, Why you don't use Kubernetes Ingress or Kubernetes Ingressroute in order to create routing?

Using statically assigned IP addresses is not a good idea, I would recommend to create Ingress configuration and refer to Kubernetes Service object that expose Gitlab.

Here is recording that should help you to achieve this Workshop: Getting Started with Traefik - YouTube

Hi @jakubhajek

I am running local cluster(k3s with rancher on premise) so i don't have external load balancer to work with ingress (related to external ip).

I just want to access my service on LAN network and forward them with traefik, like i can do with kubectl port-forward

Here i asked how can i replace kubectl port-forward, traefik was an advice so i'm trying it.