Answers: <p>Set <code>automountServiceAccountToken: true</code> in your pod specification in both of the jobs and the deployment.</p>
  <p>Ref: <a href="https://discuss.kubernetes.io/t/nginx-ingress-install-failure/5379/4" rel="nofollow noreferrer">https://discuss.kubernetes.io/t/nginx-ingress-install-failure/5379/4</a></p>
  
Answers: CC BY-SA 4.0
Answers: 2021-06-04T20:27:25.210Z
Answers: 2021-06-05T06:36:03.700Z
Answers: 2021-06-05T06:36:03.700Z
Answers: Samit
Body: <h2>What I'm trying to do</h2>
  <p>I'm trying to get the <a href="https://kubernetes.github.io/ingress-nginx/deploy/#aws" rel="nofollow noreferrer">Nginx controller</a> up and running on my kubernetes cluster with the <a href="https://raw.githubusercontent.com/kubernetes/ingress-nginx/controller-v0.46.0/deploy/static/provider/aws/deploy.yaml" rel="nofollow noreferrer">NLB version of the config files</a>.</p>
  <h2>The problem</h2>
  <p>The <code>ingress-nginx-admission-create</code> and <code>ingress-nginx-admission-patch</code> jobs immediately fail and do not create the <code>ingress-nginx-admission</code> secret that the deployment needs to mount a cert and key.</p>
  <h2>Details</h2>
  <h3>logs from the <code>ingress-nginx-admission-create</code> job</h3>
  <pre><code>W0603 17:59:17.907729       1 client_config.go:608] Neither --kubeconfig nor --master was specified.  Using the inClusterConfig.  This might not work.
  W0603 17:59:17.907803       1 client_config.go:613] error creating inClusterConfig, falling back to default config: open /var/run/secrets/kubernetes.io/serviceaccount/token: no such file or directory
  {&quot;error&quot;:&quot;invalid configuration: no configuration has been provided, try setting KUBERNETES_MASTER environment variable&quot;,&quot;level&quot;:&quot;fatal&quot;,&quot;msg&quot;:&quot;error building kubernetes config&quot;,&quot;source&quot;:&quot;k8s/k8s.go:21&quot;,&quot;time&quot;:&quot;2021-06-03T17:59:17Z&quot;}
  </code></pre>
  <h3>logs from the <code>ingress-nginx-admission-patch</code> job</h3>
  <pre><code>0603 17:59:18.990027       1 client_config.go:608] Neither --kubeconfig nor --master was specified.  Using the inClusterConfig.  This might not work.
  W0603 17:59:18.990093      1 client_config.go:613] error creating inClusterConfig, falling back to default config: open /var/run/secrets/kubernetes.io/serviceaccount/token: no such file or directory
  {&quot;error&quot;:&quot;invalid configuration: no configuration has been provided, try setting KUBERNETES_MASTER environment variable&quot;,&quot;level&quot;:&quot;fatal&quot;,&quot;msg&quot;:&quot;error building kubernetes config&quot;,&quot;source&quot;:&quot;k8s/k8s.go:21&quot;,&quot;time&quot;:&quot;2021-06-03T17:59:18Z&quot;}
  </code></pre>
  <p>Essentially the same as the <code>create</code> job.</p>
  <h3>describing the deployment's pod</h3>
  <pre><code>Events:
    Type     Reason       Age                   From               Message
    ----     ------       ----                  ----               -------
    Normal   Scheduled    4m56s                 default-scheduler  Successfully assigned ingress-nginx/ingress-nginx-controller-59b98554fb-8bp6t to ip-172-31-47-215.us-west-2.compute.internal
    Warning  FailedMount  47s (x10 over 4m57s)  kubelet            MountVolume.SetUp failed for volume &quot;webhook-cert&quot; : secret &quot;ingress-nginx-admission&quot; not found
    Warning  FailedMount  38s (x2 over 2m54s)   kubelet            Unable to attach or mount volumes: unmounted volumes=[webhook-cert], unattached volumes=[webhook-cert]: timed out waiting for the condition
  </code></pre>
  <h3>potentially useful information</h3>
  <p>I saw on other sources that I should try deleting the ValidatingWebhookConfiguration and recreate the jobs and deployment--that didn't work and I got the same logs/results. I tried creating a secret with empty secrets prior to the jobs running but that resulted in basically the same thing. The deployment was actually able to get going (in a way) but it didn't have the certificate or key from the jobs.</p>
  <h2>My question</h2>
  <p>Why aren't the jobs creating the secret? Is there something I need to modify?</p>
  
Comments: CC BY-SA 4.0
Comments: 2021-06-03T18:15:41.953Z
Comments: Is this a fresh setup?
Comments: Samit
Comments: CC BY-SA 4.0
Comments: 2021-06-03T19:00:21.673Z
Comments: Not exactly sure what you mean, but if I had to guess, I'd say no. I'm installing this on a cluster where I have the GitLab Helm chart installed which comes with its own Nginx. However, that Nginx controller is in a different namespace.
Comments: Zachary Delano
Comments: CC BY-SA 4.0
Comments: 2021-06-03T19:18:25.283Z
Comments: https://discuss.kubernetes.io/t/nginx-ingress-install-failure/5379 
  Check this out, this could be the reason.
