Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Golang hello-world plugin #155

Closed
urxvtcd opened this issue Nov 4, 2019 · 5 comments
Closed

Golang hello-world plugin #155

urxvtcd opened this issue Nov 4, 2019 · 5 comments
Labels

Comments

@urxvtcd
Copy link

urxvtcd commented Nov 4, 2019

Hi, I'm trying to follow the documentation and setup the example go plugin. KrakenD gets up, I can access the flask server behind it, however as far as I can tell, the plugin is working (I don't get the Println output from init function). I compiled the plugin as documented (had to make this change to the code though: getsentry/raven-go#182). I'm placing the .so file next to krakend.json.

krakend.json

{
  "version": 2,
  "extra_config": {
    "github_com/devopsfaith/krakend/transport/http/server/handler": {
       "name": "krakend-example"
    }
  },
  "timeout": "3000ms",
  "cache_ttl": "300s",
  "output_encoding": "json",
  "name": "krakend-poc",
  "port": 8080,
  "endpoints": [
    {
      "endpoint": "/hello-1",
      "method": "GET",
      "extra_config": {},
      "output_encoding": "no-op",
      "concurrent_calls": 1,
      "headers_to_pass": [
        "Authorization"
      ],
      "querystring_params": [
        "name"
      ],
      "backend": [
        {
          "extra_config": {},
          "url_pattern": "/",
          "is_collection": true,
          "encoding": "no-op",
          "sd": "static",
          "method": "GET",
          "host": [
            "http://flask-basic-auth-1:5000"
          ],
          "disable_host_sanitize": false
        }
      ]
    }
  ]
}

I run krakend in using image from dockerhub, here's the docker-compose.yml

version: '3.5'

services:

  krakend:
    image: devopsfaith/krakend:latest
    ports:
      - "8080:8080"
    volumes:
      - ./krakend/:/etc/krakend/

  flask-basic-auth-1:
    build:
      context: flask-basic-auth
      args:
        - "http_proxy=${http_proxy}"
        - "https_proxy=${http_proxy}"
        - "no_proxy=${no_proxy}"
    environment:
      - APPNUM=1
      - USER=user1
      - PASS=pass1
    ports:
      - "5000:5000"

Here are logs:

...
Successfully tagged krakend-poc_flask-basic-auth-1:latest
Starting krakend-poc_krakend_1            ... done
Starting krakend-poc_flask-basic-auth-1_1 ... done
Attaching to krakend-poc_flask-basic-auth-1_1, krakend-poc_krakend_1
krakend_1             | Parsing configuration file: /etc/krakend/krakend.json
krakend_1             | 2019/11/04 09:00:28  ERROR: unable to create the gologging logger: getting the extra config for the krakend-gologging module
krakend_1             | 2019/11/04 09:00:28  ERROR: unable to create the GELF writer: getting the extra config for the krakend-gelf module
krakend_1             | 2019/11/04 09:00:28  INFO: Listening on port: 8080
krakend_1             | 2019/11/04 09:00:28  WARNING: building the etcd client: unable to create the etcd client: no config
krakend_1             | 2019/11/04 09:00:28  DEBUG: creating a new influxdb client
krakend_1             | 2019/11/04 09:00:28  DEBUG: no config for the influxdb client. Aborting
krakend_1             | 2019/11/04 09:00:28  WARNING: influxdb: unable to load custom config
krakend_1             | 2019/11/04 09:00:28  WARNING: opencensus: no extra config defined for the opencensus module
krakend_1             | 2019/11/04 09:00:28  DEBUG: no config for the bloomfilter
krakend_1             | 2019/11/04 09:00:28  WARNING: bloomFilter: no config for the bloomfilter
krakend_1             | 2019/11/04 09:00:28  INFO: registering usage stats for cluster ID 'KATLdbT86LVaKm5q0vA3UjdmjySn7z3Ep242Jpsf3qA='
krakend_1             | 2019/11/04 09:00:28  WARNING: no config present for the httpsecure module
krakend_1             | 2019/11/04 09:00:28  DEBUG: lua: no extra config
krakend_1             | 2019/11/04 09:00:28  DEBUG: botdetector middleware:  no config defined for the module
krakend_1             | 2019/11/04 09:00:28  DEBUG: AMQP: http://flask-basic-auth-1:5000: no amqp consumer defined
krakend_1             | 2019/11/04 09:00:28  DEBUG: AMQP: http://flask-basic-auth-1:5000: no amqp producer defined
krakend_1             | 2019/11/04 09:00:28  DEBUG: pubsub: subscriber (http://flask-basic-auth-1:5000): github.com/devopsfaith/krakend-pubsub/subscriber not found in the extra config
krakend_1             | 2019/11/04 09:00:28  DEBUG: pubsub: publisher (http://flask-basic-auth-1:5000): github.com/devopsfaith/krakend-pubsub/publisher not found in the extra config
krakend_1             | 2019/11/04 09:00:28  DEBUG: http-request-executor: no extra config for backend /
krakend_1             | 2019/11/04 09:00:28  DEBUG: CEL: no extra config detected for backend /
krakend_1             | [GIN-debug] [WARNING] Running in "debug" mode. Switch to "release" mode in production.
krakend_1             |  - using env:	export GIN_MODE=release
krakend_1             |  - using code:	gin.SetMode(gin.ReleaseMode)
krakend_1             | 
krakend_1             | 2019/11/04 09:00:28  DEBUG: lua: no extra config
krakend_1             | 2019/11/04 09:00:28  DEBUG: CEL: no extra config detected for pipe /hello-1
krakend_1             | 2019/11/04 09:00:28  DEBUG: lua: no extra config
krakend_1             | 2019/11/04 09:00:28  INFO: JOSE: singer disabled for the endpoint /hello-1
krakend_1             | 2019/11/04 09:00:28  DEBUG: lua: no extra config
krakend_1             | 2019/11/04 09:00:28  INFO: JOSE: validator disabled for the endpoint /hello-1
krakend_1             | 2019/11/04 09:00:28  DEBUG: botdetector:  no config defined for the module
krakend_1             | 2019/11/04 09:00:28  DEBUG: http-server-handler: no plugins registered for the module
flask-basic-auth-1_1  |  * Serving Flask app "hello.py"
flask-basic-auth-1_1  |  * Environment: production
flask-basic-auth-1_1  |    WARNING: This is a development server. Do not use it in a production deployment.
flask-basic-auth-1_1  |    Use a production WSGI server instead.
flask-basic-auth-1_1  |  * Debug mode: off
flask-basic-auth-1_1  |  * Running on http://0.0.0.0:5000/ (Press CTRL+C to quit)
krakend_1             | 2019/11/04 09:00:33  WARNING: unable to create the usage report client: Post https://usage.krakend.io/session: context deadline exceeded
@kpacha
Copy link
Member

kpacha commented Nov 4, 2019

it looks like you are not enabling the plugin loader in your config. Try adding this section:

"plugin": {
  "folder": ".",
  "pattern": ".so"
}

@urxvtcd
Copy link
Author

urxvtcd commented Nov 4, 2019

Hm, I put this just under the version key, doesn't seem to help...

@kpacha
Copy link
Member

kpacha commented Nov 4, 2019

are you sure the plugin is mounted as expected on the docker container?

@urxvtcd
Copy link
Author

urxvtcd commented Nov 5, 2019

From inside the container:

# ls /etc/krakend/
krakend-example.so  krakend.json

I'm really confused. Maybe I'll try again from scratch.

BTW, I noticed this line in log:

krakend_1             | 2019/11/04 09:00:28  ERROR: unable to create the gologging logger: getting the extra config for the krakend-gologging module

Could this be a problem? (Printlns not getting printed or something)

@urxvtcd urxvtcd closed this as completed Dec 5, 2019
@github-actions
Copy link

github-actions bot commented Apr 8, 2022

This issue was marked as resolved a long time ago and now has been automatically locked as there has not been any recent activity after it. You can still open a new issue and reference this link.

@github-actions github-actions bot added the locked label Apr 8, 2022
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 8, 2022
# for free to subscribe to this conversation on GitHub. Already have an account? #.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants