Search code examples
javawindowsamazon-web-servicescmdamazon-eks

I need to run kubectl commands simultaneously in JAVA for different EKS clusters


I want to get data for two EKS clusters via JAVA (Different clusters in the same account or different account). But if I run 'aws eks update-kubeconfig' command. I am able to get data for only one of them. Can anyone suggest me a better idea?


Solution

  • I followed the below steps to connect (I used processBuilder to connect to kubectl):

    1. Set AWS environment variables.
    2. We can generate unique KUBECONFIG file for each cluster in a different name (name according to your feasibility) using --kubeconfig argument.
    3. Invoke kubectl commands via the processbuilder object.