Using environment variables in kong.yml

2,202 views
Skip to first unread message

Jason Motylinski

unread,
May 30, 2015, 10:55:49 PM5/30/15
to kong...@googlegroups.com
Hello - 

I'm attempting to set up kong on Google's Container Engine, Kubernetes. One thing which Kubernetes doesn't seem to support is linking between Docker containers. 

Kubernetes has a concept of "Services" which are a way of encapsulating many instances of a container under a pseudo load balancer. To reference services in an other container (ilke Kong needing Cassandra) Kubernetes sets environment variables. For instance, the Kong container has an environment variable called "CASSANDRA_SERVICE_HOST" which has the IP address of the Cassandra container.

Is there a way to use an environment variable at runtime in the kong.yml file?

For reference, this is how Kubernetes suggests discovering services:

Thanks,

Jason

Thibault Charbonnier

unread,
Jun 3, 2015, 1:34:45 PM6/3/15
to kong...@googlegroups.com
Hi jason,

There is no way to pass environment variables at runtime to kong.yml but what I can suggest you is to replace the value in kong.yml when starting your container, before starting Kong:

sed -ie "s/hosts: \"localhost\"/hosts: $CASSANDRA_SERVICE_HOST/" kong.yml


How does that sound? It should solve your problem.

y...@yunspace.com

unread,
Jul 24, 2016, 8:36:10 PM7/24/16
to Kong
Hi, just an FYI I've created a fork which supports certain Postgres and Cassandra environment variables: https://github.com/LittleBayDigital/docker-kong-service 

Hope this helps until a official solution is out.

Marco

unread,
Jul 25, 2016, 1:40:09 PM7/25/16
to y...@yunspace.com, Kong
Starting from 0.9 all the configuration properties can be overwritten with environment variables.


 Marco Palladino | CTO @ Mashape | mashape.com+1 (415) 361-3858

--
You received this message because you are subscribed to the Google Groups "Kong" group.
To unsubscribe from this group and stop receiving emails from it, send an email to konglayer+...@googlegroups.com.
To post to this group, send email to kong...@googlegroups.com.
Visit this group at https://groups.google.com/group/konglayer.
To view this discussion on the web visit https://groups.google.com/d/msgid/konglayer/34e557c1-c9f4-432e-ba69-2c25e5bb21f5%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages