is there any way to get all pods in cluster without RBAC?

11/6/2019

I looked at https://github.com/kubernetes-client/java library but it requires RBAC enabled in cluster. Is any other way to retrieve pods in kubernetes programatically?

-- user2738882
java
kubernetes

1 Answer

11/7/2019

As per Kubernetes Java Client library you can find there:

  1. InClusterClient Example (Configure a client while running inside the Kubernetes cluster.).

  2. KubeConfigFileClient Example: (Configure a client to access a Kubernetes cluster from outside.)

The first example from inside the cluster is using serviceaccount applied to the POD.

The second example from outside the cluster is using kubeconfig file.

In the official docs you can find java example of Accessing Kubernetes API Using Java client I it uses kubeconfig file by default stored in $HOME/.kube/config. In addition you can find there other examples how to programmatically access the Kubernetes API with the list of Officially-supported Kubernetes client libraries and Community-maintained client libraries

Please refer also to the Authorization Modes

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

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.

Additional resources:

Hope this help.

-- Hanx
Source: StackOverflow