how to edit kubernetes cluster role define

1/29/2020

I have created a cluster role yaml(rbac.yaml) like this:

kind: ClusterRole
apiVersion: rbac.authorization.k8s.io/v1beta1
metadata:
  name: traefik-ingress-controller
rules:
  - apiGroups: [""]
    resources: ["services","endpoints","secrets"]
    verbs: ["get","list","watch"]
  - apiGroups: ["extensions"]
    resources: ["ingresses"]
    verbs: ["get","list","watch"]

Now I want to add a new apiGroups into the ClusterRole.

How to edit the ClusterRole and refresh? I search from kubernetes docs,but nothing to tell how to edit.what should I do to update the yaml?

-- Dolphin
kubernetes

1 Answer

1/29/2020

You just need to modify the yaml and apply it again. Kubernetes API Server will take care of updating it into ETCD storage and it should take effect almost immediately.

You can also edit in directly via kubectl edit clusterrole clustebrolename but I don't recommend that because you loose the previous history. You should really be version controlling your yamls and apply the changes with kubectl apply

-- Arghya Sadhu
Source: StackOverflow