<p>I use rancher to manager the k8s cluster to allow only access some specific project/namespace, it works good except it gots annoying error messages</p>

<pre>
$ kubectl get all
NAME                                 READY   STATUS    RESTARTS   AGE
pod/nginx-64cf74bdcb-vmssn           1/1     Running   0          14m

NAME                    TYPE       CLUSTER-IP      EXTERNAL-IP   PORT(S)        AGE
service/nginx           NodePort   10.100.132.26           80:32318/TCP   14m

NAME                            READY   UP-TO-DATE   AVAILABLE   AGE
deployment.apps/nginx           1/1     1            1           14m

NAME                                       DESIRED   CURRENT   READY   AGE
replicaset.apps/nginx-contiki-64cf74bdcb   1         1         1       14m
Error from server (Forbidden): users.jenkins.io is forbidden: User "u-4foykbynfi" cannot list resource "users" in API group "jenkins.io" in the namespace "sandbox"
Error from server (Forbidden): facts.jenkins.io is forbidden: User "u-4foykbynfi" cannot list resource "facts" in API group "jenkins.io" in the namespace "sandbox"
...
</pre>

<p>This user just wants to check the all resource on its own namespace, though it doesn't have permission to other API group, but can we just skip this check?</p>

<p>How can I configure in rancher or k8s to not show this error msg (or exit code)</p>

<p>env</p>

<ul>
<li>k8s server - v1.14.1</li>
<li>kubectl client - v1.13.2</li>
<li>rancher - v2.2.4</li>
</ul>

Larry Cai
<p>Actually, when you invoke <code>kubectl get all</code> command, k8s looks through resources catalog bounded to <code>all</code> category. You can add this category for each custom object <a href="https://kubernetes.io/docs/tasks/access-kubernetes-api/custom-resources/custom-resource-definitions/#create-a-customresourcedefinition" rel="nofollow noreferrer"><em>CRD</em></a>, supplying particular <code>CustomResourceDefinition</code> resource definition as described <a href="https://kubernetes.io/docs/tasks/access-kubernetes-api/custom-resources/custom-resource-definitions/#categories" rel="nofollow noreferrer">here</a>. </p>

<p>However, you can't change the <code>kubectl get</code> command approach, you may apply only certain filters or customize printed output.</p>

<p>If your aim only with getting output of <code>kubectl get all</code> to <code>stdout</code> avoiding error records, you can probably redirect <code>stderr</code> to <code>/dev/null</code> :</p>

<pre><code>$ kubectl get all 2&gt;/dev/null
</code></pre>

<p>Or even fetch exit code for the previous command via <code>echo $?</code>.</p>

<p>You can also add <code>--as</code> flag to <code>kubectl get</code> command in order to impersonate resource owner:</p>

<pre><code>$ kubectl get all --as=&lt;username&gt;
</code></pre>
