> For the complete documentation index, see [llms.txt](https://hossainemruz.gitbook.io/notes/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://hossainemruz.gitbook.io/notes/kubernetes/untitled/rbac/cross-namespaced-access.md).

# Cross namespaced access

## How to provide namespaced acces to a service account of other namespace?

#### Problem:

Let, we have two namespaces **A** and **B**. We want to provide access of some resources of namespace **B** to a `ServiceAccount` of namespace **A**.

**Solution:**

&#x20;Create a `RoleBinding` in namespace **B** with subject pointing to `ServiceAccount` of namespace **A**.

```yaml
kind: RoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
  name: demo
  namespace: B
subjects:
- kind: ServiceAccount
  name: demo-sa
  namespace: A
roleRef:
  kind: Role
  name: demo-role
  apiGroup: rbac.authorization.k8s.io
```
