<p>I looked at <a href="https://github.com/kubernetes-client/java" rel="nofollow noreferrer">https://github.com/kubernetes-client/java</a> library but it requires RBAC enabled in cluster. Is any other way to retrieve pods in kubernetes programatically?</p>

<p>As per Kubernetes Java Client library you can find there:</p>

<ol>
<li><p><a href="https://github.com/kubernetes-client/java/blob/master/examples/src/main/java/io/kubernetes/client/examples/KubeConfigFileClientExample.java" rel="nofollow noreferrer">InClusterClient</a> Example (Configure a client while running inside the Kubernetes cluster.).</p></li>
<li><p><a href="https://github.com/kubernetes-client/java/blob/master/examples/src/main/java/io/kubernetes/client/examples/KubeConfigFileClientExample.java" rel="nofollow noreferrer">KubeConfigFileClient</a> Example: (Configure a client to access a Kubernetes cluster from outside.) </p></li>
</ol>

<p>The first example from inside the cluster is using serviceaccount applied to the POD.</p>

<p>The second example from outside the cluster is using kubeconfig file.</p>

<p>In the official docs you can find java example of <a href="https://kubernetes.io/docs/tasks/administer-cluster/access-cluster-api/#java-client" rel="nofollow noreferrer">Accessing Kubernetes API</a> Using Java client I it uses kubeconfig file by default stored in <code>$HOME/.kube/config</code>. In addition you can find there other examples how to programmatically access the Kubernetes API with the list of <a href="https://kubernetes.io/docs/reference/using-api/client-libraries/" rel="nofollow noreferrer">Officially-supported Kubernetes client libraries</a> and <a href="https://kubernetes.io/docs/reference/using-api/client-libraries/#community-maintained-client-libraries" rel="nofollow noreferrer">Community-maintained client libraries</a>  </p>

<p>Please refer also to the <a href="https://kubernetes.io/docs/reference/access-authn-authz/authorization/#authorization-modules" rel="nofollow noreferrer">Authorization Modes</a></p>

<blockquote>
  <p>Kubernetes RBAC allows admins to configure and control access to Kubernetes resources as well as the operations that can be performed on those resources.
  RBAC can be enabled by starting the API server with --authorization-mode=RBAC</p>
  
  <p>Kubernetes includes a built-in role-based access control (RBAC) mechanism that allows you to configure fine-grained and specific sets of permissions that define how a given GCP user, or group of users, can interact with any Kubernetes object in your cluster, or in a specific Namespace of your cluster.</p>
</blockquote>

<p>Additional resources:</p>

<ul>
<li><a href="https://kubernetes.io/docs/reference/access-authn-authz/rbac/" rel="nofollow noreferrer">Using RBAC Authorization</a> </li>
<li><a href="https://kubernetes.io/docs/tasks/access-application-cluster/access-cluster/" rel="nofollow noreferrer">Accessing Clusters</a> </li>
<li><a href="https://kubernetes.io/docs/tasks/configure-pod-container/configure-service-account/" rel="nofollow noreferrer">Configure Service Accounts for Pods</a> </li>
<li><a href="https://kubernetes.io/docs/reference/access-authn-authz/authorization/#authorization-modules" rel="nofollow noreferrer">Authorization Modes</a> </li>
<li><a href="https://www.replex.io/blog/kubernetes-in-production" rel="nofollow noreferrer">Kubernetes in Production</a> </li>
</ul>

<p>Hope this help.</p>
