Load GoPlugin in Kong running in K8s

I developed a small go plugin code for Kong and build the docker image. I am able to generate .so file and this is my dockerfile:

FROM kong/go-plugin-tool:2.0.4-alpine-latest AS builder
RUN mkdir -p /tmp/url/
COPY ./url.go /tmp/url/url.go
RUN cd /tmp/url/ && \
    go get github.com/Kong/go-pdk && \
    go mod init kong-go-plugin && \
    go get -d -v github.com/Kong/go-pluginserver && \
    go build github.com/Kong/go-pluginserver && \
    go build -buildmode plugin url.go

FROM kong:2.3-alpine
COPY --from=builder  /tmp/url/go-pluginserver /usr/local/bin/go-pluginserver
COPY --from=builder  /tmp/url/url.so /usr/local/kong/go-plugins/url.so
USER root
RUN chmod -R 777 /tmp
RUN /usr/local/bin/go-pluginserver -version && \
    /usr/local/bin/go-pluginserver -dump-all-plugins -plugins-directory /usr/local/kong/go-plugins
USER kong

I am running Kong:2.3.3 (bdless mode) in K8s (set-up by kubeadm) and I updated the kong image in the YAML file to the docker image I built but, I am getting an error in proxy pod:

2021/04/12 09:55:33 [error] 1#0: init_by_lua error: /usr/local/share/lua/5.1/kong/init.lua:490: error loading plugin schemas: on plugin 'url': url plugin is enabled but not installed;
no plugin found
stack traceback:
	[C]: in function 'assert'
	/usr/local/share/lua/5.1/kong/init.lua:490: in function 'init'
	init_by_lua:3: in main chunk
nginx: [error] init_by_lua error: /usr/local/share/lua/5.1/kong/init.lua:490: error loading plugin schemas: on plugin 'url': url plugin is enabled but not installed;
no plugin found
stack traceback:
	[C]: in function 'assert'
	/usr/local/share/lua/5.1/kong/init.lua:490: in function 'init'
	init_by_lua:3: in main chunk

When I run a container from the docker image I generated I am seeing this:

/usr/local/kong $  /usr/local/bin/go-pluginserver -dump-all-plugins -plugins-directory /usr/local/kong/go-plugins
[{"Name":"url","Phases":["access"],"Version":"","Priority":0,"Schema":{"name":"url","fields":[{"config":{"type":"record","fields":[{"urlpath":{"type":"string"}}]}}]}}]

I have added these in my YAML file:

- name: KONG_GO_PLUGINS_DIR
  value: /usr/local/kong/go-plugins/
- name: KONG_PLUGINS
  value: bundled,url
- name: KONG_PLUGINSERVER_EXE
  value: /usr/local/bin/go-pluginserver
- name: KONG_PLUGINSERVER_NAMES
  value: go

I feel somehow my plugin is not installed properly. Can one educate me what wrong I am doing here?
I am ready to write a clean documentation for Goplugins in Kong.
@salazar @hbagdi Any hints.


© 2019 Kong Inc.    Terms  •  Privacy  •  FAQ