<p>When I deploy my golang service to any namespace but the <code>default</code> namespace, the service is unable to retrieve pods on any namespace. The same service deployed on the <code>default</code> namespace works perfectly, using the golang client-go api.</p>

<p>Is this a security issue?</p>

<p>Thanks.</p>

<p>This issue is permission issue. Since you are using <code>rest.InClusterConfig(config)</code> to create client. That means it using pod's service account as credential. So check whether that service account has the permission to get pods in any namespace.</p>

<blockquote>
  <p>if service account in the pod is not defined, then it will use <code>default</code> service account.</p>
</blockquote>

<p>If RBAC is enabled in your cluster, then check the <strong>role binding</strong> in that namespace, to find out whether your service account has the permission. </p>

<pre><code># to see the list of role bindings in 'default' namespace
kubectl get rolebindings --namespace default
</code></pre>

<p>To see the specific rolebinding</p>

<pre><code>kubectl get rolebindings ROLE-BINDING-NAME --namespace default -o yaml
</code></pre>

<p>Also you can create role and role binding to give permission. To know about RBAC role and role binding see here: <a href="https://kubernetes.io/docs/reference/access-authn-authz/rbac/" rel="nofollow noreferrer">https://kubernetes.io/docs/reference/access-authn-authz/rbac/</a></p>
