<p>I want to drain a Node from the Node itself. I therefore created a Service Account and added the token to the .kube/config file on the Node. I also creaded the Role Binding.</p>
<p>But I can't figure out the right permissions.
I tried this so far but it didn't work.</p>
<pre class="lang-yaml prettyprint-override"><code>apiVersion: rbac.authorization.k8s.io/v1beta1
kind: ClusterRole
metadata:
  name: admin-clusterrole
rules:
- apiGroups: [&quot;&quot;]
  resources: [&quot;nodes&quot;]
  verbs: [&quot;drain&quot;]

</code></pre>
<p>What would be the correct permissions for that?<br />
Thanks :)</p>
<p>Edit 1:</p>
<p>RoleBinding:</p>
<pre class="lang-yaml prettyprint-override"><code>apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
  name: node-drainer-clusterrole-bind
  namespace: default
subjects:
- kind: ServiceAccount
  name: node-drainer-sa
  namespace: default
roleRef:
  kind: ClusterRole
  name: system:node-drainer
  apiGroup: rbac.authorization.k8s.io
</code></pre>
<p>ServiceAccount:</p>
<pre class="lang-yaml prettyprint-override"><code>apiVersion: v1
kind: ServiceAccount
metadata:
  name: node-drainer-sa
</code></pre>

erkum
<p>First off, you should not use the name <code>admin-clusterrole</code> for this ClusterRole, because you risk locking yourself out of your own cluster by overwriting default bindings.</p>
<p>Here's a ClusterRole which should be able to drain a Node. Let me know if it doesn't work for you.</p>
<pre class="lang-yaml prettyprint-override"><code>apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
  name: system:node-drainer
rules:
  # Needed to evict pods
  - apiGroups: [&quot;&quot;]
    resources: [&quot;pods/eviction&quot;]
    verbs: [&quot;create&quot;]
  # Needed to list pods by Node
  - apiGroups: [&quot;&quot;]
    resources: [&quot;pods&quot;]
    verbs: [&quot;get&quot;, &quot;list&quot;]
  # Needed to cordon Nodes
  - apiGroups: [&quot;&quot;]
    resources: [&quot;nodes&quot;]
    verbs: [&quot;get&quot;, &quot;patch&quot;]
  # Needed to determine Pod owners
  - apiGroups: [&quot;apps&quot;]
    resources: [&quot;statefulsets&quot;]
    verbs: [&quot;get&quot;, &quot;list&quot;]
  # Needed to determine Pod owners
  - apiGroups: [&quot;extensions&quot;]
    resources: [&quot;daemonsets&quot;, &quot;replicasets&quot;]
    verbs: [&quot;get&quot;, &quot;list&quot;]
</code></pre>
<p>You can determine which APIs are used by a kubectl command by using the verbosity levels.</p>
<p>For example:</p>
<pre class="lang-sh prettyprint-override"><code>kubectl drain node my-node -v=10
</code></pre>
<p>From here you can inspect the HTTP requests made by kubectl.</p>
