I currently use kubernetes.config.kube_config.configuration.host to log information about which Kubernetes cluster a given Python process is connecting to, to check that the cluster I think a configuration is pointing to is actually the cluster it's using. In the 4.0 client, this moves to kubernetes.client.configuration.Configuration._default.host, which is a private API. If the API remains private, a way to access the host for the default configuration would also work. It doesn't have to be writable.
i think you probably want to get the server IP your process is connecting to, rather than relying on kube config, to do the verification check
How do I do that? I'm relying on the Python client to make the connection using the established Kubernetes defaults or the in-cluster configuration, depending on how it's running.
ok, i took another look.
from https://github.com/kubernetes-incubator/client-python/blob/2d6e453b1e0c2df295da80847298e636f74f69fe/kubernetes/client/api_client.py#L147
url = self.configuration.host + resource_path
so once you've got the ApiClient, you should be able to call api_client.configuration.host
Just to be clear: thanks, @yliaog, this does work.
Most helpful comment
Just to be clear: thanks, @yliaog, this does work.