Can't create spanner instance emulator in minikube

280 Views Asked by At

On local environment, use spanner's docker emulator to create development tools.

If use minikube, run its docker in kubernetes environment, can start its container

minikube start
eval $(minikube docker-env)
docker run -p 9010:9010 -p 9020:9020 gcr.io/cloud-spanner-emulator/emulator

But can't create an instance via gcloud command

gcloud spanner instances create test-env --config=emulator-config --description="Local dev instance" --nodes=1

It became pending.

When use an environment without minikube, I can start docker and create an instance

docker run -p 9010:9010 -p 9020:9020 gcr.io/cloud-spanner-emulator/emulator
gcloud spanner instances create test-env --config=emulator-config --description="Local dev instance" --nodes=1
gcloud spanner instances list

It seems can't run gcloud spanner command under minikube's docker-env. Why?

2

There are 2 best solutions below

0
On BEST ANSWER

Doing eval $(minikube docker-env) configures environment to use minikube’s Docker daemon (https://minikube.sigs.k8s.io/docs/commands/docker-env/).

Thus, emulator is running "inside" the docker domain that is running "inside" the minikube cluster.

You can verify the same by sshing into the minikube cluster using ssh minikube to see the list of running processes. You can then do a curl on http://localhost:9020/v1/projects/test-project/instances, which should return a result immediately.

0
On

This seems likely due to the port not being exposed.

By default, minikube only exposes ports 30000-32767. You can change that with the following:

minikube start --extra-config=apiserver.service-node-port-range=1-65535

https://minikube.sigs.k8s.io/docs/handbook/accessing/#increasing-the-nodeport-range