<blockquote>
<p>error: resource mapping not found for name: &quot;ingress-srv&quot; namespace: &quot;&quot; from &quot;ingress-srv.yaml&quot;: no matches for kind &quot;Ingress&quot; in version &quot;networking.k8s.io/v1beta1&quot;
ensure CRDs are installed first</p>
</blockquote>
<p>I am new to Kubernetes, I was setting up ingress nginx on minikube and it installed successfully but when I try to run using kubectl apply -f filename it gives above error</p>
<p>here is the code
filename: <strong>ingress-srv.yaml</strong></p>
<pre><code>apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
  name: ingress-srv
  annotations:
    kubernetes.io/ingress.class: nginx
spec:
  rules:
    - host: posts.com
      http:
        paths:
          - path: /posts
            pathType: Prefix
            backend:
              serviceName: posts-clusterip-srv
              servicePort: 4000
</code></pre>

<p>The resource type specified in your manifest, <code>networking.k8s.io/v1beta1 Ingress</code>, was removed in Kubernetes v1.22 and replaced by <code>networking.k8s.io/v1 Ingress</code> (see the <a href="https://kubernetes.io/docs/reference/using-api/deprecation-guide/#ingress-v122" rel="noreferrer">deprecation guide</a> for details). If your cluster's Kubernetes server version is 1.22 or higher (which I suspect it is) trying to create an Ingress resource from your manifest will result in exactly the error you're getting.</p>
<p>You can check your cluster's Kubernetes server version (as Kamol Hasan points out) using the command <code>kubectl version --short</code>.</p>
<p>If the version is indeed 1.22 or higher, you'll need to modify your YAML file so that its format is valid in the new version of the API. This <a href="https://github.com/kubernetes/kubernetes/pull/89778" rel="noreferrer">pull request</a> summarises the format differences. In your case, <code>ingress-srv.yaml</code> needs to be changed to:</p>
<pre class="lang-yaml prettyprint-override"><code>apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: ingress-srv
  annotations:
    kubernetes.io/ingress.class: nginx
spec:
  rules:
    - host: posts.com
      http:
        paths:
          - path: /posts
            pathType: Prefix
            backend:
              service:
                name: posts-clusterip-srv
                port:
                  number: 4000
</code></pre>
