Royal thapa
Royal thapa

Reputation: 351

error: resource mapping not found || make sure CRDs are installed first

error: resource mapping not found for name: "ingress-srv" namespace: "" from "ingress-srv.yaml": no matches for kind "Ingress" in version "networking.k8s.io/v1beta1"
ensure CRDs are installed first

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.

here is the code filename: ingress-srv.yaml

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

Upvotes: 35

Views: 93371

Answers (3)

Vishwanath Reddy M
Vishwanath Reddy M

Reputation: 9

Here api version is the problem so please makesure that api version is proper

For Example:

Good case:

apiVersion: resources.azure.com/v1api20200601
kind: ResourceGroup
metadata:
  name: aso-sample-rg
  namespace: default
spec:
  location: westcentralus

Bad case:

apiVersion: azure.microsoft.com/v1alpha1
kind: ResourceGroup
metadata:
   name: rg-aso-sample-sophia1
   namespace: default
spec:
   location: centralus

Sample Screenshot

Upvotes: 0

hasouscsed
hasouscsed

Reputation: 46

A simple solution is to use kubectl convert plugin which was made for upgrading old resource version to new ones. It's installation is available for different OS and is well instructed in K8 docs.

tl;dr For linux: https://kubernetes.io/docs/tasks/tools/install-kubectl-linux/

Step 1) curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"

Step 2) sudo install -o root -g root -m 0755 kubectl-convert /usr/local/bin/kubectl-convert

Step 3) kubectl convert -f old.yaml > new.yaml

Step 4) Use new.yaml as you require.

Upvotes: 0

David Wesby
David Wesby

Reputation: 749

The resource type specified in your manifest, networking.k8s.io/v1beta1 Ingress, was removed in Kubernetes v1.22 and replaced by networking.k8s.io/v1 Ingress (see the deprecation guide 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.

You can check your cluster's Kubernetes server version (as Kamol Hasan points out) using the command kubectl version --short.

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 pull request summarises the format differences. In your case, ingress-srv.yaml needs to be changed to:

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

Upvotes: 43

Related Questions