Reputation: 648
I want to create a google cloud function to create pods on my gke cluster. I use the python kubernetes client to create them (I don't know if there is a better way to achive this).
Normally I would use the command: gcloud container clusters get-credentials cluster_name --region=cluster_region
but cloud sdk is not installed in the cloud function environment.
I've read the python api documentation and I found that it is possible to pass the path to the kubeconfig file, but I didn't found how to create that file
Upvotes: 0
Views: 821
Reputation: 75715
The get credential does nothing special:
That's all.
Now, when you use the kubectl command, the access token is used and put in the Authorization: Bearer
header and perform an API call to Kubernetes control plane.
Therefore, if you want to reach directly the control plane from your Cloud Functions with an API call, simply the Cloud Functions access token in the security header and that's all!
Upvotes: 2