<p>By default, the data in clusterrole system:node is as below:</p>
<pre><code>$ kubectl get clusterrole system:node -o yaml
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
name: system:node
rules:
- apiGroups:
  - &quot;&quot;
  resources:
  - pods
  verbs:
  - get
  - list
  - watch
- apiGroups:
  - &quot;&quot;
  resources:
  - pods
  verbs:
  - create
  - delete
- apiGroups:
  - &quot;&quot;
  resources:
  - pods/status
  verbs:
  - patch
  - update
</code></pre>
<p>Now, I want to change the clusterrole <code>system:node</code>, and added a <code>- patch</code> under the pods resources, it should be like this:</p>
<pre><code>- apiGroups:
  - &quot;&quot;
  resources:
  - pods
  verbs:
  - get
  - list
  - watch
  - patch
</code></pre>
<p>I could update it by using <code>kubectl edit</code>, but I want to update it in the bash script, so <code>kubectl edit</code> is not suitable, is there any other solution using kubectl?</p>

kins
<p>You can use a <code>kubectl apply -f node-role.yaml</code> where <code>node-role.yaml</code> contains the yaml definition of the <code>ClusterRole</code> with your change included. <code>kubectl apply</code> will update the role if it already exists (and create it otherwise).</p>
