1

I have a very long configuration for nginx ingress that I have to specify using nginx.ingress.kubernetes.io/server-snippet annotation.

nginx.ingress.kubernetes.io/server-snippet: |
      gzip            on;
      gzip_types      text/plain application/xml text/css application/javascript;
      gzip_min_length 1000;
      ... about 100 more lines ...

It is a little ugly to mix resource definition files with nginx configuration, and also some configurations are shared among multiple ingresses. So I want to know, is there any way to load the configuration from a file? I'm using kustomize.

Ahmad
  • 5,551
  • 8
  • 41
  • 57

1 Answers1

0

If I understand correctly you are looking for a way to put your server-snippet configuration into a file and load it into your ingresses.


From what I see in the documentation, it's possible to create a configmap with a server-snippet configuration, and load it into your ingress.

There is an example of such configuration.


If you would use Helm:

  • According to this answer you can create a configmap from a file.
  • I also found an example with server-snippet as multiline environment variable.
Jakub
  • 8,189
  • 1
  • 17
  • 31
  • As the documentations says, using configmaps will inject the config in ALL server sections in the ingress, and it means all namespaces and applications. I suppose this is rarely wanted and won't be useful in my case. – Ahmad Mar 29 '21 at 12:54
  • u need to configure your configmap file check it first # kubectl get cm - A and edit your ingress controller configmap – newcomers May 14 '22 at 04:32