<p>I am trying to use Openshift REST-API's to get the status of my cron-jobs. I am the admin of my namespace but I don't have cluster access so I can't do anything on cluster level.</p>
<p>Now, to get the status, I am first creating the role :</p>
<pre><code># oc create role podreader --verb=get --verb=list --verb=watch --resource=pods,cronjobs.batch,jobs.batch
role.rbac.authorization.k8s.io/podreader created
</code></pre>
<p>But when I try to add a role to a service account it fails.</p>
<pre><code># oc create serviceaccount nagios 
# oc policy add-role-to-user podreader system:serviceaccount:uc-immoscout-dev:nagios
Warning: role 'podreader' not found
Error from server (NotFound): clusterroles.rbac.authorization.k8s.io &quot;podreader&quot; not found
</code></pre>
<p>My main intention is to to get the status of my cron-jobs, jobs and pods which I am scheduling.</p>

<p>You'll have to add <code>--role-namespace=namespace-of-role</code> to the <code>oc policy add-role-to-user</code> command otherwise the role is treated as a cluster role.</p>
<p>From the docs:</p>
<blockquote>
<p>--role-namespace='': namespace where the role is located: empty means a role defined in cluster policy</p>
</blockquote>
