How to connect to a bigtable emulator using cbt command line?
Asked Answered
F

4

5

I ran the command gcloud beta emulators bigtable start but when I ran the command cbt listinstances, I got the error below

Getting list of instances: rpc error: code = Unimplemented desc = unknown service google.bigtable.admin.v2.BigtableInstanceAdmin

How can I use cbt command to connect my local bigtable emulator?

The emulator command https://cloud.google.com/sdk/gcloud/reference/beta/emulators/bigtable/start

The cbt command https://cloud.google.com/bigtable/docs/go/cbt-reference

Fez answered 8/11, 2017 at 3:54 Comment(0)
D
2

The Cloud Bigtable emulator doesn't support any instance-level operations (CRUD for instances). You can use any arbitrary instance name when connecting to it and start by creating a table.

Duggan answered 8/11, 2017 at 10:42 Comment(0)
E
4

once the emulator is running, you need to do the following:

  1. export BIGTABLE_EMULATOR_HOST=localhost:8086
  2. run cbt -project test -instance localhost:8086 ls
Elbrus answered 28/7, 2022 at 13:50 Comment(1)
In this answer, both -project test and -instance localhost:8086 are just examples. Use the same project name and instance name that were used when the emulator tables were created. If the tables were created using an official library, look for environment variables like GCP_PROJECT which may have been read at the time of table-creation.Arnhem
D
2

The Cloud Bigtable emulator doesn't support any instance-level operations (CRUD for instances). You can use any arbitrary instance name when connecting to it and start by creating a table.

Duggan answered 8/11, 2017 at 10:42 Comment(0)
B
0

You can use the local emulator if you prefix cbt:

cbt -project <PROJECT NAME> -instance localhost:8086

Hope this helps!

Bilbe answered 24/7, 2019 at 19:1 Comment(2)
This didn't work for me. It thinks "localhost:8086" is the name of an instance in a real GCP project to look for. I get errors like Getting list of tables: rpc error: code = InvalidArgument desc = When parsing 'projects/test/instances/localhost:8086' : Instance name expected in the form 'projects/<project_id>/instances/<instance_id>'. when I run cbt -project test -instance localhost:8086 ls.Benavidez
Got it working. Had to set the BIGTABLE_EMULATOR_HOST env var. It looks like both the googleapis libraries and the cbt CLI tool both use that env var to control whether they look at GCP or connect to an emulator. The emulator appears to namespace -project and -instance, so if you create stuff with one pair, you'll need the same pair specified when doing read commands to see it in the emulator.Benavidez
B
0

To summarize all the answers

# gcloud beta emulators bigtable start --host-port=0.0.0.0:8086
# $(gcloud alpha emulators bigtable env-init)

# cbt -project arbitrary-project -instance arbitrary-instance createtable test-table families=a,b

# cbt -project arbitrary-project -instance arbitrary-instance ls
test-table
Bascio answered 28/7, 2023 at 14:55 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.