<p>Is it somehow possible to seperately allow patching of resources' metadata through a role in a Kubernetes cluster?</p>
<p>I would like to solely allow patching of namespace's metadata without giving write permissions to the whole namespace object.</p>
<p>The usecase is to allow deployment pipelines to add/change annotations to the namespace without giving them full control.</p>

roehrijn
<p>To add/change namespace's metadata without giving write permissions to the whole namespace object, you can create a RBAC role where you can restrict access to namespace resources. So that deployment pipeline can have access to change only the metadata i.e., annotations to the namespace without giving them full control.</p>
<p>An RBAC Role contains rules that represent a set of permissions. Permissions are purely additive (there are no &quot;deny&quot; rules).</p>
<p>A Role always sets permissions within a particular <a href="https://kubernetes.io/docs/concepts/overview/working-with-objects/namespaces" rel="nofollow noreferrer">namespace</a>; when you create a Role, you have to specify the namespace it belongs in.</p>
<p>Let us consider an example Role in the namespace that can be used to grant read access to resources pods and services:</p>
<pre><code>apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
  namespace: &lt;namespace-name&gt;
  name: read-access
rules:
- apiGroups: [&quot;&quot;] 
  resources: [&quot;pods&quot;, “services”]
  verbs: [&quot;get&quot;, &quot;watch&quot;, &quot;list&quot;]
</code></pre>
<p>To grant read access to all the resources which are mentioned in the namespace, use this special character <strong>“*”</strong> in the <strong>resources</strong> field i.e., <strong>resources: [&quot;*”]</strong>.</p>
<p><strong>Note :</strong> If you want to restrict resources to a specific user you can use Rolebinding. A role binding grants the permissions defined in a role to a user or set of users. It holds a list of subjects (users, groups, or service accounts), and a reference to the role being granted. A RoleBinding grants permissions within a specific namespace</p>
<p>Refer <a href="https://kubernetes.io/docs/reference/access-authn-authz/rbac/#api-overview" rel="nofollow noreferrer">RBAC Role</a> for more information.</p>
