Obtain Kubernetes API key with Java
Kubernetes is not involved in the OAuth side of things at all. That’s up to your IdP. More normally you would use a ServiceAccount token for automation though.
The Kubernetes config is stored as a YAML file. Use a library to read and parse it, example
In the end you'll get an object with all the keys and values from the config. Just access directly what you need.