The java client should be able to find the pod's service account and authenticate itself within a cluster, and use a kubeconfig file to authenticate when outside cluster. The default location to look for a kubeconfig file is HOME/.kube/config
When outside the cluster, the gcloud container clusters get-credentials ...
command will create a kubeconfig file with proper helper configuration to authenticate. Presumably there is a java way to set up a kubeconfig file without running gcloud from a shell in the google-cloud-container library.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…