<p>I am trying to follow this tutorial on configuring nginx-ingress-controller for a Kubernetes cluster I deployed to AWS using kops.</p>

<p><a href="https://daemonza.github.io/2017/02/13/kubernetes-nginx-ingress-controller/" rel="nofollow noreferrer">https://daemonza.github.io/2017/02/13/kubernetes-nginx-ingress-controller/</a></p>

<p>When I run <strong>kubectl create -f ./nginx-ingress-controller.yml</strong>, the pods are created but error out. From what I can tell, the problem lies with the following portion of nginx-ingress-controller.yml:</p>

<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-html lang-html prettyprint-override"><code>volumes:
        - name: tls-dhparam-vol
          secret:
            secretName: tls-dhparam
        - name: nginx-template-volume
          configMap:
            name: nginx-template
            items:
            - key: nginx.tmpl
              path: nginx.tmpl</code></pre>
</div>
</div>
</p>

<p>Error shown on the pods:</p>

<p>MountVolume.SetUp failed for volume "nginx-template-volume" : configmaps "nginx-template" not found</p>

<p>This makes sense, because the tutorial does not have the reader create this configmap before creating the controller. I know that I need to create the configmap using:</p>

<p><strong>kubectl create configmap nginx-template --from-file=nginx.tmpl=nginx.tmpl</strong></p>

<p>I've done this using <strong>nginx.tmpl</strong> files found from sources <a href="https://github.com/kubernetes/ingress-nginx/blob/master/rootfs/etc/nginx/template/nginx.tmpl" rel="nofollow noreferrer">like this</a>, but they don't seem to work (always fail with invalid NGINX template errors). Log example:</p>

<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-html lang-html prettyprint-override"><code>I1117 16:29:49.344882       1 main.go:94] Using build: https://github.com/bprashanth/contrib.git - git-92b2bac
I1117 16:29:49.402732       1 main.go:123] Validated default/default-http-backend as the default backend
I1117 16:29:49.402901       1 main.go:80] mkdir /etc/nginx-ssl: file exists already exists
I1117 16:29:49.402951       1 ssl.go:127] using file '/etc/nginx-ssl/dhparam/dhparam.pem' for parameter ssl_dhparam
F1117 16:29:49.403962       1 main.go:71] invalid NGINX template: template: nginx.tmpl:1: function "where" not defined</code></pre>
</div>
</div>
</p>

<p>The image version used is quite old, but I've tried newer versions with no luck.</p>

<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-html lang-html prettyprint-override"><code> containers:
        - name: nginx-ingress-controller
          image: gcr.io/google_containers/nginx-ingress-controller:0.8.3</code></pre>
</div>
</div>
</p>

<p><a href="https://github.com/kubernetes/contrib/issues/2061" rel="nofollow noreferrer">This thread</a> is similar to my issue, but I don't quite understand the proposed solution. Where would I use docker cp to extract a usable template from? Seems like the templates I'm using use a language/syntax incompatible with Docker...?</p>

<p>To copy the nginx template file from the ingress controller pod to your local machine, you can first grab the name of the pod with <code>kubectl get pods</code> then run <code>kubectl exec [POD_NAME] -it -- cat /etc/nginx/template/nginx.tmpl &gt; nginx.tmpl</code>.</p>

<p>This will leave you with the <code>nginx.tmpl</code> file you can then edit and push back up as a configmap. I would recommend though keeping custom changes to the template to a minimum as it can make it hard for you to update the controller in the future.</p>

<p>Hope this helps!</p>