Comments: Samit
Comments: CC BY-SA 4.0
Comments: 2021-06-03T19:36:57.827Z
Comments: @Samit YES!!! That was it! I had to add `automount_service_account_token = true` (terraform syntax, it'll be camel-cased in k8s) to the pod spec in both of my jobs. I also added it to the pod spec in the deployment but I'm not absolutely sure if that's needed. Go ahead and put that down in the answer if you want. Thank you so much.
Comments: Zachary Delano
Tags: <kubernetes><amazon-web-services><nginx><ingress>
Title: Nginx Ingress Controller - error creating inClusterConfig
UserDisplayName: Zachary Delano
ThreadText: # Nginx Ingress Controller - error creating inClusterConfig
  
  (Asked by: username_0 on 2021-06-03)
  
  ## What I'm trying to do
  
  I'm trying to get the [Nginx controller](https://kubernetes.github.io/ingress-nginx/deploy/#aws) up and running on my kubernetes cluster with the [NLB version of the config files](https://raw.githubusercontent.com/kubernetes/ingress-nginx/controller-v0.46.0/deploy/static/provider/aws/deploy.yaml).
  
  ## The problem
  
  The `ingress-nginx-admission-create` and `ingress-nginx-admission-patch` jobs immediately fail and do not create the `ingress-nginx-admission` secret that the deployment needs to mount a cert and key.
  
  ## Details
  
  ### logs from the `ingress-nginx-admission-create` job
  
  ```
  W0603 17:59:17.907729       1 client_config.go:608] Neither --kubeconfig nor --master was specified.  Using the inClusterConfig.  This might not work.
  W0603 17:59:17.907803       1 client_config.go:613] error creating inClusterConfig, falling back to default config: open /var/run/secrets/kubernetes.io/serviceaccount/token: no such file or directory
  {"error":"invalid configuration: no configuration has been provided, try setting KUBERNETES_MASTER environment variable","level":"fatal","msg":"error building kubernetes config","source":"k8s/k8s.go:21","time":"2021-06-03T17:59:17Z"}
  
  ```
  
  ### logs from the `ingress-nginx-admission-patch` job
  
  ```
  0603 17:59:18.990027       1 client_config.go:608] Neither --kubeconfig nor --master was specified.  Using the inClusterConfig.  This might not work.
  W0603 17:59:18.990093      1 client_config.go:613] error creating inClusterConfig, falling back to default config: open /var/run/secrets/kubernetes.io/serviceaccount/token: no such file or directory
  {"error":"invalid configuration: no configuration has been provided, try setting KUBERNETES_MASTER environment variable","level":"fatal","msg":"error building kubernetes config","source":"k8s/k8s.go:21","time":"2021-06-03T17:59:18Z"}
  
  ```
  
  Essentially the same as the `create` job.
  
  ### describing the deployment's pod
  
  ```
  Events:
    Type     Reason       Age                   From               Message
    ----     ------       ----                  ----               -------
    Normal   Scheduled    4m56s                 default-scheduler  Successfully assigned ingress-nginx/ingress-nginx-controller-59b98554fb-8bp6t to ip-172-31-47-215.us-west-2.compute.internal
    Warning  FailedMount  47s (x10 over 4m57s)  kubelet            MountVolume.SetUp failed for volume "webhook-cert" : secret "ingress-nginx-admission" not found
    Warning  FailedMount  38s (x2 over 2m54s)   kubelet            Unable to attach or mount volumes: unmounted volumes=[webhook-cert], unattached volumes=[webhook-cert]: timed out waiting for the condition
  
  ```
  
  ### potentially useful information
  
  I saw on other sources that I should try deleting the ValidatingWebhookConfiguration and recreate the jobs and deployment--that didn't work and I got the same logs/results. I tried creating a secret with empty secrets prior to the jobs running but that resulted in basically the same thing. The deployment was actually able to get going (in a way) but it didn't have the certificate or key from the jobs.
  
  ## My question
  
  Why aren't the jobs creating the secret? Is there something I need to modify?
  
  **Tags:** kubernetes, amazon-web-services, nginx, ingress
  
  > **Comments:**
  > **username_1**: Is this a fresh setup?  
  > **username_0**: Not exactly sure what you mean, but if I had to guess, I'd say no. I'm installing this on a cluster where I have the GitLab Helm chart installed which comes with its own Nginx. However, that Nginx controller is in a different namespace.  
  > **username_1**: https://discuss.kubernetes.io/t/nginx-ingress-install-failure/5379  Check this out, this could be the reason.  
  > **username_0**: @username_1 YES!!! That was it! I had to add `automount_service_account_token = true` (terraform syntax, it'll be camel-cased in k8s) to the pod spec in both of my jobs. I also added it to the pod spec in the deployment but I'm not absolutely sure if that's needed. Go ahead and put that down in the answer if you want. Thank you so much.  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2021-06-04. Score: 1 | Accepted answer
  
  Set `automountServiceAccountToken: true` in your pod specification in both of the jobs and the deployment.
  
  Ref: <https://discuss.kubernetes.io/t/nginx-ingress-install-failure/5379/4>
  
  
  ---
  
  