# How to reload custom go plugin configuration

**URL:** <https://discuss.konghq.com/t/how-to-reload-custom-go-plugin-configuration/12582>\
**Category:** General\
**Tags:** kubernetes, kong-gateway\
**Created:** [April 16, 2024, 2:51pm UTC](https://discuss.konghq.com/t/how-to-reload-custom-go-plugin-configuration/12582 "2024-04-16T14:51:46Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![sebbonnet](https://yyz2.discourse-cdn.com/flex036/user_avatar/discuss.konghq.com/sebbonnet/32/4441_2.png) [@sebbonnet](https://discuss.konghq.com/u/sebbonnet)\
**Post date:** [April 16, 2024, 2:51pm UTC](https://discuss.konghq.com/t/how-to-reload-custom-go-plugin-configuration/12582/1 "2024-04-16T14:51:46Z")

</div>

Hi,

I’m writing a custom go plugin to validate scopes in JWT.  
The plugin takes the “allowed scopes” for a given path as plugin configuration.  
Although the plugin configuration is loaded correctly the first time, subsequent updates to the config are not picked up. Is there a way to rollout config changes or somehow send a signal to the plugin to reload its config?

Here is what the custom plugin configuration looks like.  
The custom plugin is backed in the kong docker image

> apiVersion: [configuration.konghq.com/v1](http://configuration.konghq.com/v1)  
> config:  
> jwksUri: [https://some-url/certs](https://some-url/certs)  
> protectedPaths:  
> - allowedScopes:  
> - tenant-two-scope  
> path: /ip  
> kind: KongPlugin  
> metadata:  
> name: hello-oauth2  
> namespace: kong-tenant-two  
> plugin: mygoplugin

Many thanks!

---

<div class="post-metadata">

**Author:** ![rick](https://yyz2.discourse-cdn.com/flex036/user_avatar/discuss.konghq.com/rick/32/4446_2.png) [@rick](https://discuss.konghq.com/u/rick)\
**Post date:** [April 18, 2024, 5:35pm UTC](https://discuss.konghq.com/t/how-to-reload-custom-go-plugin-configuration/12582/2 "2024-04-18T17:35:27Z")

</div>

@sebbonnet Are you aware of the `configure` function as documented here? You could start with adding some logging to the function to see if it’s being called when you expect.

> **[Implementing Custom Logic - Kong Gateway | Kong Docs](https://docs.konghq.com/gateway/latest/plugin-development/custom-logic/#available-contexts)**
>
> Documentation for Kong, the Cloud Connectivity Company for APIs and Microservices.

---

<div class="post-metadata">

**Author:** ![sebbonnet](https://yyz2.discourse-cdn.com/flex036/user_avatar/discuss.konghq.com/sebbonnet/32/4441_2.png) [@sebbonnet](https://discuss.konghq.com/u/sebbonnet)\
**Post date:** [April 22, 2024, 10:49am UTC](https://discuss.konghq.com/t/how-to-reload-custom-go-plugin-configuration/12582/3 "2024-04-22T10:49:50Z")

</div>

@rick thanks for the response

The doc you’re pointing me to is for LUA plugins, when I’m creating a Golang one.  
There isn’t an equivalent init\_worker as far as I can see in [go-pdk/server/instance.go at v0.11.0 · Kong/go-pdk · GitHub](https://github.com/Kong/go-pdk/blob/v0.11.0/server/instance.go#L31-L51)

I’ve implemented all the methods of the interface, but none are being invoked when the KongPlugin config changes.

> certificater interface{ Certificate(\*pdk.PDK) }|  
> rewriter interface{ Rewrite(\*pdk.PDK) }|  
> accesser interface{ Access(\*pdk.PDK) }|  
> responser interface{ Response(\*pdk.PDK) }|  
> prereader interface{ Preread(\*pdk.PDK) }|  
> logger interface{ Log(\*pdk.PDK) }|

Besides deleting the KongPlugin configuration CR as no effect either, so it does seem that the plugin configuration is cached for the duration of the plugin server at least.  
In fact looking at bit more in `instance.go`, there is a comment suggesting [here](https://github.com/Kong/go-pdk/blob/v0.11.0/server/instance.go#L81-L86) that a new instance should be started in case of plugin config changes and the old one stopped. Are there any examples / guides on how to do that? How can I retrieve the current instance status to stop the old instance and how to generate a new instance status to start a new one?

---

<div class="post-metadata">

**Author:** ![salazar](https://avatars.discourse-cdn.com/v4/letter/s/bbce88/32.png) [@salazar](https://discuss.konghq.com/u/salazar)\
**Post date:** [April 22, 2024, 6:49pm UTC](https://discuss.konghq.com/t/how-to-reload-custom-go-plugin-configuration/12582/4 "2024-04-22T18:49:45Z")

</div>

Hi @sebbonnet ,

Thanks for opening up this issue, welcome to the Kong community.

What Kong version is this? We have recently fixed an issue that sounds like the same as you are facing; check out [[backport -\> release/3.6.x] fix(pluginserver): ensure a change to plugin config takes effect by team-gateway-bot · Pull Request #12729 · Kong/kong · GitHub](https://github.com/Kong/kong/pull/12729). It has been merged and will go out in 3.7.0 (or 3.6.2 if we release one).

If that does not help, please consider opening up an issue in our Git repos [GitHub - Kong/kong: 🦍 The Cloud-Native API Gateway and AI Gateway.](https://github.com/Kong/kong) or even [GitHub - Kong/go-pdk: Write Kong plugins in Go! 🦍](https://github.com/Kong/go-pdk).

Thanks and happy Konging! 🦍

---

<div class="post-metadata">

**Author:** ![sebbonnet](https://yyz2.discourse-cdn.com/flex036/user_avatar/discuss.konghq.com/sebbonnet/32/4441_2.png) [@sebbonnet](https://discuss.konghq.com/u/sebbonnet)\
**Post date:** [April 23, 2024, 7:26am UTC](https://discuss.konghq.com/t/how-to-reload-custom-go-plugin-configuration/12582/5 "2024-04-23T07:26:09Z")

</div>

Hi @salazar,

The bug fix sounds promising.  
I’m using kong docker image 3.6.0-ubuntu (I need the docker image as I’m bundling the custom plugin in it). I can see there is 3.6.1-ubuntu available but not 3.7.0 (or 3.6.2) yet - will you be releasing them soon, so I can test again?

I’ve also raised [Question: How to reload plugin configuration? · Issue #198 · Kong/go-pdk · GitHub](https://github.com/Kong/go-pdk/issues/198) yesterday

Thanks!

---

<div class="post-metadata">

**Author:** ![salazar](https://avatars.discourse-cdn.com/v4/letter/s/bbce88/32.png) [@salazar](https://discuss.konghq.com/u/salazar)\
**Post date:** [April 23, 2024, 3:20pm UTC](https://discuss.konghq.com/t/how-to-reload-custom-go-plugin-configuration/12582/6 "2024-04-23T15:20:45Z")

</div>

@sebbonnet,

3.7 is planned for mid-May. We do not have a date for the next 3.6 patch release.

In the meantime, you can test the fix with our nightly builds [Docker](https://hub.docker.com/r/kong/kong) – note that this build is for testing only and should not be used in prod environments.

---

<div class="post-metadata">

**Author:** ![sebbonnet](https://yyz2.discourse-cdn.com/flex036/user_avatar/discuss.konghq.com/sebbonnet/32/4441_2.png) [@sebbonnet](https://discuss.konghq.com/u/sebbonnet)\
**Post date:** [May 7, 2024, 1:08pm UTC](https://discuss.konghq.com/t/how-to-reload-custom-go-plugin-configuration/12582/7 "2024-05-07T13:08:52Z")

</div>

Hi @salazar,

Thanks for the feedback and sorry for the late reply - I was on leave 🙂

I’ve used the nightly build [3ff9ea0de5a9](https://hub.docker.com/layers/kong/kong/nightly-ubuntu/images/sha256-3ff9ea0de5a9b54c5999b8482e7bd704f76063ecf6367d6687c87b239609ab03?context=explore) and can confirm that the KongPlugin config is now correctly getting reloaded on changes. I’ve also checked that deleting a KongPlugin configuration CR is correctly picked up.

Thanks for your help with it.

I’ll be watching the next Kong releases to get the permanent fix in either 3.6.2 or 3.7

---

<div class="post-metadata">

**Author:** ![salazar](https://avatars.discourse-cdn.com/v4/letter/s/bbce88/32.png) [@salazar](https://discuss.konghq.com/u/salazar)\
**Post date:** [May 7, 2024, 1:28pm UTC](https://discuss.konghq.com/t/how-to-reload-custom-go-plugin-configuration/12582/8 "2024-05-07T13:28:33Z")

</div>

Glad it resolved the issue; thanks for testing and reporting back.

---

<div class="post-metadata">

**Author:** ![cassioconti](https://yyz2.discourse-cdn.com/flex036/user_avatar/discuss.konghq.com/cassioconti/32/4527_2.png) [@cassioconti](https://discuss.konghq.com/u/cassioconti)\
**Post date:** [June 13, 2024, 7:35pm UTC](https://discuss.konghq.com/t/how-to-reload-custom-go-plugin-configuration/12582/9 "2024-06-13T19:35:12Z")

</div>

Hi @salazar,  
Is there a plan to port this fix to the 3.4.x LTS?

---

<div class="post-metadata">

**Author:** ![salazar](https://avatars.discourse-cdn.com/v4/letter/s/bbce88/32.png) [@salazar](https://discuss.konghq.com/u/salazar)\
**Post date:** [June 17, 2024, 7:48pm UTC](https://discuss.konghq.com/t/how-to-reload-custom-go-plugin-configuration/12582/10 "2024-06-17T19:48:25Z")

</div>

@cassioconti 👋 It has already been done - and released in 3.4.3.6.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex036/uploads/konghq/original/2X/8/8651049fb84484276f21c943c975876b17c63898.png) [@system](https://discuss.konghq.com/u/system)\
**Post date:** [June 19, 2024, 7:49pm UTC](https://discuss.konghq.com/t/how-to-reload-custom-go-plugin-configuration/12582/11 "2024-06-19T19:49:00Z")

</div>

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.
