Expose admin API in kong k8 ingress


#1

hello

How can i expose kong admin api using kong k8 ingress .so i can use this REST endpoint for creating consumers dynamically


#2

Although the admin API is still present in ingress controller deployments, you shouldn’t add configuration via it directly. It’s only exposed for the ingress controller to add configuration based on your custom resources. Configuration added manually will be overwritten.

You’ll likely want to instead develop some means of generating KongConsumer resource definitions and applying updates via kubectl.

Kubernetes management is itself handled via a REST API; kubectl is essentially a specialized client for sending the appropriate calls. That API can be accessed via other means, so you should be able to write your own client to create KongConsumers through it if desired. Though I’m not particularly familiar with using the API directly and not sure how to work back from the source to determine the correct endpoints, it should be easy enough to reverse engineer from kubectl’s trace mode, which shows the calls it makes. For example:

$ kubectl --v=10 create -f consumer.yaml
...
I1105 16:46:40.588252   10905 request.go:897] Request Body: {"apiVersion":"configuration.konghq.com/v1","custom_id":"examplesumer","kind":"KongConsumer","metadata":{"name":"examplesumer","namespace":"kingress"},"username":"examplesumer"}
I1105 16:46:40.588289   10905 round_trippers.go:386] curl -k -v -XPOST  -H "User-Agent: kubectl/v1.11.0 (linux/amd64) kubernetes/91e7b4f" -H "Accept: application/json" -H "Content-Type: application/json" 'https://127.0.0.1/apis/configuration.konghq.com/v1/namespaces/kingress/kongconsumers'
I1105 16:46:40.637651   10905 round_trippers.go:405] POST https://127.0.0.1/apis/configuration.konghq.com/v1/namespaces/kingress/kongconsumers 201 Created in 49 milliseconds

#3

thank you.will try that way. i just tried the admin api because for the development and experiment purpose it is easy to use