Unable to run cbt CLI from within the container built from the dockerfile:
FROM google/cloud-sdk:504.0.1
RUN apt-get install -y google-cloud-cli-cbt
COPY service_account_key.json /service_account_key.json
COPY test.csv /tmp/
ENV GOOGLE_CLOUD_PROJECT=myproject-1234
ENV BIGTABLE_INSTANCE_ID=test123
ENV GOOGLE_APPLICATION_CREDENTIALS=/service_account_key.json
ENV PATH="${PATH}:/google-cloud-sdk/bin"
CMD ["sh", "-c", "\
echo project = $GOOGLE_CLOUD_PROJECT >> ~/.cbtrc && \
echo instance = $BIGTABLE_INSTANCE_ID >> ~/.cbtrc && \
gcloud auth activate-service-account --key-file=$GOOGLE_APPLICATION_CREDENTIALS && \
cbt import record /tmp/test.csv --workers=10 --timestamp=0 --batch-size=2000 \
"]
The output that shows on running the container is:
Activated service account credentials for: [my-service-account@myproject-1234.iam.gserviceaccount.com]
2024/12/23 16:50:13 [0] Writing batch:: size: 500, firstRowKey: 1234a:0, lastRowKey: 1234a:499
2024/12/23 16:50:16 [0] Writing batch:: size: 500, firstRowKey: 1234a:500, lastRowKey: 1234a:999
...
..
Clearly this is not honoring the workers=10
and batch-size=2000
arguments. Anyone has an idea why these flags do not get applied when CBT is run from within a container? The test.csv file has sufficiently large data. Please let me know if I am missing something here.
It could be because you’re using an incorrect command syntax/ parameters or the cbt
CLI tool is not properly installed in your environment.
As per this documentation that was given also by John Hanley, this is the usage of cbt in Bigtable: (You’ll see there all the references about the usage of cbt
CLI commands and compare them with those in your file)
cbt [-<option> <option-argument>] <command> <required-argument> [optional-argument]
Also, ensure that the cbt
CLI tool is installed in your environment. If it is installed, the terminal window will display the ‘All components are up to date’ message.
You can also try using the .cbtrc
file to store the required options and parameters, in a single file for your convenience.
I hope this helps.