traefik / plugindemo

This repository includes an example plugin, for you to use as a reference for developing your own plugins
https://plugins.traefik.io/plugins/628c9ee2108ecc83915d7764/demo-plugin
Apache License 2.0
140 stars 45 forks source link

Trying to create a new plugin, traefik does not find dev plugin #10

Closed PascalMinder closed 3 years ago

PascalMinder commented 3 years ago

So I am trying to create a new plugin. But I get stuck at a traefik error: time="2021-03-12T09:35:25Z" level=error msg="plugin: unknown plugin type: geoblock" entryPointName=http routerName=hello@docker

Docker Compose:

version: "3.3"

services:
  traefik:
    image: traefik:v2.4
    #command:
      #- --log.level=INFO
      #- --api.insecure=true
      #- --entrypoints.web.address=:80
      #- --providers.docker

    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
      - C:/docker/docker-config/traefik.yml:/etc/traefik/traefik.yml
      - C:/docker/docker-config/dynamic-configuration.yml:/etc/traefik/dynamic-configuration.yml
      - C:/Users/User/go:/plugins/go

    labels:
      traefik.http.routers.dash.rule: Host(`dash.localhost`)
      traefik.http.routers.dash.service: api@internal

    ports:
      - "80:80"

  hello:
    image: containous/whoami
    labels: # auto-detects port 80 in next line
      - traefik.enable=true
      - traefik.http.routers.hello.entrypoints=http
      - traefik.http.routers.hello.rule=Host(`hello.localhost`)
      - traefik.http.services.hello.loadbalancer.server.port=80
      - traefik.http.routers.hello.middlewares=my-plugin@file

  whoami:
    image: jwilder/whoami
    labels:
      - traefik.enable=true
      - traefik.http.routers.whoami.entrypoints=http
      - traefik.http.routers.whoami.rule=Host(`whoami.localhost`)
      - traefik.http.services.whoami.loadbalancer.server.port=8000

traefik.yml:

## traefik.yml
log:
  level: DEBUG

experimental:
  devPlugin:
    goPath: /plugins/go
    moduleName: github.com/user/geoblock

# API and dashboard configuration
api:
  dashboard: true
  insecure: true

entryPoints:
  http:
    address: ":80"
    forwardedHeaders:
      insecure: true

providers:
  docker:
    endpoint: "unix:///var/run/docker.sock"
    exposedByDefault: false
  file:
    filename: /etc/traefik/dynamic-configuration.yml

dynamic-configuration.yml

http:
  middlewares:
    my-plugin:
      plugin:
        geoblock:
          headers:
            Foo: Bar

The content in github.com/user/geoblock is the code from this repo.

ldez commented 3 years ago

Hello,

the name/type of the dev plugin is dev:

http:
  middlewares:
    my-plugin:
      plugin:
        dev:
          headers:
            Foo: Bar

https://github.com/traefik/plugindemo#dev-mode

PascalMinder commented 3 years ago

Hello,

the name/type of the dev plugin is dev:

http:
  middlewares:
    my-plugin:
      plugin:
        dev:
          headers:
            Foo: Bar

https://github.com/traefik/plugindemo#dev-mode

Hi thanks for your reply, If i chang it to your answer I stil get the error:

time="2021-03-12T12:13:06Z" level=info msg="Configuration loaded from file: /etc/traefik/traefik.yml"

time="2021-03-12T12:13:06Z" level=info msg="Traefik version 2.4.7 built on 2021-03-08T17:18:28Z"

