Darth Shirr
Darth Shirr

Reputation: 587

Deploying custom Kong plugin in GKE deployed Kong API Gateway

I'm looking up on the Kong API gateway and deployed a Kong instance on GKE via Google Cloud Marketplace. I want to add a custom Kong plugin to this instance and enable it for my services. How could I do it? are there any resources I could follow to get an idea on this? thank you.

Upvotes: 1

Views: 591

Answers (2)

Harsh Manvar
Harsh Manvar

Reputation: 30083

if you are using docker

you can install any plugin in kong using luarocks

For example here is one sample docker file

FROM kong
ENV LUA_PATH /usr/local/share/lua/5.1/?.lua;/usr/local/kong-oidc/?.lua;;
# For lua-cjson
ENV LUA_CPATH /usr/local/lib/lua/5.1/?.so;;

# Install unzip for luarocks, gcc for lua-cjson
RUN yum install -y unzip gcc 
RUN luarocks install luacov

here one example of oidc plugin : https://github.com/nokia/kong-oidc

we can install plugin using : luarocks install <plugin name>

build your own custom docker image and use kong image as base docker image.

here whole example working Dockerfile

FROM kong:latest  
USER root
RUN apk update && apk add git unzip luarocks
RUN luarocks install kong-oidc  
USER kong

by this way also you can add some of the community plugin and enterprise plugin in docker.

Upvotes: 2

Pablo
Pablo

Reputation: 66

You could either bake the custom plugin into your container image, or modify your Deployment manifest to download and run the plugin with command and arguments in the configuration.

For the first option, you only need to add the commands to install and run the plugin to your Dockerfile, then build an image with docker build. Once you have the new image, you can perform a rolling update by using kubectl set image deployment or modify the workload in the Cloud Console.

Modifying the Deployment YAML would have a similar result, but you would need to add command and arguments to download and run the custom plugin whenever the container starts.

The google-marketplace-kong-app and kong-dist-kubernetes repo has instructions on how to build and deploy Kong manually. I'd recommend checking them and include your custom plugin.

Upvotes: 0

Related Questions