So I have a website deployed on Google Cloud Run. From the container of the server I would like to launch job on GKE. I setup GKE in the container like this:
RUN gcloud container clusters get-credentials deployment --zone europe-west2-c --project myproject
Then I have a simple yaml in the container and I deploy it using kubectl. When running the container on a machine, everything runs ok. When running the container in Cloud Run, I get the following error:
Error from server (NotFound): the server could not find the requested resource
After doing some research it seems to be a problem from my kubectl version not matching my GKE version but I tried changing this and it didn't change anything to the error.
RUN
statements are executed of part of your Dockerfile and they are executed as part of your Docker image build (which doesn't have access to your Google credentials). This is not a Cloud Run specific problem.get-credentials
command actually doesn't get any credentials. It just crafts a KUBECONFIG file that contains GKE cluster’s IP address and CA cert (which is not needed if you want to skip server's authenticity validation via TLS).If you want to connect to GKE clusters from other places without
gcloud
, read my post Authenticating to GKE without gcloud (mirror) which details how to craft a KUBECONFIG file ahead of time and bundle with your container image.