time="2021-03-12T12:13:06Z" level=debug msg="Static configuration loaded {\"global\":{\"checkNewVersion\":true},\"serversTransport\":{\"maxIdleConnsPerHost\":200},\"entryPoints\":{\"http\":{\"address\":\":80\",\"transport\":{\"lifeCycle\":{\"graceTimeOut\":10000000000},\"respondingTimeouts\":{\"idleTimeout\":180000000000}},\"forwardedHeaders\":{\"insecure\":true},\"http\":{}},\"traefik\":{\"address\":\":8080\",\"transport\":{\"lifeCycle\":{\"graceTimeOut\":10000000000},\"respondingTimeouts\":{\"idleTimeout\":180000000000}},\"forwardedHeaders\":{},\"http\":{}}},\"providers\":{\"providersThrottleDuration\":2000000000,\"docker\":{\"watch\":true,\"endpoint\":\"unix:///var/run/docker.sock\",\"defaultRule\":\"Host(`{{ normalize .Name }}`)\",\"swarmModeRefreshSeconds\":15000000000},\"file\":{\"watch\":true,\"filename\":\"/etc/traefik/dynamic-configuration.yml\"}},\"api\":{\"insecure\":true,\"dashboard\":true},\"log\":{\"level\":\"DEBUG\",\"format\":\"common\"},\"experimental\":{\"devPlugin\":{\"goPath\":\"/plugins/go\",\"moduleName\":\"github.com/user/geoblock\"}}}"

time="2021-03-12T12:13:06Z" level=info msg="\nStats collection is disabled.\nHelp us improve Traefik by turning this feature on :)\nMore details on: https://doc.traefik.io/traefik/contributing/data-collection/\n"

time="2021-03-12T12:13:06Z" level=info msg="Starting provider aggregator.ProviderAggregator {}"

time="2021-03-12T12:13:06Z" level=debug msg="Start TCP Server" entryPointName=traefik

time="2021-03-12T12:13:06Z" level=info msg="Starting provider *file.Provider {\"watch\":true,\"filename\":\"/etc/traefik/dynamic-configuration.yml\"}"

time="2021-03-12T12:13:06Z" level=debug msg="Start TCP Server" entryPointName=http

time="2021-03-12T12:13:06Z" level=info msg="Starting provider *traefik.Provider {}"

time="2021-03-12T12:13:06Z" level=info msg="Starting provider *acme.ChallengeTLSALPN {\"Timeout\":4000000000}"

time="2021-03-12T12:13:06Z" level=info msg="Starting provider *docker.Provider {\"watch\":true,\"endpoint\":\"unix:///var/run/docker.sock\",\"defaultRule\":\"Host(`{{ normalize .Name }}`)\",\"swarmModeRefreshSeconds\":15000000000}"

time="2021-03-12T12:13:06Z" level=debug msg="Configuration received from provider file: {\"http\":{\"middlewares\":{\"my-plugin\":{\"plugin\":{\"dev\":{\"headers\":{\"Foo\":\"Bar\"}}}}}},\"tcp\":{},\"udp\":{},\"tls\":{}}" providerName=file

time="2021-03-12T12:13:06Z" level=debug msg="Configuration received from provider internal: {\"http\":{\"routers\":{\"api\":{\"entryPoints\":[\"traefik\"],\"service\":\"api@internal\",\"rule\":\"PathPrefix(`/api`)\",\"priority\":2147483646},\"dashboard\":{\"entryPoints\":[\"traefik\"],\"middlewares\":[\"dashboard_redirect@internal\",\"dashboard_stripprefix@internal\"],\"service\":\"dashboard@internal\",\"rule\":\"PathPrefix(`/`)\",\"priority\":2147483645}},\"services\":{\"api\":{},\"dashboard\":{},\"noop\":{}},\"middlewares\":{\"dashboard_redirect\":{\"redirectRegex\":{\"regex\":\"^(http:\\\\/\\\\/(\\\\[[\\\\w:.]+\\\\]|[\\\\w\\\\._-]+)(:\\\\d+)?)\\\\/$\",\"replacement\":\"${1}/dashboard/\",\"permanent\":true}},\"dashboard_stripprefix\":{\"stripPrefix\":{\"prefixes\":[\"/dashboard/\",\"/dashboard\"]}}},\"serversTransports\":{\"default\":{\"maxIdleConnsPerHost\":200}}},\"tcp\":{},\"tls\":{}}" providerName=internal

