<p>I try to create an ingress resource over terraform. I receive the following error message</p>
<blockquote>
<p>Error: Failed to create Ingress 'jenkins/jenkins-ingress' because: the
server could not find the requested resource (post
ingresses.extensions) │ │   with kubernetes_ingress.jenkins-ingress, │
on main.tf line 160, in resource &quot;kubernetes_ingress&quot;
&quot;jenkins-ingress&quot;: │  160: resource &quot;kubernetes_ingress&quot;
&quot;jenkins-ingress&quot; {</p>
</blockquote>
<p>My terraform resource looks like this:</p>
<pre><code>resource &quot;kubernetes_ingress&quot; &quot;jenkins-ingress&quot; {
    metadata {
        name = &quot;${var.name}-ingress&quot;
        namespace = var.namespace
        annotations = {
            &quot;ingress.kubernetes.io/rewrite-target&quot; = &quot;/&quot;
            &quot;kubernetes.io/ingress.class&quot; = &quot;nginx&quot;
        }
    }
    spec {
        rule {
            host = &quot;domain.com&quot;
            http {
                path {
                    path = &quot;/&quot;
                    backend {
                        service_name = var.name
                        service_port = 8080
                    }
                }
            }
        }
   }
}
</code></pre>
<p>If I create the ingress over a yaml it works:</p>
<pre><code>apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: jenkins-ingress
  annotations:
    ingress.kubernetes.io/rewrite-target: /
    kubernetes.io/ingress.class: &quot;nginx&quot;
spec:
  rules:
  - host: domain.com
    http:
      paths:
      - path: /
        pathType: Prefix
        backend:
          service:
            name: jenkins
            port:
              number: 8080
</code></pre>
<p>What strikes me is the difference between <em>rule</em> (see <a href="https://registry.terraform.io/providers/hashicorp/kubernetes/latest/docs/resources/ingress" rel="nofollow noreferrer">kubernetes_ingress</a>) and <em>rules</em> in the terraform script and in the yaml. Ideas?</p>

user1747547
<p>I was getting the same error.</p>
<p>Try using <a href="https://registry.terraform.io/providers/hashicorp/kubernetes/latest/docs/resources/ingress_v1" rel="nofollow noreferrer"><code>kubernetes_ingress_v1</code></a> instead of <code>kubernetes_ingress</code> which uses <code>networking.k8s.io/v1</code> instead of <code>networking.k8s.io/v1beta1</code>.</p>
