No matches for kind "ClusterRole" in version "rbac.authorization.k8s.io/v1beta1"

741 Views Asked by At

I created Kubernetes cluster on AWS with the help of kOps and I want to install LoadBalancer on it so I run the command

kubectl create -f https://raw.githubusercontent.com/kubernetes/kops/master/addons/ingress-nginx/v1.6.0.yaml

And got the following error:

namespace/kube-ingress created
serviceaccount/nginx-ingress-controller created
service/nginx-default-backend created
deployment.apps/nginx-default-backend created
configmap/ingress-nginx created
service/ingress-nginx created
deployment.apps/ingress-nginx created
unable to recognize "https://raw.githubusercontent.com/kubernetes/kops/master/addons/ingress-nginx/v1.6.0.yaml": no matches for kind "ClusterRole" in version "rbac.authorization.k8s.io/v1beta1"
unable to recognize "https://raw.githubusercontent.com/kubernetes/kops/master/addons/ingress-nginx/v1.6.0.yaml": no matches for kind "Role" in version "rbac.authorization.k8s.io/v1beta1"
unable to recognize "https://raw.githubusercontent.com/kubernetes/kops/master/addons/ingress-nginx/v1.6.0.yaml": no matches for kind "ClusterRoleBinding" in version "rbac.authorization.k8s.io/v1beta1"
unable to recognize "https://raw.githubusercontent.com/kubernetes/kops/master/addons/ingress-nginx/v1.6.0.yaml": no matches for kind "RoleBinding" in version "rbac.authorization.k8s.io/v1beta1"

I tried to edit my cluster so that v1beta1 API will be supported by adding the following

apiVersion: kops.k8s.io/v1alpha2
kind: Cluster
//ommited
spec:
  //ommited
  kubeAPIServer:
    runtimeConfig:
      rbac.authorization.k8s.io/v1beta1: "true"
  //ommited

But I keep getting the same error

Additional info, output of the following command

kubectl version

looks like this

Client Version: version.Info{Major:"1", Minor:"19", GitVersion:"v1.19.7", GitCommit:"1dd5338295409edcfff11505e7bb246f0d325d15", GitTreeState:"clean", BuildDate:"2021-01-13T13:23:52Z", GoVersion:"go1.15.5", Compiler:"gc", Platform:"windows/amd64"}
Server Version: version.Info{Major:"1", Minor:"22", GitVersion:"v1.22.2", GitCommit:"8b5a19147530eaac9476b0ab82980b4088bbc1b2", GitTreeState:"clean", BuildDate:"2021-09-15T21:32:41Z", GoVersion:"go1.16.8", Compiler:"gc", Platform:"linux/amd64"}
1

There are 1 best solutions below

2
CedricYao On BEST ANSWER

Try applying this. k apply -f I used the v1 here in the apiVersion so you need to do it to all the resources as needed to fit your k8s version.

# clusterRole for 1.22
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
  labels:
    k8s-addon: ingress-nginx.addons.k8s.io
  name: nginx-ingress-controller
  namespace: kube-ingress
rules:
  - apiGroups:
      - ""
    resources:
      - configmaps
      - endpoints
      - nodes
      - pods
      - secrets
    verbs:
      - list
      - watch
  - apiGroups:
      - ""
    resources:
      - nodes
    verbs:
      - get
  - apiGroups:
      - ""
    resources:
      - services
    verbs:
      - get
      - list
      - watch
  - apiGroups:
      - "extensions"
    resources:
      - ingresses
    verbs:
      - get
      - list
      - watch
  - apiGroups:
      - ""
    resources:
        - events
    verbs:
        - create
        - patch
  - apiGroups:
      - "extensions"
    resources:
      - ingresses/status
    verbs:
      - update