Forum Discussion

pratikshagugale's avatar
pratikshagugale
Copper Contributor
Oct 02, 2023

Fetch AKS pods programatically (Java)

I have an existing app and service principle. I have assigned contributor role to service principle at subscription level. SP also has "Azure Kubernetes Service Cluster Admin Role", "Azure Kubernetes Service Cluster User Role" and "Reader" role at subscription level which gets inherited for all clusters. I have also done cluster role binding of SP for cluster which is created using "Azure AD authentication with Kubernetes RBAC" and "Azure AD authentication with Azure RBAC".

When I tried various approaches to fetch pods in java, I am facing following issues
1. unauthorized exception : Here, I had generated accesstoken and used it in APIClient which fetches list of pods.

2. Required classes are not present in mvn libraries:  ManagedCluster, ManagedClusterAgentPool class etc.
3. F
etch kubeconfig file, result does not seems valid

azure.kubernetesClusters().getAdminKubeConfigContent(resourceName, clusterName)


Is there anything I have missed in permissions? Or am I coding it incorrectly. LMK if there is any example I can refer to.

No RepliesBe the first to reply

Resources