I'm using Kubernetes Python client to manage my local Kubernetes cluster:
from kubernetes import client, config
config = client.Configuration()
config.host = "http://local_master_node:8080"
client.Configuration.set_default(config)
print(client.CoreV1Api().v1.list_node())
Everything works fine until I need to connect to a project on Google Cloud Kubernetes Engine using the key file provided by customer owning the project from Google like:
{
"type": "...",
"project_id": "...",
"private_key_id": "...",
"private_key": "...",
"client_email": "...",
"client_id": "...",
"auth_uri": "https://accounts.google.com/o/oauth2/auth",
"token_uri": "https://accounts.google.com/o/oauth2/token",
"auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
"client_x509_cert_url": "https://www.googleapis.com/..."
}
I'm trying to load it (probably doing it in wrong way):
os.environ['GOOGLE_APPLICATION_CREDENTIALS'] = os.path.abspath('credentials.json')
config.load_incluster_config()
But this code raises an exception kubernetes.config.config_exception.ConfigException: Service host/port is not set.
The questions are:
- How to provide Google credentials for Kubernetes Python client properly?
- If I am on the right track then where can I find the host/port for using with Google Cloud?
Some snippets will be appreciated.