Kubernetes api call by Cloud Functions.
This is an example of calling Kubernetes(GKE) API from Cloud Functions.
This example used Javascript Kubernetes Client
cloud_auth.ts is used gcloud
.It is not available on Cloud Functions.
I responded as follows.
Do not define authProvider . Because CloudAuth is executed, it will be an error.
users: [
{
name: env.k8s.clusterFullName,
user: {
token: token,
}
}
]
user.token
: Google API Authentication token.
The token is obtained using the Google Auth Library.
async function getToken() {
let authResult = await auth.getClient({ scopes: 'https://www.googleapis.com/auth/cloud-platform' });
let accessToken = await authResult.getAccessToken().catch((err) => {
throw err;
})
return accessToken.token
}
gcloud beta functions deploy kubefunc --entry-point ctl --trigger-http --project=${project-id} --env-vars-file .env.yaml --memory=128MB --runtime=nodejs8