<p>I have setup nginx ingress controller configurations under the data property as shown in the below yaml file.</p>
<ol>
<li><p>I would like to know is this the correct way to set nginx configurations instead of providing a nginx.conf file.</p>
</li>
<li><p>Secondly I would like to find out whether the provided configurations are set. To find whether the new configurations are applied, should I exec into the pod and run <code>nginx -T</code> or is there any other way to find it?</p>
</li>
</ol>
<pre><code>kind: ConfigMap
apiVersion: v1
metadata:
  name: nginx-configuration
  namespace: ingress-nginx
  labels:
    app.kubernetes.io/name: ingress-nginx
    app.kubernetes.io/part-of: ingress-nginx
data:
  worker-processes: &quot;24&quot;
  worker-connections: &quot;100000&quot;
  worker-rlimit-nofile: &quot;102400&quot;
  worker-cpu-affinity: &quot;auto 111111111111111111111111&quot;
  keepalive: &quot;200&quot;
  main-template: | 
   user nginx;
   worker_processes  {{.WorkerProcesses}};
   {{- if .WorkerRlimitNofile}}
   worker_rlimit_nofile {{.WorkerRlimitNofile}};{{end}}
   {{- if .WorkerCPUAffinity}}
   worker_cpu_affinity {{.WorkerCPUAffinity}};{{end}}
   {{- if .WorkerShutdownTimeout}}
   worker_shutdown_timeout {{.WorkerShutdownTimeout}};{{end}}
   daemon off;

   error_log  /var/log/nginx/error.log {{.ErrorLogLevel}};
   pid        /var/run/nginx.pid;

   {{- if .MainSnippets}}
   {{range $value := .MainSnippets}}
   {{$value}}{{end}}
   {{- end}}

   events {
       worker_connections  {{.WorkerConnections}};
   }

   http {
       include       /etc/nginx/mime.types;
       default_type  application/octet-stream;
       
       ...
      

       sendfile        on;
       access_log  off;
       tcp_nopush  on;
       tcp_nodelay on;

       keepalive_timeout  315;
       keepalive_requests 10000000;

       #gzip  on;   
        ...
   }

---
kind: ConfigMap
apiVersion: v1
metadata:
  name: tcp-services
  namespace: ingress-nginx
  labels:
    app.kubernetes.io/name: ingress-nginx
    app.kubernetes.io/part-of: ingress-nginx

---
kind: ConfigMap
apiVersion: v1
metadata:
  name: udp-services
  namespace: ingress-nginx
  labels:
    app.kubernetes.io/name: ingress-nginx
    app.kubernetes.io/part-of: ingress-nginx

---
apiVersion: v1
kind: ServiceAccount
metadata:
  name: nginx-ingress-serviceaccount
  namespace: ingress-nginx
  labels:
    app.kubernetes.io/name: ingress-nginx
    app.kubernetes.io/part-of: ingress-nginx

</code></pre>

jeril
<p>There are many ways how to install <code>NGINX Ingress Controller</code>, however they depends on environments they are deploying on.
For example for minikube:</p>
<strong>minikube</strong>
<p>For standard usage:</p>
<p><code>minikube addons enable ingress</code></p>
<p>To check if the ingress controller pods have started, run the following command:</p>
<p><code>$ kubectl get pods -n ingress-nginx \ -l app.kubernetes.io/name=ingress-nginx --watch</code></p>
<p>You can use <strong>helm</strong> (but only <code>v3</code>):</p>
<p><code>NGINX Ingress controller</code> can be installed via  <a href="https://helm.sh/" rel="nofollow noreferrer">Helm</a>  using the chart from the project repository. To install the chart with the release name  <code>ingress-nginx</code>:</p>
<pre><code>$ helm repo add ingress-nginx https://kubernetes.github.io/ingress-nginx
$ helm repo update
$ helm install ingress-nginx ingress-nginx/ingress-nginx
</code></pre>
<p>Then try to detect installed version:</p>
<p><code>POD_NAME=$(kubectl get pods -l app.kubernetes.io/name=ingress-nginx -o jsonpath='{.items[0].metadata.name}') kubectl exec -it $POD_NAME -- /nginx-ingress-controller --version</code></p>
<p>However most common way is to install the NGINX Ingress Controller in your Kubernetes cluster using Kubernetes manifests and then modify nginx-config.yaml</p>
<p><strong>Summing up:</strong> you have to to modify nginx.conf file. You are providing clear specification and then easily you can debug it.</p>
<p>Read more: <a href="https://docs.nginx.com/nginx-ingress-controller/installation/installation-with-manifests/" rel="nofollow noreferrer">nginx-ingress-controller-installation-manifest</a>, <a href="https://kubernetes.github.io/ingress-nginx/deploy/" rel="nofollow noreferrer">nginx-ingress-controller</a>.</p>
<p>Even while troubleshooting you have examples to check <code>nginx.conf</code> file.
To check Ingress Controller you can for example:</p>
<ul>
<li><p><strong>check the Ingress Resource Events</strong></p>
<pre><code>$ kubectl get ing -n &lt;namespace-of-ingress-resource&gt; NAME 
$ kubectl describe ing &lt;ingress-resource-name&gt; -n &lt;namespace-of-ingress-resource&gt;
</code></pre>
</li>
<li><p><strong>check the Ingress Controller Logs</strong></p>
<pre><code>  $ kubectl get pods -n &lt;namespace-of-ingress-controller&gt; 
  $ kubectl logs -n &lt;namespace&gt; nginx-ingress-controller
</code></pre>
</li>
<li><p><strong>check the Nginx Configuration</strong></p>
<pre><code>   $ kubectl get pods -n &lt;namespace-of-ingress-controller&gt;   
   $ kubectl exec -it -n &lt;namespace-of-ingress-controller&gt; nginx-ingress-controller -- cat /etc/nginx/nginx.conf
</code></pre>
</li>
<li><p><strong>check if used Services Exist</strong></p>
<pre><code>  $ kubectl get svc --all-namespaces
</code></pre>
</li>
</ul>
<p>See more: <a href="https://kubernetes.github.io/ingress-nginx/troubleshooting/" rel="nofollow noreferrer">ingress-troubleshooting</a>.</p>
