Accidentally overwrote the default cluster-admin role

4/6/2020

While trying to setup Helm for my cluster I declared the cluster-admin role which caused the overwriting of the default cluster-admin role. Now I don't have it in my cluster anymore. How can I fix this?

-- Erokos
kubernetes
kubernetes-helm

1 Answer

4/6/2020

You can create a new one with the following yaml:

cluster-admin.yaml:

apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
  annotations:
    rbac.authorization.kubernetes.io/autoupdate: "true"
  labels:
    kubernetes.io/bootstrapping: rbac-defaults
  name: cluster-admin
rules:
- apiGroups:
  - '*'
  resources:
  - '*'
  verbs:
  - '*'
- nonResourceURLs:
  - '*'
  verbs:
  - '*'

Create clusterRole:

$ kubectl apply -f cluster-admin.yaml

N.B.:

-- Kamol Hasan
Source: StackOverflow