time="2021-03-12T12:13:06Z" level=debug msg="Added outgoing tracing middleware api@internal" entryPointName=traefik routerName=api@internal middlewareName=tracing middlewareType=TracingForwarder

time="2021-03-12T12:13:06Z" level=debug msg="Added outgoing tracing middleware dashboard@internal" middlewareType=TracingForwarder entryPointName=traefik routerName=dashboard@internal middlewareName=tracing

time="2021-03-12T12:13:06Z" level=debug msg="Creating middleware" middlewareName=dashboard_stripprefix@internal middlewareType=StripPrefix entryPointName=traefik routerName=dashboard@internal

time="2021-03-12T12:13:06Z" level=debug msg="Adding tracing to middleware" entryPointName=traefik routerName=dashboard@internal middlewareName=dashboard_stripprefix@internal

time="2021-03-12T12:13:06Z" level=debug msg="Creating middleware" entryPointName=traefik routerName=dashboard@internal middlewareName=dashboard_redirect@internal middlewareType=RedirectRegex

time="2021-03-12T12:13:06Z" level=debug msg="Setting up redirection from ^(http:\\/\\/(\\[[\\w:.]+\\]|[\\w\\._-]+)(:\\d+)?)\\/$ to ${1}/dashboard/" entryPointName=traefik routerName=dashboard@internal middlewareName=dashboard_redirect@internal middlewareType=RedirectRegex

time="2021-03-12T12:13:06Z" level=debug msg="Adding tracing to middleware" entryPointName=traefik routerName=dashboard@internal middlewareName=dashboard_redirect@internal

time="2021-03-12T12:13:06Z" level=debug msg="Creating middleware" entryPointName=traefik middlewareName=traefik-internal-recovery middlewareType=Recovery

time="2021-03-12T12:13:06Z" level=debug msg="No default certificate, generating one"

time="2021-03-12T12:13:06Z" level=debug msg="Provider connection established with docker 20.10.5 (API 1.41)" providerName=docker

time="2021-03-12T12:13:06Z" level=debug msg="Filtering disabled container" providerName=docker container=traefik-setup-4f3a85a8ea985539f4333517a85fe0ba87d64252ceb41b78f0b8824dd8898596

time="2021-03-12T12:13:06Z" level=debug msg="Configuration received from provider docker: {\"http\":{\"routers\":{\"hello\":{\"entryPoints\":[\"http\"],\"middlewares\":[\"my-plugin@file\"],\"service\":\"hello\",\"rule\":\"Host(`hello.localhost`)\"},\"whoami\":{\"entryPoints\":[\"http\"],\"service\":\"whoami\",\"rule\":\"Host(`whoami.localhost`)\"}},\"services\":{\"hello\":{\"loadBalancer\":{\"servers\":[{\"url\":\"http://172.18.0.2:80\"}],\"passHostHeader\":true}},\"whoami\":{\"loadBalancer\":{\"servers\":[{\"url\":\"http://172.18.0.4:8000\"}],\"passHostHeader\":true}}}},\"tcp\":{},\"udp\":{}}" providerName=docker

time="2021-03-12T12:13:06Z" level=debug msg="No default certificate, generating one"

time="2021-03-12T12:13:06Z" level=debug msg="Creating middleware" middlewareName=pipelining middlewareType=Pipelining routerName=hello@docker serviceName=hello entryPointName=http

time="2021-03-12T12:13:06Z" level=debug msg="Creating load-balancer" entryPointName=http routerName=hello@docker serviceName=hello

time="2021-03-12T12:13:06Z" level=debug msg="Creating server 0 http://172.18.0.2:80" entryPointName=http routerName=hello@docker serviceName=hello serverName=0

