Get ConsumerId from KongConsumer


We want to use the X-Consumer-Id to identify certain consumer for a particular use-case. Is there a way to get my consumer’s id from Kubernetes?

I tried the following:

  1. kubectl describe KongConsumer <my-consumer>
  2. kubectl get KongConsumer <my-consumer> -o yaml

It seems like there is no way. Perhaps this is just a bad usage of the consumer id and we should use the username or the custom-id instead, but we already use these for another purpose.


It’s not possible to determine the ID from the KongConsumer. The ID is entirely random; you’ll want to use the username or custom ID instead.

I figured there was no way of determining the consumer ID in advance, I was expecting to be able to get it afterwards though.

You can see the ID in Kong, but the controller never has any knowledge of it. Consumer names are deterministic (they always match the username field in the KongConsumer), so you can retrieve the consumer that way. Something like:

curl -s localhost:8001/consumers/USERNAME | jq .id

when you’ve port-forwarded to 8001 will show the consumer USERNAME’s ID. Note that the ID can change, however, if you restart or if some change results in the controller deleting and creating the consumer again.

Ok, good to know! Thanks for your help! :slight_smile:

© 2019 Kong Inc.    Terms  •  Privacy  •  FAQ