Johan
Johan

Reputation: 40510

How to handle configuration for Nginx on Kubernetes (GKE)?

Due to limitations of ingress resources (in my case I need more than 50 routes which is not supported in Google Container Engine) I'm considering using Nginx as a reverse proxy to other backend services. What I want to do is essentially the same as an ingress resource provides such as routing path "/x" to service x and "/y" to service y. I'd like to run more than one instance of Nginx for HA, probably behind a service. My question mainly concerns configuration where I have a couple of options:

  1. Create a custom Docker image with nginx as base image and then copy our nginx configuration into this image. This would make it very easy to run this nginx-based image on Kubernetes. But while this works it would require rebuilding, publishing and storing a new custom nginx image every time the configuration changes. We already have pipelines setup for this so it won't be a big problem operationally.
  2. Use the vanilla nginx docker image, create a GCE persistent disk (we're running on Google Container Engine) that is shared between all nginx pods in read only mode. The problem I see with this is approach is how to copy configuration updates to the disk in an easy manner?
  3. Is there a better option? I've looked at config maps and/or secrets (which would solve the configuration update problem) but I don't think they can contain arbitrary data such as an nginx config file.

Upvotes: 1

Views: 2551

Answers (1)

jayme
jayme

Reputation: 1316

ConfigMaps containing text-files should be no problem at all. Take a look at the --from-file option: http://kubernetes.io/docs/user-guide/configmap/.

Im unsure about binary files inside a ConfigMap. I'm able to add a JPEG but trying to read object results in an error so this might not be intended (needs additional base64 encoding or such).

$ kubectl create configmap test --from-file=foo1=/tmp/scudcloud_U0GQ27N0M.jpg
configmap "test" created
$ kubectl get configmap test -o yaml
error: error converting JSON to YAML: %!(EXTRA *errors.errorString=yaml: control characters are not allowed)

Upvotes: 3

Related Questions