time="2021-03-12T12:13:06Z" level=debug msg="Added outgoing tracing middleware hello" entryPointName=http routerName=hello@docker middlewareName=tracing middlewareType=TracingForwarder

time="2021-03-12T12:13:06Z" level=error msg="plugin: unknown plugin type: dev" entryPointName=http routerName=hello@docker

time="2021-03-12T12:13:06Z" level=debug msg="Creating middleware" middlewareName=pipelining middlewareType=Pipelining serviceName=whoami entryPointName=http routerName=whoami@docker

time="2021-03-12T12:13:06Z" level=debug msg="Creating load-balancer" routerName=whoami@docker serviceName=whoami entryPointName=http

time="2021-03-12T12:13:06Z" level=debug msg="Creating server 0 http://172.18.0.4:8000" entryPointName=http serverName=0 routerName=whoami@docker serviceName=whoami

time="2021-03-12T12:13:06Z" level=debug msg="Added outgoing tracing middleware whoami" entryPointName=http routerName=whoami@docker middlewareType=TracingForwarder middlewareName=tracing

time="2021-03-12T12:13:06Z" level=debug msg="Creating middleware" middlewareType=Recovery middlewareName=traefik-internal-recovery entryPointName=http

time="2021-03-12T12:13:06Z" level=debug msg="Added outgoing tracing middleware api@internal" entryPointName=traefik routerName=api@internal middlewareName=tracing middlewareType=TracingForwarder

time="2021-03-12T12:13:06Z" level=debug msg="Added outgoing tracing middleware dashboard@internal" entryPointName=traefik routerName=dashboard@internal middlewareName=tracing middlewareType=TracingForwarder

time="2021-03-12T12:13:06Z" level=debug msg="Creating middleware" entryPointName=traefik routerName=dashboard@internal middlewareName=dashboard_stripprefix@internal middlewareType=StripPrefix

time="2021-03-12T12:13:06Z" level=debug msg="Adding tracing to middleware" middlewareName=dashboard_stripprefix@internal routerName=dashboard@internal entryPointName=traefik

time="2021-03-12T12:13:06Z" level=debug msg="Creating middleware" middlewareName=dashboard_redirect@internal middlewareType=RedirectRegex entryPointName=traefik routerName=dashboard@internal

time="2021-03-12T12:13:06Z" level=debug msg="Setting up redirection from ^(http:\\/\\/(\\[[\\w:.]+\\]|[\\w\\._-]+)(:\\d+)?)\\/$ to ${1}/dashboard/" routerName=dashboard@internal middlewareName=dashboard_redirect@internal middlewareType=RedirectRegex entryPointName=traefik

time="2021-03-12T12:13:06Z" level=debug msg="Adding tracing to middleware" middlewareName=dashboard_redirect@internal entryPointName=traefik routerName=dashboard@internal

time="2021-03-12T12:13:06Z" level=debug msg="Creating middleware" middlewareType=Recovery entryPointName=traefik middlewareName=traefik-internal-recovery

time="2021-03-12T12:13:06Z" level=debug msg="No default certificate, generating one"

time="2021-03-12T12:13:07Z" level=debug msg="No default certificate, generating one"

time="2021-03-12T12:13:06Z" level=error msg="plugin: unknown plugin type: dev" entryPointName=http routerName=hello@docker

PascalMinder commented 3 years ago

Could there be I problem because I use windows?

trois-six commented 3 years ago

Could there be I problem because I use windows?

You MUST use Traefik Pilot to use plugins. I don't see any Pilot token in your configuration?

PascalMinder commented 3 years ago

Could there be I problem because I use windows?

You MUST use Traefik Pilot to use plugins. I don't see any Pilot token in your configuration?

I thought if I use the

experimental:
  devPlugin:
    goPath: /plugins/go/
    moduleName: github.com/traefik/plugindemo

I dont need to use Traefik Pilot, since I am developing it locally and as soon as I want to use it in production I have to use traefik pilot