You are browsing documentation for an outdated version. See the latest documentation here.

Use Plugins With Containers

Use external plugins in container and Kubernetes

To use plugins requiring external plugin servers, both the plugin servers and the plugins themselves need to be installed inside the Kong Gateway container, copy or mount the plugin’s source code into the Kong Gateway container.

Note: Official Kong Gateway images are configured to run as the nobody user. When building a custom image, to copy files into the Kong Gateway image, you must temporarily set the user to root.

This is an example Dockerfile that explains how to mount your plugin in the Kong Gateway image:

  1. FROM kong
  2. USER root
  3. # Example for GO:
  4. COPY your-go-plugin /usr/local/bin/your-go-plugin
  5. # Example for JavaScript:
  6. RUN apk update && apk add nodejs npm && npm install -g kong-pdk
  7. COPY your-js-plugin /path/to/your/js-plugins/your-js-plugin
  8. # Example for Python
  9. # PYTHONWARNINGS=ignore is needed to build gevent on Python 3.9
  10. RUN apk update && \
  11. apk add python3 py3-pip python3-dev musl-dev libffi-dev gcc g++ file make && \
  12. PYTHONWARNINGS=ignore pip3 install kong-pdk
  13. COPY your-py-plugin /path/to/your/py-plugins/your-py-plugin
  14. # reset back the defaults
  15. USER kong
  16. ENTRYPOINT ["/docker-entrypoint.sh"]
  17. EXPOSE 8000 8443 8001 8444
  18. STOPSIGNAL SIGQUIT
  19. HEALTHCHECK --interval=10s --timeout=10s --retries=10 CMD kong health
  20. CMD ["kong", "docker-start"]

More information